tinybucket 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f31ef006e2349c6b675693438c0495738f12f8e
4
- data.tar.gz: 8e6936028ede63f3fb2329fee38a642ae24c6977
3
+ metadata.gz: 71d4192b2e8e49b41049f5b1f55fb6e76eb88aeb
4
+ data.tar.gz: 6f7140b93b530ffb03bce656742dfbbbb097cffc
5
5
  SHA512:
6
- metadata.gz: 233c5f18bf339318144d37ddb80ab00ce3867e276ccd2fd0efb39ca105d1453a0b6434e12cab2fababcac270d50d4b1df2de953e7a05c4a1f1ce264aaa75bd53
7
- data.tar.gz: d7be4ba5300b87cfe0f18dabc5820564e0fa98f6c4b6515b7f26e19412a8c22575933d80c8add582311a80bc44d6c9c6d1145b46f5a93acf0ac0c4d15588ec04
6
+ metadata.gz: 15cefdad2130c594419751a8debd493e5362a1d6d4cb0d46b16dd7aea8f4bd86cdd0208052ab8747ea614f5ed428fc1e01eac29ca39700ccce9fac7ae4ccf6b4
7
+ data.tar.gz: 2439679903d2ae7ea9e7eabf51e02e3a1da7ff37b03de89f36dbc6000182102a57c37692b5e09376fed768217ab6378f2f6f6ee3efb74d5c186ead247fb83480
data/.rubocop.yml CHANGED
@@ -42,3 +42,6 @@ Style/AlignHash:
42
42
 
43
43
  Style/RaiseArgs:
44
44
  Enabled: false
45
+
46
+ Metrics/AbcSize:
47
+ Max: 18
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
+ sudo: false
1
2
  language: ruby
3
+ before_install:
4
+ - gem install bundler -v 1.10.6
2
5
  rvm: 2.1.2
3
6
  addons:
4
7
  code_climate:
data/Gemfile CHANGED
@@ -3,6 +3,15 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in bitbucket.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'rake', '~> 10.4'
7
+ gem 'rspec', '~> 3.4'
8
+ gem 'rspec-mocks', '~> 3.4'
9
+ gem 'webmock', '~> 1.22'
10
+ gem 'rubocop', '~> 0.35'
11
+
12
+ gem 'yard', '~> 0.8'
13
+ gem 'yardstick', '~> 0.9.9'
14
+
6
15
  group :development, :test do
7
16
  gem 'pry'
8
17
  gem 'pry-stack_explorer'
@@ -17,6 +26,7 @@ group :development, :test do
17
26
  end
18
27
 
19
28
  group :test do
20
- gem 'coveralls', require: false
29
+ gem 'simplecov', '~> 0.11', require: false
30
+ gem 'coveralls', '~> 0.8', require: false
21
31
  gem 'codeclimate-test-reporter', require: nil
22
32
  end
@@ -51,12 +51,13 @@ module FaradayMiddleware
51
51
 
52
52
  def include_body_params?(env)
53
53
  # see RFC 5849, section 3.4.1.3.1 for details
54
- !(type = env[:request_headers][OAuth::CONTENT_TYPE]) or type == OAuth::TYPE_URLENCODED
54
+ !(type = env[:request_headers][OAuth::CONTENT_TYPE]) ||
55
+ type == OAuth::TYPE_URLENCODED
55
56
  end
56
57
 
57
58
  def signature_params(params)
58
- params.empty? ? params :
59
- params.reject { |_k, v| v.respond_to?(:content_type) }
59
+ return params if params.empty?
60
+ params.reject { |_k, v| v.respond_to?(:content_type) }
60
61
  end
61
62
  end
62
63
 
@@ -36,7 +36,7 @@ module Tinybucket
36
36
  when Tinybucket::Model::Page
37
37
  result.items.map { |m| m.commented_to = commented_to }
38
38
  else
39
- fail ArgumentError, "Invalid result: #{result.inspect}"
39
+ raise ArgumentError, "Invalid result: #{result.inspect}"
40
40
  end
