global 0.1.1 → 0.1.2

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: 74e88d1ceec15ae147dc103ce73fada9416df172
4
- data.tar.gz: c81815b76116e5d9b52fa5760f4d12a5a4b64203
3
+ metadata.gz: d261b1f7e73030d8006467431156cfc1a39c4788
4
+ data.tar.gz: 0012a6c457ad0c674bdfa3c126447db4361a56bd
5
5
  SHA512:
6
- metadata.gz: 296fc33e969364671f75a72da7522ead05a45979bf4d9da79e89cc85379adc26f8a4d023f2e3b7819fffc516b5b7c571c1b041f8d0dec0c81e262b289411f532
7
- data.tar.gz: 4ae571ebc0c2be750cd5b115a2348dd554f116649cc2b8ef039fd55f17ba99634f14183d83ffe4ff7783ac3a855ee9c1323254e91bf165fe55125d600c1eed0d
6
+ metadata.gz: 0e2dec1011fb245458c2a92fa9dcdebcfd0662a0d1295285329c6fcfb21ca2e9f5c52e73d865d3789f76b7b0791f5015e3e0da8ab24c04dcda31001889af9769
7
+ data.tar.gz: 0c96806548f0a4585cf07c75cd89a6f5ba52b871cfe3998d6971d831080f979f410fc828c7638d2673b70c7d02e5e34af2c3d225cb66d725578adc101c6e82d0
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.0
@@ -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.0
5
- - 2.1.2
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
@@ -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.to_s[0..-2] if method.to_s[-1] == '?'
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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Global
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -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
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Global, "generate js in Rails" do
3
+ RSpec.describe Global, "generate js in Rails" do
4
4
  before do
5
5
  evaljs("var window = this;", true)
6
6
  jscontext[:log] = lambda {|context, value| puts value.inspect}
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Global do
3
+ RSpec.describe Global do
4
4
 
5
5
  before(:each) do
6
6
  described_class.configure do |config|
@@ -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.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: 2014-07-09 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec