Skip to content

Commit

Permalink
Update rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
jue58 committed Oct 31, 2016
1 parent 7bdd24f commit 99483ae
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 121 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ Style/AsciiComments:

CyclomaticComplexity:
Max: 10

Style/FrozenStringLiteralComment:
Enabled: false

Style/SymbolProc:
Exclude:
- 'lib/kintone/query.rb'
4 changes: 2 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
guard :rspec, all_after_pass: false, all_on_start: false, cmd: 'bundle exec rspec' do
guard :rspec, all_after_pass: false, all_on_start: false, cmd: 'rspec' do
watch(%r{spec/.+_spec\.rb$})
watch(%r{lib/(.+)\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
watch(%r{lib/(.+)/.+\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
end

guard :rubocop, all_on_start: false, cmd: 'bundle exec rubocop' do
guard :rubocop, all_on_start: false, cmd: 'rubocop' do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
3 changes: 1 addition & 2 deletions kintone.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# coding: utf-8
# rubocop:disable Style/RegexpLiteral
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'kintone/version'
Expand All @@ -25,7 +24,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'bundler', '~> 1.5'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 3.0.0'
spec.add_development_dependency 'rubocop', '~> 0.24.1'
spec.add_development_dependency 'rubocop', '~> 0.44.1'
spec.add_development_dependency 'webmock', '~> 1.18'
spec.add_development_dependency 'rspec-parameterized', '~> 0.1.2'
spec.add_development_dependency 'coveralls'
Expand Down
14 changes: 8 additions & 6 deletions lib/kintone/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
require 'kintone/query'

class Kintone::Api
BASE_PATH = '/k/v1/'
COMMAND = '%s.json'
BASE_PATH = '/k/v1/'.freeze
COMMAND = '%s.json'.freeze
ACCESSIBLE_COMMAND = [
:record,
:records,
Expand Down Expand Up @@ -92,9 +92,7 @@ def post_file(url, path, content_type, original_filename)
@connection.post do |request|
request.url url
request.headers['Content-Type'] = 'multipart/form-data'
request.body = { file: Faraday::UploadIO.new(
path, content_type, original_filename,
'Content-Disposition' => 'form-data') }
request.body = { file: Faraday::UploadIO.new(path, content_type, original_filename) }
end
response.body['fileKey']
end
Expand All @@ -103,10 +101,14 @@ def method_missing(name, *args)
if ACCESSIBLE_COMMAND.include?(name)
CommandAccessor.send(name, self)
else
super(name, *args)
super
end
end

def respond_to_missing?(name, *args)
ACCESSIBLE_COMMAND.include?(name) || super
end

class CommandAccessor
extend Kintone::Command::Accessor
end
Expand Down
8 changes: 6 additions & 2 deletions lib/kintone/api/guest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Kintone::Api
class Guest
extend Forwardable

GUEST_PATH = '/k/guest/%s/v1/'
GUEST_PATH = '/k/guest/%s/v1/'.freeze
ACCESSIBLE_COMMAND = [
:record,
:records,
Expand Down Expand Up @@ -41,10 +41,14 @@ def method_missing(name, *args)
if ACCESSIBLE_COMMAND.include?(name)
CommandAccessor.send(name, self)
else
super(name, *args)
super
end
end

def respond_to_missing?(name, *args)
ACCESSIBLE_COMMAND.include?(name) || super
end

class CommandAccessor
extend Kintone::Command::Accessor
end
Expand Down
2 changes: 1 addition & 1 deletion lib/kintone/command/accessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ def space_guests(api)
SpaceGuests.new(api)
end

alias_method :bulk, :bulk_request
alias bulk bulk_request
end
end
2 changes: 1 addition & 1 deletion lib/kintone/command/guests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def delete(guests)
@api.delete(@url, guests: guests)
end

alias_method :create, :register
alias create register
end
2 changes: 1 addition & 1 deletion lib/kintone/command/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def update(app, id, record, revision: nil)
@api.put(@url, body)
end

alias_method :create, :register
alias create register
end
2 changes: 1 addition & 1 deletion lib/kintone/command/records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def delete(app, ids, revisions: nil)
@api.delete(@url, params)
end

alias_method :create, :register
alias create register
end
2 changes: 1 addition & 1 deletion lib/kintone/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def inspect
to_s
end

alias_method :f, :field
alias f field

private

Expand Down
2 changes: 1 addition & 1 deletion lib/kintone/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Kintone
VERSION = '0.1.4'
VERSION = '0.1.4'.freeze
end
32 changes: 22 additions & 10 deletions spec/kintone/api/guest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
query: params
)
.to_return(body: "{\"abc\":\"def\"}", status: 200,
headers: { 'Content-type' => 'application/json' })
.to_return(
body: '{"abc":"def"}',
status: 200,
headers: { 'Content-type' => 'application/json' }
)
end

subject { target.get(path, params) }
Expand All @@ -45,10 +48,13 @@
)
.with(
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
body: '{"p1":"abc","p2":"def"}'
)
.to_return(
body: '{"abc":"def"}',
status: 200,
headers: { 'Content-type' => 'application/json' }
)
.to_return(body: "{\"abc\":\"def\"}", status: 200,
headers: { 'Content-type' => 'application/json' })
end

subject { target.post(path, body) }
Expand All @@ -67,10 +73,13 @@
)
.with(
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
body: '{"p1":"abc","p2":"def"}'
)
.to_return(
body: '{"abc":"def"}',
status: 200,
headers: { 'Content-type' => 'application/json' }
)
.to_return(body: "{\"abc\":\"def\"}", status: 200,
headers: { 'Content-type' => 'application/json' })
end

subject { target.put(path, body) }
Expand All @@ -91,8 +100,11 @@
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
)
.to_return(body: "{\"abc\":\"def\"}", status: 200,
headers: { 'Content-type' => 'application/json' })
.to_return(
body: '{"abc":"def"}',
status: 200,
headers: { 'Content-type' => 'application/json' }
)
end

subject { target.delete(path, params) }
Expand Down
Loading

0 comments on commit 99483ae

Please sign in to comment.