41
41
 
42
42
  result
@@ -24,7 +24,7 @@ module Tinybucket
24
24
  def urlencode(v, key)
25
25
  if v.blank? || (escaped = CGI.escape(v.to_s)).blank?
26
26
  msg = "Invalid #{key} parameter. (#{v})"
27
- fail ArgumentError, msg
27
+ raise ArgumentError, msg
28
28
  end
29
29
 
30
30
  escaped
@@ -22,7 +22,7 @@ module Tinybucket
22
22
  when Tinybucket::Model::PullRequest
23
23
  base_path_of_pullrequest
24
24
  else
25
- fail ArgumentError, 'commented_to must be a pull_request or commit'
25
+ raise ArgumentError, 'commented_to must be a pull_request or commit'
26
26
  end
27
27
  end
28
28
 
@@ -7,7 +7,7 @@ module Tinybucket
7
7
  klass =
8
8
  begin
9
9
  name = "#{klass_name}Api".intern
10
- (Tinybucket::Api).const_get name
10
+ Tinybucket::Api.const_get name
11
11
  rescue => e
12
12
  # TODO: log exception
13
13
  Tinybucket.logger.error e
@@ -37,12 +37,12 @@ module Tinybucket
37
37
  when String, Symbol
38
38
  owners_repos(*args)
39
39
  else
40
- fail ArgumentError
40
+ raise ArgumentError
41
41
  end
42
42
  when 2
43
43
  owners_repos(*args)
44
44
  else
45
- fail ArgumentError
45
+ raise ArgumentError
46
46
  end
47
47
  end
48
48
 
@@ -71,8 +71,8 @@ module Tinybucket
71
71
  private
72
72
 
73
73
  def public_repos(*args)
74
- options = (args.empty?) ? {} : args.first
75
- fail ArgumentError unless options.is_a?(Hash)
74
+ options = args.empty? ? {} : args.first
75
+ raise ArgumentError unless options.is_a?(Hash)
76
76
 
77
77
  @repos ||= create_instance('Repos', options)
78
78
  @repos.list(options)
@@ -81,7 +81,7 @@ module Tinybucket
81
81
  def owners_repos(*args)
82
82
  owner = args.first
83
83
  options = (args.size == 2) ? args[1] : {}
84
- fail ArgumentError unless options.is_a?(Hash)
84
+ raise ArgumentError unless options.is_a?(Hash)
85
85
 
86
86
  @user ||= create_instance('User', options)
87
87
  @user.username = owner
@@ -14,7 +14,7 @@ module Tinybucket
14
14
 
15
15
  # TODO: cache connection for each (options, parser) pairs.
16
16
  Faraday.new(
17
- conn_options.merge(builder: stack(options, parser)))
17
+ conn_options.merge(builder: stack(parser, options)))
18
18
  end
19
19
 
20
20
  private
@@ -49,7 +49,7 @@ module Tinybucket
49
49
  end
50
50
  end
51
51
 
52
- def stack(options = {}, parser, &block)
52
+ def stack(parser, options = {}, &block)
53
53
  Faraday::RackBuilder.new(&block) and return if block_given?
54
54
 
55
55
  # TODO: cache stack for each (options, parser) pairs
@@ -1,4 +1,5 @@
1
1
  module Tinybucket
2
2
  module Constants
3
+ MISSING_REPOSITORY_KEY = 'This method call require repository keys.'.freeze
3
4
  end
4
5
  end
@@ -13,7 +13,7 @@ module Tinybucket
13
13
  def initialize(json)
14
14
  self.attributes = json
15
15
  @api_config = {}
16
- @_loaded = !(json.empty?)
16
+ @_loaded = !json.empty?
17
17
  end
18
18
 
19
19
  def attributes=(hash)
@@ -36,7 +36,7 @@ module Tinybucket
36
36
 
37
37
  protected
38
38
 
39
- def create_api(api_key, keys, options)
39
+ def create_api(api_key, keys, options)
40
40
  key = ('@' + api_key.underscore).intern
