Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for copy paste to work #760

Closed
wants to merge 1 commit into from
Closed

Conversation

hasandiwan
Copy link

Eliminate the "$" executing bundle

Eliminate the "$" executing bundle
@tarcieri
Copy link
Member

The README contains a mixture of both shell and Ruby code examples. Including the prompts helps visually disambiguate which ones are which, even if it makes copy/paste slightly harder.

Also, there are multiple shell examples and this proposal only covers one of them, so at best it's inconsistent.

@ixti
Copy link
Member

ixti commented Aug 28, 2023

I find it's better to have $ prefix for shell commands. That follows common practice: $ some_command means running some_command in shell as user, and # some_command as root.

This section is also pretty standard, as it's the default README of gem skeleton provided by bundler.

With that being said, I do think it's better to let shell commands to standout from ruby code. Removing $ will eventually lead to somebody asking to bring it back because they thought it was supposed to be copy-pasted to IRB, or Gemfile, or such.

@ixti ixti closed this Aug 28, 2023
@ixti
Copy link
Member

ixti commented Aug 28, 2023

We can update it to be smaller, though. I believe people working with Ruby know what Gemfile is and how to modify it manually. Thus, we can follow the latest bundler's template, that is all that will be good for all users:

## Installation

Install the gem and add to the application's Gemfile by executing:

    $ bundle add http

If bundler is not being used to manage dependencies, install the gem by executing:

    $ gem install http

Then we can update Usage section a bit:

## Usage

``` ruby
require "http"

response = HTTP.get("https://github.com")
# => #<HTTP::Response/1.1 200 OK {"Server"=>"GitHub.com", "Date"=>"Tue, 10 May...

# Get response body as a String
HTTP.get("https://github.com").to_s
# => "\n\n\n<!DOCTYPE html>\n<html lang=\"en\" class=\"\">\n  <head prefix=\"o...

# Get response body object for streaming
body = HTTP.get("https://github.com").body
File.new("/tmp/example.html", "w") do |io|
  while chunk = body.readpartial
    io << chunk
  end
end
```

See [wiki][documentation] for more detailed documentation and usage notes.
The following API documentation is also available:

- [YARD API documentation](https://www.rubydoc.info/github/httprb/http)
- [Chainable module (all chainable methods)](https://www.rubydoc.info/github/httprb/http/HTTP/Chainable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants