Skip to content

Commit ab5762c

Browse files
committed
Set up Rubocop
1 parent 45422d7 commit ab5762c

File tree

6 files changed

+38
-18
lines changed

6 files changed

+38
-18
lines changed

.rubocop.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Metrics:
2+
Enabled: false
3+
4+
Style/AccessModifierIndentation:
5+
EnforcedStyle: outdent
6+
7+
Style/Documentation:
8+
Enabled: false
9+
10+
Style/ParallelAssignment:
11+
Enabled: false
12+
13+
Style/StringLiterals:
14+
EnforcedStyle: double_quotes
15+
16+
Style/TrailingCommaInArguments:
17+
EnforcedStyleForMultiline: comma
18+
19+
Style/TrailingCommaInLiteral:
20+
EnforcedStyleForMultiline: comma

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

33
# Specify your gem's dependencies in buckybox-api.gemspec
44
gemspec

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ require "bundler/gem_tasks"
33
require "rspec/core/rake_task"
44
RSpec::Core::RakeTask.new(:spec)
55

6-
task :default => :spec
6+
task default: :spec

buckybox-api.gemspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# coding: utf-8
2-
lib = File.expand_path('../lib', __FILE__)
2+
lib = File.expand_path("../lib", __FILE__)
33
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
44

55
Gem::Specification.new do |spec|
66
spec.name = "buckybox-api"
77
spec.version = "1.6.2"
88
spec.authors = ["Cédric Félizard"]
99
spec.email = ["[email protected]"]
10-
spec.summary = %q{RubyGem wrapper for the Bucky Box API}
10+
spec.summary = "RubyGem wrapper for the Bucky Box API"
1111
spec.description = "#{spec.summary} - https://api.buckybox.com/docs"
1212
spec.homepage = ""
1313
spec.license = "LGPLv3"
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
2626
spec.add_development_dependency "rspec", ">= 3.5"
2727
spec.add_development_dependency "vcr"
2828
spec.add_development_dependency "webmock"
29-
spec.add_development_dependency "simplecov", ">= 0.9"
29+
spec.add_development_dependency "simplecov", ">= 0.11"
30+
spec.add_development_dependency "rubocop"
3031
end

lib/buckybox/api.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def initialize(headers)
3939
self.class.headers(headers)
4040
end
4141

42-
def boxes(params = {embed: "images"}, options = {})
42+
def boxes(params = { embed: "images" }, options = {})
4343
query :get, "/boxes", params, options, price: CrazyMoney
4444
end
4545

46-
def box(id, params = {embed: "extras,images,box_items"}, options = {})
46+
def box(id, params = { embed: "extras,images,box_items" }, options = {})
4747
query :get, "/boxes/#{id}", params, options, price: CrazyMoney
4848
end
4949

@@ -74,7 +74,7 @@ def authenticate_customer(params = {}, options = {})
7474
def create_or_update_customer(json_customer)
7575
customer = JSON.parse(json_customer)
7676

77-
if customer['id']
77+
if customer["id"]
7878
query :put, "/customers/#{customer['id']}", json_customer # TODO: replace by :patch
7979
else
8080
query :post, "/customers", json_customer
@@ -108,26 +108,26 @@ def exception_type(http_code)
108108

109109
def query(type, uri, params = {}, options = {}, types = {})
110110
options = {
111-
as_object: true
111+
as_object: true,
112112
}.merge(options)
113113

114114
hash = query_cache(type, uri, params, types)
115115

116116
if options[:as_object]
117-
SuperRecursiveOpenStruct.new(hash)
117+
Response.new(hash)
118118
else
119119
hash
120120
end.freeze
121121
end
122122

123123
def query_cache(type, uri, params, types)
124-
query_fresh = -> {
124+
query_fresh = lambda do
125125
params_key = (type == :get ? :query : :body)
126126
response = self.class.public_send(type, uri, params_key => params)
127127
check_response!(response)
128128
parsed_response = response.parsed_response
129129
add_types(parsed_response, types)
130-
}
130+
end
131131

132132
if type == :get # NOTE: only cache GET method
133133
@cache ||= {}
@@ -163,7 +163,7 @@ def add_types(object, types)
163163

164164
def to_query(hash)
165165
if hash.empty?
166-
''
166+
""
167167
else
168168
hash.map do |key, value|
169169
"#{CGI.escape(key.to_s)}=#{CGI.escape(value)}"

spec/spec_helper.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# Use the documentation formatter for detailed output,
6666
# unless a formatter has already been configured
6767
# (e.g. via a command-line flag).
68-
config.default_formatter = 'doc'
68+
config.default_formatter = "doc"
6969
end
7070

7171
# Print the 10 slowest examples and example groups at the
@@ -88,10 +88,9 @@
8888

8989
require "vcr"
9090
VCR.configure do |c|
91-
c.cassette_library_dir = 'fixtures'
91+
c.cassette_library_dir = "fixtures"
9292
c.hook_into :webmock
9393
c.configure_rspec_metadata!
94-
c.filter_sensitive_data('<API-Key>') { ENV.fetch("BUCKYBOX_API_KEY") }
95-
c.filter_sensitive_data('<API-Secret>') { ENV.fetch("BUCKYBOX_API_SECRET") }
94+
c.filter_sensitive_data("<API-Key>") { ENV.fetch("BUCKYBOX_API_KEY") }
95+
c.filter_sensitive_data("<API-Secret>") { ENV.fetch("BUCKYBOX_API_SECRET") }
9696
end
97-

0 commit comments

Comments
 (0)