41
41
  api = instance_variable_get(key)
42
42
  return api if api.present?
@@ -6,11 +6,11 @@ module Tinybucket
6
6
  acceptable_attributes :groups, :id, :kind, :links, :pattern, :users, :uuid
7
7
 
8
8
  def update(_params)
9
- fail NotImplementedError
9
+ raise NotImplementedError
10
10
  end
11
11
 
12
12
  def destroy
13
- fail NotImplementedError
13
+ raise NotImplementedError
14
14
  end
15
15
  end
16
16
  end
@@ -5,7 +5,7 @@ module Tinybucket
5
5
  include Tinybucket::Model::Concerns::Reloadable
6
6
 
7
7
  acceptable_attributes \
8
- :links, :id, :parent, :filename, :content, :user, :inline, \
8
+ :links, :id, :parent, :filename, :content, :user, :inline, \
9
9
  :created_on, :updated_on, :uuid
10
10
 
11
11
  attr_accessor :commented_to
@@ -28,7 +28,7 @@ module Tinybucket
28
28
  when Tinybucket::Model::PullRequest
29
29
  pull_request_api({})
30
30
  else
31
- fail ArgumentError, 'commented_to was invalid'
31
+ raise ArgumentError, 'commented_to was invalid'
32
32
  end
33
33
 
34
34
  api.commented_to = commented_ato
@@ -3,6 +3,7 @@ module Tinybucket
3
3
  class Commit < Base
4
4
  include Tinybucket::Model::Concerns::RepositoryKeys
5
5
  include Tinybucket::Model::Concerns::Reloadable
6
+ include Tinybucket::Constants
6
7
 
7
8
  acceptable_attributes \
8
9
  :hash, :links, :repository, :author, :parents, :date,
@@ -19,8 +20,7 @@ module Tinybucket
19
20
  private
20
21
 
21
22
  def comments_api(options)
22
- fail ArgumentError,
23
- 'This method call require repository keys.' unless repo_keys?
23
+ raise ArgumentError, MISSING_REPOSITORY_KEY unless repo_keys?
24
24
 
25
25
  api = create_api('Comments', repo_keys, options)
26
26
  api.commented_to = self
@@ -20,14 +20,10 @@ module Tinybucket
20
20
  @_loaded
21
21
  end
22
22
 
23
- # rubocop: disable Style/TrivialAccessors
24
-
25
23
  def loaded?
26
24
  @_loaded
27
25
  end
28
26
 
29
- # rubocop: enabled Style/TrivialAccessors
30
-
31
27
  def reload
32
28
  @_loaded = false
33
29
  load
@@ -36,7 +32,7 @@ module Tinybucket
36
32
  private
37
33
 
38
34
  def load_model
39
- fail NotImplementedError
35
+ raise NotImplementedError
40
36
  end
41
37
  end
42
38
  end
@@ -26,12 +26,12 @@ module Tinybucket
26
26
  case result
27
27
  when Tinybucket::Model::Page
28
28
  result.items.map do |m|
29
- next unless (m.class).concern_included?(:RepositoryKeys)
29
+ next unless m.class.concern_included?(:RepositoryKeys)
30
30
  m.repo_keys = repo_keys
31
31
  end
32
32
  when Tinybucket::Model::Base
33
33
  result.repo_keys = repo_keys \
34
- if (result.class).concern_included?(:RepositoryKeys)
34
+ if result.class.concern_included?(:RepositoryKeys)
35
35
  end
36
36
 
37
37
  result
@@ -31,7 +31,7 @@ module Tinybucket
31
31
  pos = start + i
32
32
  yield(m, pos)
33
33
 
34
- fail StopIteration if \
34
+ raise StopIteration if \
35
35
  (!options[:limit].nil? && pos == (options[:limit] - 1))
36
36
  end
37
37
 
@@ -51,13 +51,13 @@ module Tinybucket
51
51
  end
52
52
 
53
53
  def load_next
54
- fail StopIteration if @attrs[:next].nil? || @next_proc.nil?
54
+ raise StopIteration if @attrs[:next].nil? || @next_proc.nil?
55
55
 
