Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Miscellaneous cleanup.

  • Loading branch information...
commit ea761f7f9f0febcff5269696cc6a98964b00919a 1 parent 9e3b956
@tristandunn tristandunn authored
View
2  Gemfile
@@ -1,3 +1,3 @@
-source 'http://rubygems.org'
+source "http://rubygems.org"
gemspec
View
12 Rakefile
@@ -1,16 +1,16 @@
-require 'bundler/setup'
-require 'rspec/core/rake_task'
-require 'yard'
+require "bundler/setup"
+require "rspec/core/rake_task"
+require "yard"
Bundler::GemHelper.install_tasks
RSpec::Core::RakeTask.new do |t|
- t.pattern = 'spec/**/*_spec.rb'
+ t.pattern = "spec/**/*_spec.rb"
end
YARD::Rake::YardocTask.new do |t|
- t.files = ['lib/**/*.rb']
- t.options = ['--no-private']
+ t.files = ["lib/**/*.rb"]
+ t.options = ["--no-private"]
end
task :default => :spec
View
30 bartender.gemspec
@@ -1,25 +1,25 @@
Gem::Specification.new do |s|
- s.name = 'bartender'
- s.version = '0.1.1'
+ s.name = "bartender"
+ s.version = "0.1.1"
s.platform = Gem::Platform::RUBY
s.authors = []
s.email = []
- s.homepage = 'http://openbeerdatabase.com'
- s.summary = 'A Ruby client for Open Beer Database.'
- s.description = 'A Ruby client for Open Beer Database.'
+ s.homepage = "http://openbeerdatabase.com"
+ s.summary = "A Ruby client for Open Beer Database."
+ s.description = "A Ruby client for Open Beer Database."
- s.required_rubygems_version = '>= 1.3.6'
- s.rubyforge_project = 'bartender'
+ s.required_rubygems_version = ">= 1.3.6"
+ s.rubyforge_project = "bartender"
- s.add_dependency 'yajl-ruby', '>= 0.8.2'
+ s.add_dependency "yajl-ruby", ">= 0.8.2"
- s.add_development_dependency 'bluecloth', '>= 2.1.0'
- s.add_development_dependency 'bourne', '>= 1.0.0'
- s.add_development_dependency 'bundler', '>= 1.0.13'
- s.add_development_dependency 'mocha', '>= 0.9.8'
- s.add_development_dependency 'rspec', '>= 2.6.0'
- s.add_development_dependency 'yard', '>= 0.6.8'
+ s.add_development_dependency "bluecloth", ">= 2.1.0"
+ s.add_development_dependency "bourne", ">= 1.0.0"
+ s.add_development_dependency "bundler", ">= 1.0.13"
+ s.add_development_dependency "mocha", ">= 0.9.8"
+ s.add_development_dependency "rspec", ">= 2.6.0"
+ s.add_development_dependency "yard", ">= 0.6.8"
s.files = `git ls-files`.split("\n")
- s.require_path = 'lib'
+ s.require_path = "lib"
end
View
12 lib/bartender.rb
@@ -1,11 +1,11 @@
-require 'yajl/json_gem'
+require "yajl/json_gem"
-require 'bartender/configuration'
-require 'bartender/request'
-require 'bartender/version'
+require "bartender/configuration"
+require "bartender/request"
+require "bartender/version"
-require 'bartender/beer'
-require 'bartender/brewery'
+require "bartender/beer"
+require "bartender/brewery"
# Top-level interface to Bartender.
module Bartender
View
2  lib/bartender/beer.rb
@@ -8,7 +8,7 @@ class Beer
# @option options [String] :page The page number to request (defautls to +1+).
# @option options [String] :per_page The number of beers to return per page (defaults to +50+).
def self.all(options = {})
- Bartender::Request.get('/beers', options)
+ Bartender::Request.get("/beers", options)
end
# Retrieve a specific beer.
View
2  lib/bartender/brewery.rb
@@ -8,7 +8,7 @@ class Brewery
# @option options [String] :page The page number to request (defautls to +1+).
# @option options [String] :per_page The number of breweries to return per page (defaults to +50+).
def self.all(options = {})
- Bartender::Request.get('/breweries', options)
+ Bartender::Request.get("/breweries", options)
end
# Retrieve a specific brewery.
View
2  lib/bartender/configuration.rb
@@ -21,7 +21,7 @@ class Configuration
# Instantiated from {Bartender.configuration}. Sets defaults.
def initialize
- self.host = 'api.openbeerdatabase.com'
+ self.host = "api.openbeerdatabase.com"
self.port = 80
self.http_open_timeout = 2
self.http_read_timeout = 2
View
8 lib/bartender/request.rb
@@ -1,5 +1,5 @@
-require 'cgi'
-require 'net/http'
+require "cgi"
+require "net/http"
module Bartender
# @private
@@ -31,8 +31,8 @@ def self.hash_to_query_string(hash)
}.delete_if { |key, value|
value.to_s.empty?
}.collect { |key, value|
- "#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{CGI.escape(value.to_s)}"
- }.join('&')
+ "#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack("H*") }}=#{CGI.escape(value.to_s)}"
+ }.join("&")
end
end
end
View
4 lib/bartender/version.rb
@@ -1,7 +1,7 @@
module Bartender
# Bartender version.
- VERSION = '0.1.0'
+ VERSION = "0.1.0"
# Version of the Open Beer Database API.
- API_VERSION = '1'
+ API_VERSION = "1"
end
View
18 spec/bartender/beer_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
-describe Bartender::Beer, '.all' do
+describe Bartender::Beer, ".all" do
before do
Bartender::Request.stubs(:get)
end
- it 'retrieves all beers, without options' do
+ it "retrieves all beers, without options" do
Bartender::Beer.all
- Bartender::Request.should have_received(:get).with('/beers', {})
+ Bartender::Request.should have_received(:get).with("/beers", {})
end
- it 'retrieves all beers, with options' do
+ it "retrieves all beers, with options" do
Bartender::Beer.all(:page => 2)
- Bartender::Request.should have_received(:get).with('/beers', { :page => 2 })
+ Bartender::Request.should have_received(:get).with("/beers", { :page => 2 })
end
end
-describe Bartender::Beer, '.find' do
+describe Bartender::Beer, ".find" do
before do
Bartender::Request.stubs(:get)
end
- it 'retrieves a specific beer' do
+ it "retrieves a specific beer" do
Bartender::Beer.find(1)
- Bartender::Request.should have_received(:get).with('/beers/1')
+ Bartender::Request.should have_received(:get).with("/beers/1")
end
end
View
18 spec/bartender/brewery_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
-describe Bartender::Brewery, '.all' do
+describe Bartender::Brewery, ".all" do
before do
Bartender::Request.stubs(:get)
end
- it 'retrieves all breweries, without options' do
+ it "retrieves all breweries, without options" do
Bartender::Brewery.all
- Bartender::Request.should have_received(:get).with('/breweries', {})
+ Bartender::Request.should have_received(:get).with("/breweries", {})
end
- it 'retrieves all breweries, with options' do
+ it "retrieves all breweries, with options" do
Bartender::Brewery.all(:page => 2)
- Bartender::Request.should have_received(:get).with('/breweries', { :page => 2 })
+ Bartender::Request.should have_received(:get).with("/breweries", { :page => 2 })
end
end
-describe Bartender::Brewery, '.find' do
+describe Bartender::Brewery, ".find" do
before do
Bartender::Request.stubs(:get)
end
- it 'retrieves a specific brewery' do
+ it "retrieves a specific brewery" do
Bartender::Brewery.find(1)
- Bartender::Request.should have_received(:get).with('/breweries/1')
+ Bartender::Request.should have_received(:get).with("/breweries/1")
end
end
View
4 spec/bartender/configuration_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Bartender::Configuration do
it { should have_configuration_option(:port).default(80) }
@@ -6,5 +6,5 @@
it { should have_configuration_option(:private_token).default(nil) }
it { should have_configuration_option(:http_open_timeout).default(2) }
it { should have_configuration_option(:http_read_timeout).default(2) }
- it { should have_configuration_option(:host).default('api.openbeerdatabase.com') }
+ it { should have_configuration_option(:host).default("api.openbeerdatabase.com") }
end
View
56 spec/bartender/request_spec.rb
@@ -1,63 +1,63 @@
-require 'spec_helper'
+require "spec_helper"
-describe Bartender::Request, '.get' do
- let(:request) { stub('Request', :get => response) }
- let(:response) { stub('Response', :body => '{}') }
+describe Bartender::Request, ".get" do
+ let(:request) { stub("Request", :get => response) }
+ let(:response) { stub("Response", :body => "{}") }
before do
- Bartender::Request.stubs(:uri).returns('/')
+ Bartender::Request.stubs(:uri).returns("/")
Bartender::Request.stubs(:request).returns(request)
Bartender.configuration.public_token = nil
end
- it 'constructs the request URI' do
- Bartender::Request.get('/', {})
- Bartender::Request.should have_received(:uri).with('/', {})
+ it "constructs the request URI" do
+ Bartender::Request.get("/", {})
+ Bartender::Request.should have_received(:uri).with("/", {})
end
- it 'makes an API request' do
- Bartender::Request.get('/')
- request.should have_received(:get).with('/')
+ it "makes an API request" do
+ Bartender::Request.get("/")
+ request.should have_received(:get).with("/")
end
- it 'returns the parsed JSON response body' do
- Bartender::Request.get('/').should == {}
+ it "returns the parsed JSON response body" do
+ Bartender::Request.get("/").should == {}
end
- it 'includes public token when configured' do
- Bartender.configuration.public_token = 'a1b2c3'
- Bartender::Request.get('/')
- Bartender::Request.should have_received(:uri).with('/', :token => 'a1b2c3')
+ it "includes public token when configured" do
+ Bartender.configuration.public_token = "a1b2c3"
+ Bartender::Request.get("/")
+ Bartender::Request.should have_received(:uri).with("/", :token => "a1b2c3")
end
- it 'allows overriding of configured public token' do
- Bartender.configuration.public_token = 'x1y2z3'
- Bartender::Request.get('/')
- Bartender::Request.should have_received(:uri).with('/', :token => 'x1y2z3')
+ it "allows overriding of configured public token" do
+ Bartender.configuration.public_token = "x1y2z3"
+ Bartender::Request.get("/")
+ Bartender::Request.should have_received(:uri).with("/", :token => "x1y2z3")
end
end
-describe Bartender::Request, '.request' do
- it 'creates a new HTTP client' do
+describe Bartender::Request, ".request" do
+ it "creates a new HTTP client" do
Bartender::Request.request.should be_a(Net::HTTP)
end
- it 'connects to configured host and port' do
+ it "connects to configured host and port" do
Bartender::Request.request.address.should == Bartender.configuration.host
Bartender::Request.request.port.should == Bartender.configuration.port
end
- it 'sets configured open and read timeouts' do
+ it "sets configured open and read timeouts" do
Bartender::Request.request.open_timeout.should == Bartender.configuration.http_open_timeout
Bartender::Request.request.read_timeout.should == Bartender.configuration.http_read_timeout
end
end
-describe Bartender::Request, '.uri' do
+describe Bartender::Request, ".uri" do
let(:version) { Bartender::API_VERSION }
- it 'returns a path and query string based on the provided options' do
- Bartender::Request.uri('/path', { :a => 1, :b => 2 }).should == "/v#{version}/path.json?a=1&b=2"
+ it "returns a path and query string based on the provided options" do
+ Bartender::Request.uri("/path", { :a => 1, :b => 2 }).should == "/v#{version}/path.json?a=1&b=2"
end
end
View
6 spec/spec_helper.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../lib/bartender', __FILE__)
-require 'bourne'
+require File.expand_path("../../lib/bartender", __FILE__)
+require "bourne"
-Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file|
+Dir[File.expand_path("../support/**/*.rb", __FILE__)].each do |file|
require file
end
View
8 spec/support/have_configuration_option_matcher.rb
@@ -2,12 +2,12 @@
match do |configuration|
configuration.should respond_to(option)
- if instance_variables.include?('@default')
+ if instance_variables.include?("@default")
configuration.send(option).should == @default
end
- configuration.__send__(:"#{option}=", 'value')
- configuration.__send__(option).should == 'value'
+ configuration.__send__(:"#{option}=", "value")
+ configuration.__send__(option).should == "value"
end
chain :default do |default|
@@ -17,7 +17,7 @@
failure_message do
description = "expected #{subject} to have"
description << " configuration option #{option.inspect}"
- description << " with a default of #{@default.inspect}" if instance_variables.include?('@default')
+ description << " with a default of #{@default.inspect}" if instance_variables.include?("@default")
description
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.