tinybucket 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/tinybucket/config.rb +6 -0
- data/lib/tinybucket/model/base.rb +7 -3
- data/lib/tinybucket/null_logger.rb +35 -0
- data/lib/tinybucket/version.rb +1 -1
- data/lib/tinybucket.rb +11 -5
- data/spec/lib/tinybucket/null_logger_spec.rb +53 -0
- data/spec/lib/tinybucket_spec.rb +24 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df8de5bb4a23d41681373aca721509d6ed520902
|
4
|
+
data.tar.gz: a0e0d3fc7485d3f065ae93aef7b92d7b32f31b8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5456f3c17cbe2ee7fde00fc7609059da637326575cebe64ec717ea8dde55130205d6a3c1a73e5bd8a7d9f7f830f79c4a4362f934b5901ca5362e00335cdeb33b
|
7
|
+
data.tar.gz: fc4c4969316d1294247c251d02a8e06219095f3701a77f46b5013a028515160ea80806025565fc39317a0b0e251485de781edaf7a154ec28eda880617212b080
|
data/README.md
CHANGED
@@ -34,6 +34,23 @@ Or install it yourself as:
|
|
34
34
|
|
35
35
|
NOTE: `x` mark means `Already implemented.`.
|
36
36
|
|
37
|
+
### Configure
|
38
|
+
|
39
|
+
#### Configure logger
|
40
|
+
|
41
|
+
This gem use built-in null_logger in default.
|
42
|
+
|
43
|
+
If you want to set your logger, configure like this.
|
44
|
+
|
45
|
+
```
|
46
|
+
logger = Logger.new($stdout)
|
47
|
+
logger.level = Logger::WARN
|
48
|
+
|
49
|
+
Tinybucket.configure do |config|
|
50
|
+
config.logger = logger
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
37
54
|
### init
|
38
55
|
|
39
56
|
```
|
@@ -17,9 +17,9 @@ module Tinybucket
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def attributes=(hash)
|
20
|
-
hash.
|
20
|
+
hash.each_pair do |key, value|
|
21
21
|
if acceptable_attribute?(key)
|
22
|
-
send("#{key}=", value)
|
22
|
+
send("#{key}=".intern, value)
|
23
23
|
else
|
24
24
|
# rubocop:disable Metrics/LineLength
|
25
25
|
logger.warn("Ignored '#{key}' attribute (value: #{value}). [#{self.class}]")
|
@@ -28,7 +28,11 @@ module Tinybucket
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
def attributes
|
32
|
+
acceptable_attributes.map do |key|
|
33
|
+
{ key => send(key.intern) }
|
34
|
+
end.reduce(&:merge)
|
35
|
+
end
|
32
36
|
|
33
37
|
protected
|
34
38
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
class NullLogger
|
3
|
+
attr_accessor :level
|
4
|
+
|
5
|
+
def fatal(_progname = nil, &_block); end
|
6
|
+
|
7
|
+
def fatal?
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
def error(_progname = nil, &_block); end
|
12
|
+
|
13
|
+
def error?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def warn(_progname = nil, &_block); end
|
18
|
+
|
19
|
+
def warn?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def info(_progname = nil, &_block); end
|
24
|
+
|
25
|
+
def info?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def debug(_progname = nil, &_block); end
|
30
|
+
|
31
|
+
def debug?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/tinybucket/version.rb
CHANGED
data/lib/tinybucket.rb
CHANGED
@@ -15,6 +15,8 @@ require 'active_model'
|
|
15
15
|
|
16
16
|
require 'logger'
|
17
17
|
|
18
|
+
require 'tinybucket/config'
|
19
|
+
require 'tinybucket/null_logger'
|
18
20
|
require 'tinybucket/api'
|
19
21
|
require 'tinybucket/api_factory'
|
20
22
|
require 'tinybucket/api/helper'
|
@@ -52,12 +54,16 @@ module Tinybucket
|
|
52
54
|
@api_client = Tinybucket::Client.new(options, &block)
|
53
55
|
end
|
54
56
|
|
57
|
+
def configure
|
58
|
+
yield(config)
|
59
|
+
end
|
60
|
+
|
61
|
+
def config
|
62
|
+
@config ||= Tinybucket::Config.new
|
63
|
+
end
|
64
|
+
|
55
65
|
def logger
|
56
|
-
|
57
|
-
logger = Logger.new($stdout)
|
58
|
-
logger.level = Logger::DEBUG
|
59
|
-
logger
|
60
|
-
end
|
66
|
+
config.logger || Tinybucket::NullLogger.new
|
61
67
|
end
|
62
68
|
end
|
63
69
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::NullLogger do
|
4
|
+
subject { Tinybucket::NullLogger.new }
|
5
|
+
|
6
|
+
describe '#level' do
|
7
|
+
it { expect(subject).to respond_to(:level) }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#level=' do
|
11
|
+
it { expect(subject).to respond_to(:level=) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#fatal' do
|
15
|
+
it { expect(subject).to respond_to(:fatal) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#fatal?' do
|
19
|
+
it { expect(subject.fatal?).to be_falsey }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#error' do
|
23
|
+
it { expect(subject).to respond_to(:error) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#error?' do
|
27
|
+
it { expect(subject.error?).to be_falsey }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#warn' do
|
31
|
+
it { expect(subject).to respond_to(:warn) }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#warn?' do
|
35
|
+
it { expect(subject.warn?).to be_falsey }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#info' do
|
39
|
+
it { expect(subject).to respond_to(:info) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#info?' do
|
43
|
+
it { expect(subject.info?).to be_falsey }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#debug' do
|
47
|
+
it { expect(subject).to respond_to(:debug) }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#debug?' do
|
51
|
+
it { expect(subject.debug?).to be_falsey }
|
52
|
+
end
|
53
|
+
end
|
data/spec/lib/tinybucket_spec.rb
CHANGED
@@ -29,4 +29,28 @@ RSpec.describe Tinybucket do
|
|
29
29
|
it_behaves_like 'return client which configured with options'
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
describe 'config' do
|
34
|
+
subject { Tinybucket.config }
|
35
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Config) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'configure' do
|
39
|
+
subject(:config) { Tinybucket.config }
|
40
|
+
let(:logger) { Logger.new($stdout) }
|
41
|
+
|
42
|
+
it 'can configurable logger' do
|
43
|
+
expect(config.logger).to be_nil
|
44
|
+
|
45
|
+
expect do
|
46
|
+
Tinybucket.configure do |config|
|
47
|
+
config.logger = logger
|
48
|
+
end
|
49
|
+
end.not_to raise_error
|
50
|
+
|
51
|
+
expect(config.logger).to eq(logger)
|
52
|
+
end
|
53
|
+
|
54
|
+
after { Tinybucket.configure { |config| config.logger = nil } }
|
55
|
+
end
|
32
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinybucket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirakiuc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- lib/tinybucket/api/user_api.rb
|
256
256
|
- lib/tinybucket/api_factory.rb
|
257
257
|
- lib/tinybucket/client.rb
|
258
|
+
- lib/tinybucket/config.rb
|
258
259
|
- lib/tinybucket/connection.rb
|
259
260
|
- lib/tinybucket/constants.rb
|
260
261
|
- lib/tinybucket/error.rb
|
@@ -275,6 +276,7 @@ files:
|
|
275
276
|
- lib/tinybucket/model/pull_request.rb
|
276
277
|
- lib/tinybucket/model/repository.rb
|
277
278
|
- lib/tinybucket/model/team.rb
|
279
|
+
- lib/tinybucket/null_logger.rb
|
278
280
|
- lib/tinybucket/parser.rb
|
279
281
|
- lib/tinybucket/parser/base_parser.rb
|
280
282
|
- lib/tinybucket/parser/branch_restriction_parser.rb
|
@@ -355,6 +357,7 @@ files:
|
|
355
357
|
- spec/lib/tinybucket/model/pull_request_spec.rb
|
356
358
|
- spec/lib/tinybucket/model/repository_spec.rb
|
357
359
|
- spec/lib/tinybucket/model/team_spec.rb
|
360
|
+
- spec/lib/tinybucket/null_logger_spec.rb
|
358
361
|
- spec/lib/tinybucket_spec.rb
|
359
362
|
- spec/spec_helper.rb
|
360
363
|
- spec/support/api_response_macros.rb
|
@@ -381,7 +384,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
381
384
|
version: '0'
|
382
385
|
requirements: []
|
383
386
|
rubyforge_project:
|
384
|
-
rubygems_version: 2.
|
387
|
+
rubygems_version: 2.2.2
|
385
388
|
signing_key:
|
386
389
|
specification_version: 4
|
387
390
|
summary: ruby wrapper for the Bitbucket REST API (v2) with oauth
|
@@ -446,6 +449,7 @@ test_files:
|
|
446
449
|
- spec/lib/tinybucket/model/pull_request_spec.rb
|
447
450
|
- spec/lib/tinybucket/model/repository_spec.rb
|
448
451
|
- spec/lib/tinybucket/model/team_spec.rb
|
452
|
+
- spec/lib/tinybucket/null_logger_spec.rb
|
449
453
|
- spec/lib/tinybucket_spec.rb
|
450
454
|
- spec/spec_helper.rb
|
451
455
|
- spec/support/api_response_macros.rb
|