Skip to content

Commit ab42327

Browse files
committed
Added Rubocop, upgraded Faraday, removed Gemfile.lock.
1 parent ee215c0 commit ab42327

32 files changed

+199
-378
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ test/tmp
1515
test/version_tmp
1616
tmp
1717
examples/william.rb
18+
Gemfile.lock

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
inherit_from: .rubocop_todo.yml
2+

.rubocop_todo.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This configuration was generated by `rubocop --auto-gen-config`
2+
# on 2014-09-17 21:23:50 -0400 using RuboCop version 0.26.0.
3+
# The point is for the user to remove these configuration records
4+
# one by one as the offenses are removed from the code base.
5+
# Note that changes in the inspected code, or installation of new
6+
# versions of RuboCop, may require this file to be generated again.
7+
8+
# Offense count: 1
9+
# Configuration parameters: CountComments.
10+
Metrics/ClassLength:
11+
Max: 106
12+
13+
# Offense count: 36
14+
# Configuration parameters: AllowURI.
15+
Metrics/LineLength:
16+
Max: 140
17+
18+
# Offense count: 1
19+
# Configuration parameters: CountComments.
20+
Metrics/MethodLength:
21+
Max: 14
22+
23+
# Offense count: 1
24+
Style/AsciiComments:
25+
Enabled: false
26+
27+
# Offense count: 3
28+
# Configuration parameters: EnforcedStyle, SupportedStyles.
29+
Style/ClassAndModuleChildren:
30+
Enabled: false
31+
32+
# Offense count: 15
33+
Style/Documentation:
34+
Enabled: false
35+
36+
# Offense count: 1
37+
Style/DoubleNegation:
38+
Enabled: false
39+
40+
# Offense count: 3
41+
Style/Lambda:
42+
Enabled: false
43+
44+
# Offense count: 6
45+
# Configuration parameters: MaxSlashes.
46+
Style/RegexpLiteral:
47+
Enabled: false

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
rvm:
22
- 1.9.3
33
- 2.0.0
4+
- 2.1.2
5+

Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ gem 'pry'
1111

1212
gem 'redcarpet'
1313
gem 'yard', '~> 0.8'
14-
gem 'yard-tomdoc', git: 'git://github.com/rubyworks/yard-tomdoc'
14+
gem 'yard-tomdoc'
1515
gem 'simplecov', require: false
16+
gem 'rubocop', '~> 0.26.0', require: false

Gemfile.lock

-112
This file was deleted.

Guardfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
guard 'minitest' do
2-
watch(%r|^test/(.*)_test\.rb|)
3-
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
4-
watch(%r|^(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
5-
watch(%r|^test/test_helper\.rb|) { "test" }
2+
watch(%r{^test/(.*)_test\.rb})
3+
watch(%r{^lib/(.*)([^/]+)\.rb}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
4+
watch(%r{^(.*)([^/]+)\.rb}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
5+
watch(%r{^test/test_helper\.rb}) { 'test' }
66
end
77

88
guard 'spinach' do
9-
watch(%r|^features/(.*)\.feature|)
10-
watch(%r|^features/steps/(.*)([^/]+)\.rb|) do |m|
9+
watch(%r{^features/(.*)\.feature})
10+
watch(%r{^features/steps/(.*)([^/]+)\.rb}) do |m|
1111
"features/#{m[1]}#{m[2]}.feature"
1212
end
1313
end

Rakefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ if ENV['COVERAGE']
1414
end
1515

1616
require 'yard'
17-
YARD::Config.load_plugin('yard-tomdoc')
17+
YARD::Config.load_plugin('yard-tomdoc')
1818
YARD::Rake::YardocTask.new do |t|
1919
t.files = ['lib/**/*.rb']
2020
t.options = %w(-r README.md)
2121
end
2222

23-
2423
Bundler::GemHelper.install_tasks
2524

2625
require 'rake/testtask'
@@ -37,4 +36,7 @@ task :spinach do
3736
ruby '-S spinach'
3837
end
3938

40-
task default: [:test, :spinach]
39+
require 'rubocop/rake_task'
40+
RuboCop::RakeTask.new(:rubocop)
41+
42+
task default: [:rubocop, :test, :spinach]

examples/cyberscore.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def games
1616
end
1717

1818
def add_game(name)
19-
client.links.submissions.post({name: name})
19+
client.links.submissions.post(name: name)
2020
end
2121

2222
def motd
@@ -32,9 +32,10 @@ def method_missing(method, *args, &block)
3232
end
3333

3434
private
35+
3536
def client
36-
@client ||= Hyperclient::EntryPoint.new 'http://cs-api.heroku.com/api',
37-
{debug: false, headers: {'content-type' => 'application/json'}}
37+
@client ||= Hyperclient::EntryPoint.new 'http://cs-api.heroku.com/api',
38+
debug: false, headers: { 'content-type' => 'application/json' }
3839
end
3940
end
4041

@@ -43,18 +44,17 @@ def print_links(links)
4344
if link.is_a?(Array)
4445
print_links(link)
4546
else
46-
puts %{Found "#{name}" at "#{link.url}" }
47+
puts %(Found "#{name}" at "#{link.url}" )
4748
end
4849
end
4950
end
5051

5152
def print_games(games)
5253
games.each do |game|
53-
puts %{Found "#{game.attributes['name']}" }
54+
puts %(Found "#{game.attributes['name']}" )
5455
end
5556
end
5657

57-
5858
api = Cyberscore.new
5959

6060
puts "Let's inspect the API:"
@@ -72,5 +72,5 @@ def print_games(games)
7272
print_links(api.links.news.links)
7373
puts "\n"
7474

75-
puts "I like games!"
75+
puts 'I like games!'
7676
print_games(api.games)

examples/hal_shop.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
def print_resources(resources)
55
resources.each do |name, resource|
66
begin
7-
puts %{Found #{name} at #{resource.url}}
7+
puts %(Found #{name} at #{resource.url})
88
rescue
9-
puts %{Found #{name}}
9+
puts %(Found #{name})
1010
end
1111
end
1212
end
1313

1414
def print_attributes(attributes)
15-
puts "-----------------------------"
15+
puts '-----------------------------'
1616
attributes.each do |attribute, value|
17-
puts %{#{attribute}: #{value}}
17+
puts %(#{attribute}: #{value})
1818
end
1919
end
2020

@@ -31,9 +31,9 @@ def print_attributes(attributes)
3131
puts "Let's see what stats we have:"
3232
print_attributes(api.embedded.stats.attributes)
3333

34-
products = api.links["http://hal-shop.heroku.com/rels/products"].resource
34+
products = api.links['http://hal-shop.heroku.com/rels/products'].resource
3535

36-
puts
36+
puts
3737
puts "And what's the inventory of products?"
3838
puts products.attributes['inventory_size']
3939

features/steps/default_config.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class Spinach::Features::DefaultConfig < Spinach::FeatureSteps
66
end
77

88
step 'the request should have been sent with the correct JSON headers' do
9-
assert_requested :get, 'api.example.org', headers: {'Content-Type' => 'application/json', 'Accept' => 'application/json'}
9+
assert_requested :get, 'api.example.org', headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
1010
end
1111

1212
step 'I send some data to the API' do
13-
stub_request(:post, "http://api.example.org/posts")
14-
api.links.posts.post({title: 'My first blog post'})
13+
stub_request(:post, 'http://api.example.org/posts')
14+
assert_equal 200, api.links.posts.post(title: 'My first blog post').status
1515
end
1616

1717
step 'it should have been encoded as JSON' do

features/support/api.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module API
55
include Spinach::Fixtures
66

77
before do
8-
stub_request(:any, %r{api.example.org*}).to_return(body: root_response, headers:{'Content-Type' => 'application/json'})
9-
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: {'Content-Type' => 'application/json'})
10-
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: {'Content-Type' => 'application/json'})
8+
stub_request(:any, %r{api.example.org*}).to_return(body: root_response, headers: { 'Content-Type' => 'application/json' })
9+
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/json' })
10+
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: { 'Content-Type' => 'application/json' })
1111
end
1212

1313
def api

features/support/fixtures.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def post_response
3434
"comments": [
3535
{
3636
"title": "Some comment"
37-
}
37+
}
3838
]
3939
}
4040
}'

hyperclient.gemspec

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
require File.expand_path('../lib/hyperclient/version', __FILE__)
33

44
Gem::Specification.new do |gem|
5-
gem.authors = ["Oriol Gual"]
6-
gem.email = ["[email protected]"]
7-
gem.description = %q{HyperClient is a Ruby Hypermedia API client.}
8-
gem.summary = %q{}
9-
gem.homepage = "http://codegram.github.com/hyperclient/"
10-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
5+
gem.authors = ['Oriol Gual']
6+
gem.email = ['[email protected]']
7+
gem.description = 'HyperClient is a Ruby Hypermedia API client.'
8+
gem.summary = ''
9+
gem.homepage = 'http://codegram.github.com/hyperclient/'
10+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
1111
gem.files = `git ls-files`.split("\n")
1212
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13-
gem.name = "hyperclient"
14-
gem.require_paths = ["lib"]
13+
gem.name = 'hyperclient'
14+
gem.require_paths = ['lib']
1515
gem.version = Hyperclient::VERSION
1616

1717
gem.add_dependency 'faraday', '~> 0.8'
@@ -26,4 +26,5 @@ Gem::Specification.new do |gem|
2626
gem.add_development_dependency 'mocha', '~> 0.13'
2727
gem.add_development_dependency 'rack-test', '~> 0.6'
2828
gem.add_development_dependency 'spinach'
29+
gem.add_development_dependency 'faraday-digestauth'
2930
end

lib/faraday/connection.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'faraday'
2-
require_relative 'request/digest_authentication'
2+
require 'faraday/digestauth'
33

44
module Faraday
55
# Reopen Faraday::Connection to add a helper to set the digest auth data.
@@ -11,7 +11,7 @@ class Connection
1111
# password - A String with the password.
1212
#
1313
def digest_auth(user, password)
14-
self.builder.insert(0, Faraday::Request::DigestAuth, user, password)
14+
builder.insert(0, Faraday::Request::DigestAuth, user, password)
1515
end
1616
end
1717
end

0 commit comments

Comments
 (0)