params_tree 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e7f87359606f69ad3c55ca37f086197e97bf1e9
4
- data.tar.gz: c570dedad54afe614d4ab327391ce665439b03ef
3
+ metadata.gz: 9d1fb07e6cc744cf96803ce1ba363ac3c4485164
4
+ data.tar.gz: d6119e76ad4517a75e8277ac2b106b82f341d4fa
5
5
  SHA512:
6
- metadata.gz: e56d7e420a7d91e23a26373ce3e933c2be1a59b5c34e1648726f367c19345d6515f4c5db9f012c20d4b055309cbc6b7b747e83fc749832ecb2a0d5e16d27992a
7
- data.tar.gz: 4c65764a9c33bad10190168190d6141be233cdd89994c0d37cbdb2f6de7f88648d05ca8b6234fb3cbc9107b4261d84b0e12f1e41db7edc5bc31edc0a46db7ea4
6
+ metadata.gz: 2d278166a7dd8e93d00d56c0b149503815af91fa537cbbfa047596ea5ea723b2895ca1f8edb4c374220a7f375c47fc66101f7ff282fd12ba44e37695a6f58ef5
7
+ data.tar.gz: 18df965abec73d71fc1c7e4a85ab218c5aef1be1a76f10a998b279300656f3e469082a93cef7bb9087cc90dc447a9269f7e43d79297ce002a3fa752cfc5bbd73
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -62,6 +62,8 @@ Or install it yourself as:
62
62
 
63
63
  ## Contributing
64
64
 
65
+ Use `rake generate` to get a `.rb` parser, but avoid committing it.
66
+
65
67
  1. Fork it ( https://github.com/razum2um/params_tree/fork )
66
68
  2. Create your feature branch (`git checkout -b my-new-feature`)
67
69
  3. Commit your changes (`git commit -am 'Add some feature'`)
@@ -2,5 +2,5 @@ require "params_tree/version"
2
2
  require "params_tree/parser"
3
3
 
4
4
  module ParamsTree
5
- # Your code goes here...
5
+ DEFAULT = 'default'.freeze
6
6
  end
@@ -324,11 +324,16 @@ when 11 then
324
324
  end
325
325
 
326
326
  def inject_key
327
- @hash[key] = {}
327
+ if @hash.key?(key)
328
+ @hash[key][ParamsTree::DEFAULT] = {}
329
+ else
330
+ @hash[key] = {}
331
+ end
328
332
  end
329
333
 
330
334
  def push
331
- @hash_stack.push @hash; @hash = @hash[key]
335
+ @hash_stack.push(@hash)
336
+ @hash = @hash[key]
332
337
  end
333
338
 
334
339
  def pop
@@ -69,11 +69,16 @@ module ParamsTree
69
69
  end
70
70
 
71
71
  def inject_key
72
- @hash[key] = {}
72
+ if @hash.key?(key)
73
+ @hash[key][ParamsTree::DEFAULT] = {}
74
+ else
75
+ @hash[key] = {}
76
+ end
73
77
  end
74
78
 
75
79
  def push
76
- @hash_stack.push @hash; @hash = @hash[key]
80
+ @hash_stack.push(@hash)
81
+ @hash = @hash[key]
77
82
  end
78
83
 
79
84
  def pop
@@ -1,3 +1,3 @@
1
1
  module ParamsTree
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -31,6 +31,12 @@ class ParserTest < Minitest::Test
31
31
  assert_equal _("default(user(id)), some"), { "default" => { 'user' => { 'id' => {} }, "some" => {} } }
32
32
  end
33
33
 
34
+ def test_mentioning_is_default
35
+ expected = { "options" => { "default" => {}, "redemptionLocations" => { "ordering" => {} } } }
36
+ assert_equal expected, _("options, options(redemptionLocations(ordering))"), expected
37
+ assert_equal expected, _("options(default, redemptionLocations(ordering))")
38
+ end
39
+
34
40
  def test_complicated
35
41
  assert_equal _("default(id,user(group(division(name)),name)),post(id,title),comment(id,author,text(title,body))"), {
36
42
  "default" => {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: params_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Bokov
@@ -30,7 +30,7 @@ cert_chain:
30
30
  vzKbYclpJ7gENr/xiTjGqA/Md3zJMzmsFrzUXt4RVmo5SaCyZjC6gFfhSr+PODc7
31
31
  ZaSbckvH/+m4boAsg0JkGGFcS3j5fgNmdwgA1A==
32
32
  -----END CERTIFICATE-----
33
- date: 2014-05-22 00:00:00.000000000 Z
33
+ date: 2014-07-29 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: bundler
metadata.gz.sig CHANGED
Binary file