56
56
  unescaped_query = URI.unescape(URI.parse(@attrs[:next]).query)
57
57
  query = Hash[*unescaped_query.split(/&|=/)]
58
58
  list = @next_proc.call(query)
59
59
 
60
- fail StopIteration if list.items.size == 0
60
+ raise StopIteration if list.items.empty?
61
61
 
62
62
  @attrs = list.attrs
63
63
  @items = list.items
@@ -3,6 +3,7 @@ module Tinybucket
3
3
  class PullRequest < Base
4
4
  include Tinybucket::Model::Concerns::RepositoryKeys
5
5
  include Tinybucket::Model::Concerns::Reloadable
6
+ include Tinybucket::Constants
6
7
 
7
8
  acceptable_attributes \
8
9
  :state, :description, :links, :title, :close_source_branch,
@@ -10,11 +11,11 @@ module Tinybucket
10
11
  :merge_commit, :closed_by, :reviewers, :participants, :uuid
11
12
 
12
13
  def create(_params)
13
- fail NotImplementedError
14
+ raise NotImplementedError
14
15
  end
15
16
 
16
17
  def update(_params)
17
- fail NotImplementedError
18
+ raise NotImplementedError
18
19
  end
19
20
 
20
21
  def decline(options = {})
@@ -58,8 +59,7 @@ module Tinybucket
58
59
  end
59
60
 
60
61
  def pull_request_api(options)
61
- fail ArgumentError,
62
- 'This method call require repository keys.' unless repo_keys?
62
+ raise ArgumentError, MISSING_REPOSITORY_KEY unless repo_keys?
63
63
 
64
64
  create_api('PullRequests', repo_keys, options)
65
65
  end
@@ -10,11 +10,11 @@ module Tinybucket
10
10
  :has_issues, :is_private, :full_name, :name, :language
11
11
 
12
12
  def create(_params)
13
- fail NotImplementedError
13
+ raise NotImplementedError
14
14
  end
15
15
 
16
16
  def destroy
17
- fail NotImplementedError
17
+ raise NotImplementedError
18
18
  end
19
19
 
20
20
  def pull_requests(options = {})
@@ -37,7 +37,7 @@ module Tinybucket
37
37
  request.path = path
38
38
  request.body = extract_data_from_params(params) unless params.empty?
39
39
  else
40
- fail ArgumentError, 'unknown http method: ' + method
40
+ raise ArgumentError, 'unknown http method: ' + method
41
41
  end
42
42
  end
43
43
 
@@ -7,7 +7,7 @@ module Tinybucket
7
7
  return if status_code < 400
8
8
 
9
9
  Tinybucket.logger.error "Invalid response code:#{status_code}"
10
- fail Tinybucket::Error::ServiceError.new(env)
10
+ raise Tinybucket::Error::ServiceError.new(env)
11
11
  end
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Tinybucket
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'.freeze
3
3
  end
data/tinybucket.gemspec CHANGED
@@ -18,19 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'activesupport', ['= 4.1.6']
21
+ spec.add_runtime_dependency 'activemodel', ['>= 4.1.6']
22
+ spec.add_runtime_dependency 'activesupport', ['>= 4.1.6']
22
23
  spec.add_runtime_dependency 'faraday', ['= 0.9.0']
23
24
  spec.add_runtime_dependency 'faraday_middleware', ['= 0.9.1']
24
25
  spec.add_runtime_dependency 'simple_oauth', ['= 0.2.0']
25
- spec.add_runtime_dependency 'activemodel', ['= 4.1.6']
26
26
 
27
- spec.add_development_dependency 'bundler', ['~> 1.6', '>= 1.6.2']
28
- spec.add_development_dependency 'rake', ['= 10.3.2']
29
- spec.add_development_dependency 'rspec', ['= 3.1.0']
30
- spec.add_development_dependency 'rspec-mocks', ['= 3.1.0']
31
- spec.add_development_dependency 'webmock', ['= 1.18.0']
32
- spec.add_development_dependency 'rubocop', ['= 0.26.0']
33
- spec.add_development_dependency 'simplecov', ['= 0.9.0']
34
- spec.add_development_dependency 'yard', ['= 0.8.7.4']
35
- spec.add_development_dependency 'yardstick', ['= 0.9.9']
27
+ spec.add_development_dependency 'bundler', '~> 1.10'
36
28
  end
metadata CHANGED
@@ -1,27 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinybucket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - hirakiuc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-24 00:00:00.000000000 Z
11
+ date: 2016-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.6
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - '='
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: 4.1.6
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - '='
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: 4.1.6
27
41
  - !ruby/object:Gem::Dependency
@@ -66,152 +80,20 @@ dependencies:
66
80
  - - '='
67
81
  - !ruby/object:Gem::Version
68
82
  version: 0.2.0
69
- - !ruby/object:Gem::Dependency
70
- name: activemodel
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 4.1.6
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 4.1.6
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 1.6.2
89
+ version: '1.10'
93
90
  type: :development
94
91
  prerelease: false
95
92
  version_requirements: !ruby/object:Gem::Requirement
96
93
  requirements:
97
94
  - - "~>"
98
95
  - !ruby/object:Gem::Version
99
- version: '1.6'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 1.6.2
103
- - !ruby/object:Gem::Dependency
104
- name: rake
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - '='
108
- - !ruby/object:Gem::Version
109
- version: 10.3.2
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - '='
115
- - !ruby/object:Gem::Version
116
- version: 10.3.2
117
- - !ruby/object:Gem::Dependency
118
- name: rspec
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - '='
122
- - !ruby/object:Gem::Version
123
- version: 3.1.0
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - '='
129
- - !ruby/object:Gem::Version
130
- version: 3.1.0
131
- - !ruby/object:Gem::Dependency
132
- name: rspec-mocks
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - '='
136
- - !ruby/object:Gem::Version
137
- version: 3.1.0
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - '='
143
- - !ruby/object:Gem::Version
144
- version: 3.1.0
145
- - !ruby/object:Gem::Dependency
146
- name: webmock
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - '='
150
- - !ruby/object:Gem::Version
151
- version: 1.18.0
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - '='
157
- - !ruby/object:Gem::Version
158
- version: 1.18.0
159
- - !ruby/object:Gem::Dependency
160
- name: rubocop
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - '='
164
- - !ruby/object:Gem::Version
165
- version: 0.26.0
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - '='
171
- - !ruby/object:Gem::Version
172
- version: 0.26.0
173
- - !ruby/object:Gem::Dependency
174
- name: simplecov
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - '='
178
- - !ruby/object:Gem::Version
179
- version: 0.9.0
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - '='
185
- - !ruby/object:Gem::Version
186
- version: 0.9.0
187
- - !ruby/object:Gem::Dependency
188
- name: yard
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - '='
192
- - !ruby/object:Gem::Version
193
- version: 0.8.7.4
194
- type: :development
195
- prerelease: false
196
- version_requirements: !ruby/object:Gem::Requirement
197
- requirements:
198
- - - '='
199
- - !ruby/object:Gem::Version
200
- version: 0.8.7.4
201
- - !ruby/object:Gem::Dependency
202
- name: yardstick
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - '='
206
- - !ruby/object:Gem::Version
207
- version: 0.9.9
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - '='
213
- - !ruby/object:Gem::Version
214
- version: 0.9.9
96
+ version: '1.10'
215
97
  description: ruby wrapper for the Bitbucket REST API (v2) with oauth inspired by vongrippen/bitbucket.
216
98
  email:
217
99
  - hirakiuc@gmail.com
@@ -385,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
267
  version: '0'
386
268
  requirements: []
387
269
  rubyforge_project:
388
- rubygems_version: 2.4.5.1
270
+ rubygems_version: 2.5.1
389
271
  signing_key:
390
272
  specification_version: 4
391
273
  summary: ruby wrapper for the Bitbucket REST API (v2) with oauth