Skip to content

Commit

Permalink
Added Rubocop, upgraded Faraday, removed Gemfile.lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Sep 26, 2014
1 parent ee215c0 commit ab42327
Show file tree
Hide file tree
Showing 32 changed files with 199 additions and 378 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ test/tmp
test/version_tmp
tmp
examples/william.rb
Gemfile.lock
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inherit_from: .rubocop_todo.yml

47 changes: 47 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2014-09-17 21:23:50 -0400 using RuboCop version 0.26.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 106

# Offense count: 36
# Configuration parameters: AllowURI.
Metrics/LineLength:
Max: 140

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 14

# Offense count: 1
Style/AsciiComments:
Enabled: false

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false

# Offense count: 15
Style/Documentation:
Enabled: false

# Offense count: 1
Style/DoubleNegation:
Enabled: false

# Offense count: 3
Style/Lambda:
Enabled: false

# Offense count: 6
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:
Enabled: false
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rvm:
- 1.9.3
- 2.0.0
- 2.1.2

3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ gem 'pry'

gem 'redcarpet'
gem 'yard', '~> 0.8'
gem 'yard-tomdoc', git: 'git://github.com/rubyworks/yard-tomdoc'
gem 'yard-tomdoc'
gem 'simplecov', require: false
gem 'rubocop', '~> 0.26.0', require: false
112 changes: 0 additions & 112 deletions Gemfile.lock

This file was deleted.

12 changes: 6 additions & 6 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
guard 'minitest' do
watch(%r|^test/(.*)_test\.rb|)
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
watch(%r|^(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
watch(%r|^test/test_helper\.rb|) { "test" }
watch(%r{^test/(.*)_test\.rb})
watch(%r{^lib/(.*)([^/]+)\.rb}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
watch(%r{^(.*)([^/]+)\.rb}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
watch(%r{^test/test_helper\.rb}) { 'test' }
end

guard 'spinach' do
watch(%r|^features/(.*)\.feature|)
watch(%r|^features/steps/(.*)([^/]+)\.rb|) do |m|
watch(%r{^features/(.*)\.feature})
watch(%r{^features/steps/(.*)([^/]+)\.rb}) do |m|
"features/#{m[1]}#{m[2]}.feature"
end
end
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ if ENV['COVERAGE']
end

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


Bundler::GemHelper.install_tasks

require 'rake/testtask'
Expand All @@ -37,4 +36,7 @@ task :spinach do
ruby '-S spinach'
end

task default: [:test, :spinach]
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)

task default: [:rubocop, :test, :spinach]
14 changes: 7 additions & 7 deletions examples/cyberscore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def games
end

def add_game(name)
client.links.submissions.post({name: name})
client.links.submissions.post(name: name)
end

def motd
Expand All @@ -32,9 +32,10 @@ def method_missing(method, *args, &block)
end

private

def client
@client ||= Hyperclient::EntryPoint.new 'http://cs-api.heroku.com/api',
{debug: false, headers: {'content-type' => 'application/json'}}
@client ||= Hyperclient::EntryPoint.new 'http://cs-api.heroku.com/api',
debug: false, headers: { 'content-type' => 'application/json' }
end
end

Expand All @@ -43,18 +44,17 @@ def print_links(links)
if link.is_a?(Array)
print_links(link)
else
puts %{Found "#{name}" at "#{link.url}" }
puts %(Found "#{name}" at "#{link.url}" )
end
end
end

def print_games(games)
games.each do |game|
puts %{Found "#{game.attributes['name']}" }
puts %(Found "#{game.attributes['name']}" )
end
end


api = Cyberscore.new

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

puts "I like games!"
puts 'I like games!'
print_games(api.games)
12 changes: 6 additions & 6 deletions examples/hal_shop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
def print_resources(resources)
resources.each do |name, resource|
begin
puts %{Found #{name} at #{resource.url}}
puts %(Found #{name} at #{resource.url})
rescue
puts %{Found #{name}}
puts %(Found #{name})
end
end
end

def print_attributes(attributes)
puts "-----------------------------"
puts '-----------------------------'
attributes.each do |attribute, value|
puts %{#{attribute}: #{value}}
puts %(#{attribute}: #{value})
end
end

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

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

puts
puts
puts "And what's the inventory of products?"
puts products.attributes['inventory_size']

Expand Down
6 changes: 3 additions & 3 deletions features/steps/default_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Spinach::Features::DefaultConfig < Spinach::FeatureSteps
end

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

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

step 'it should have been encoded as JSON' do
Expand Down
6 changes: 3 additions & 3 deletions features/support/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module API
include Spinach::Fixtures

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

def api
Expand Down
2 changes: 1 addition & 1 deletion features/support/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def post_response
"comments": [
{
"title": "Some comment"
}
}
]
}
}'
Expand Down
17 changes: 9 additions & 8 deletions hyperclient.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
require File.expand_path('../lib/hyperclient/version', __FILE__)

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

gem.add_dependency 'faraday', '~> 0.8'
Expand All @@ -26,4 +26,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'mocha', '~> 0.13'
gem.add_development_dependency 'rack-test', '~> 0.6'
gem.add_development_dependency 'spinach'
gem.add_development_dependency 'faraday-digestauth'
end
4 changes: 2 additions & 2 deletions lib/faraday/connection.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'faraday'
require_relative 'request/digest_authentication'
require 'faraday/digestauth'

module Faraday
# Reopen Faraday::Connection to add a helper to set the digest auth data.
Expand All @@ -11,7 +11,7 @@ class Connection
# password - A String with the password.
#
def digest_auth(user, password)
self.builder.insert(0, Faraday::Request::DigestAuth, user, password)
builder.insert(0, Faraday::Request::DigestAuth, user, password)
end
end
end
Loading

0 comments on commit ab42327

Please sign in to comment.