global 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +12 -2
- data/lib/global/configuration.rb +16 -1
- data/lib/global/version.rb +1 -1
- data/spec/global/configuration_spec.rb +22 -1
- data/spec/global/global_js_spec.rb +1 -1
- data/spec/global_spec.rb +1 -1
- data/spec/spec_helper.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d261b1f7e73030d8006467431156cfc1a39c4788
|
4
|
+
data.tar.gz: 0012a6c457ad0c674bdfa3c126447db4361a56bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e2dec1011fb245458c2a92fa9dcdebcfd0662a0d1295285329c6fcfb21ca2e9f5c52e73d865d3789f76b7b0791f5015e3e0da8ab24c04dcda31001889af9769
|
7
|
+
data.tar.gz: 0c96806548f0a4585cf07c75cd89a6f5ba52b871cfe3998d6971d831080f979f410fc828c7638d2673b70c7d02e5e34af2c3d225cb66d725578adc101c6e82d0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/.travis.yml
CHANGED
@@ -1,17 +1,27 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
3
|
+
cache:
|
4
|
+
bundler: true
|
5
|
+
|
2
6
|
rvm:
|
3
7
|
- 1.9.3
|
4
|
-
- 2.0
|
5
|
-
- 2.1
|
8
|
+
- 2.0
|
9
|
+
- 2.1
|
10
|
+
- 2.2
|
6
11
|
- jruby-19mode
|
7
12
|
- ruby-head
|
8
13
|
- jruby-head
|
14
|
+
|
9
15
|
notifications:
|
10
16
|
email: false
|
17
|
+
|
18
|
+
sudo: false
|
19
|
+
|
11
20
|
branches:
|
12
21
|
only:
|
13
22
|
- master
|
14
23
|
- development
|
24
|
+
|
15
25
|
matrix:
|
16
26
|
allow_failures:
|
17
27
|
- rvm: ruby-head
|
data/lib/global/configuration.rb
CHANGED
@@ -20,6 +20,15 @@ module Global
|
|
20
20
|
hash.select{|key, _| keys.include?(key)}
|
21
21
|
end
|
22
22
|
|
23
|
+
def respond_to?(symbol, include_all=false)
|
24
|
+
method = normalize_key_by_method(symbol)
|
25
|
+
if key?(method)
|
26
|
+
true
|
27
|
+
else
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
23
32
|
private
|
24
33
|
|
25
34
|
def filtered_keys_list(options)
|
@@ -39,7 +48,7 @@ module Global
|
|
39
48
|
protected
|
40
49
|
|
41
50
|
def method_missing(method, *args, &block)
|
42
|
-
method = method
|
51
|
+
method = normalize_key_by_method(method)
|
43
52
|
if key?(method)
|
44
53
|
value = hash[method]
|
45
54
|
value.kind_of?(Hash) ? Global::Configuration.new(value) : value
|
@@ -47,5 +56,11 @@ module Global
|
|
47
56
|
super
|
48
57
|
end
|
49
58
|
end
|
59
|
+
|
60
|
+
def normalize_key_by_method(method)
|
61
|
+
'?' == method.to_s[-1] ? method.to_s[0..-2] : method
|
62
|
+
end
|
63
|
+
|
64
|
+
|
50
65
|
end
|
51
66
|
end
|
data/lib/global/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Global::Configuration do
|
3
|
+
RSpec.describe Global::Configuration do
|
4
4
|
let(:hash){ { "key" => "value", "nested" => { "key" => "value" } } }
|
5
5
|
let(:configuration){ described_class.new hash }
|
6
6
|
|
@@ -95,4 +95,25 @@ describe Global::Configuration do
|
|
95
95
|
it{ is_expected.to eq("value") }
|
96
96
|
end
|
97
97
|
end
|
98
|
+
|
99
|
+
describe "#respond_to?" do
|
100
|
+
context "when key exist" do
|
101
|
+
subject{ configuration.respond_to?(:key) }
|
102
|
+
|
103
|
+
it{ is_expected.to eq(true) }
|
104
|
+
end
|
105
|
+
|
106
|
+
context "when key does not exist" do
|
107
|
+
subject{ configuration.respond_to?(:some_key) }
|
108
|
+
|
109
|
+
it{ is_expected.to eq(false) }
|
110
|
+
end
|
111
|
+
|
112
|
+
context "with nested hash" do
|
113
|
+
subject{ configuration.nested.respond_to?(:key) }
|
114
|
+
|
115
|
+
it{ is_expected.to eq(true) }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
98
119
|
end
|
data/spec/global_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,26 @@ SimpleCov.start do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
RSpec.configure do |config|
|
17
|
+
config.disable_monkey_patching!
|
18
|
+
|
19
|
+
config.expect_with :rspec do |expectations|
|
20
|
+
expectations.syntax = :expect
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
config.mock_with :rspec do |mocks|
|
32
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
33
|
+
# a real object. This is generally recommended, and will default to
|
34
|
+
# `true` in RSpec 4.
|
35
|
+
mocks.verify_partial_doubles = true
|
36
|
+
end
|
17
37
|
|
18
38
|
config.run_all_when_everything_filtered = true
|
19
39
|
config.filter_run :focus
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Railsware LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|