jumunge 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: 6d1087b396ae11b150de7e45101c7f3f10256090
4
- data.tar.gz: '0804afa2e6472820175a8a9556f851d36782737c'
2
+ SHA256:
3
+ metadata.gz: 37e08bf99fc91e7a0b1b317b6f2c668cadb5d24ac6184cfca2c680a2dc1d73d7
4
+ data.tar.gz: 70336a84087344df1822ffb25d4c30b11ed0f7565b84890b8a0db556409d58fd
5
5
  SHA512:
6
- metadata.gz: 326b8d5f7fe7990ef3161264afa98a9f321e214b6a43fa7dbfc5bce4069b29c6c28268489a5323f211ff0e5f3e39addcdc8a4e0e6681e60670df940637f8521e
7
- data.tar.gz: 3735177850e86f78ede9c06a38eb754715a01cc9b9387af70505a839180d84c5296546c7fc6980bac6b98b58494df6ed1e50c0c3f7f07ecc52d457cb8318b07b
6
+ metadata.gz: bc7d79fcd0ff309ee7b1dc39ff94acf78d7c26059bd1f18247efc43bfd1c76bb9ebbf97d0ea8933766d09125e0c2dafbca03f47f4e0c034b093221fd768f6c17
7
+ data.tar.gz: 0ed59ce3815b2a2e442c1b0c2e15343ffd6023b1f323e0f0b8c3756989dd76d4cf4496bb407dde757026db3b22414c4d9eb7d65cab233a4dfe8afc4d0a502ec2
data/.travis.yml CHANGED
@@ -1,12 +1,17 @@
1
- sudo: false
2
1
  language: ruby
2
+ sudo: false
3
+ cache:
4
+ bundler: true
3
5
  rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.15.4
6
+ - 2.4
7
+ - 2.5
8
+ before_install:
9
+ - gem install bundler
6
10
  deploy:
7
11
  provider: rubygems
8
12
  api_key:
9
13
  secure: YgPD3zs9Am0R1w7xOYlLrI7ls8v1nuOQpC+R+4GyULeDYMIJg9kHe59n3CuiUmaVs3bQZTlW921sluY6+GPQrZdOf5fF0wGluF7X71DtZYEabic611QI1y4hgrFrHX7JFerqjoDATUMIkN+MAk3m+Ok7czs9PSL89CltNznJcV3PXVFyPHrWZE9+XY8Bl2hh8N3PHdcVKDiT1JK1d3qLoiklW32bOvD0Vt5VPnThps+hDRY+Gm4sfNDextd1LqptXdAGrrd1y+agQD+9GDf6m9Ypo2LofpY0J29nZ93eV04bP5zC2gVWCwwmPANLX7LcUboDt309j5ytbwQT9zAd4ms/mIH+8Jf6taOvugmGDJOzCBSXyDl4sj9gLAeHkrYFv5l/cka0bvBAHiyBNOEJAUyrmc7ZKGAIYJiwCZQ4cExyiQE3ywPMC7z2FhR5OOMpJyXawbgdMkLma1fIWnBUdPBudKYt0yni5+BVlWyDymoduWQxYllkVrLyAfdOLzjUGWF6oXZMTsqQTJ2s34pitrMeXa5Q4RUIN/2A1Yav0pQQ3yP0vODMzLxi3rCj9NM7XX2KC3H+EEfc9zLPOIMSnlnnu7SlX9+65HJQMgFAm/u3zRHSF3FdBX2ZtwmEZbjwhqhdkKWlW4SA70TLoYDyeNqshRlgoJ663jox38iL92Y=
14
+ gem: jumunge
10
15
  on:
11
16
  tags: true
12
17
  repo: miyucy/jumunge
data/jumunge.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.15"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
26
  end
data/lib/jumunge.rb CHANGED
@@ -100,12 +100,44 @@ module Jumunge
100
100
  end
101
101
  end
102
102
 
103
+ class JuOpt
104
+ def initialize(object, trail, trails)
105
+ @object = object
106
+ @trail = trail
107
+ @trails = trails
108
+ end
109
+
110
+ def perform
111
+ if @object.key? key_name
112
+ @object[key_name] = deep_applied_value
113
+ @object
114
+ else
115
+ @object
116
+ end
117
+ end
118
+
119
+ private
120
+
121
+ def key_name
122
+ @key_name ||= @trail[0..-2]
123
+ end
124
+
125
+ def deep_applied_value
126
+ Jumunge.new(@object[key_name], remaining_trails).perform
127
+ end
128
+
129
+ def remaining_trails
130
+ @remaining_trails ||= @trails.join('.')
131
+ end
132
+ end
133
+
103
134
  class Jumunge
104
135
  def initialize(object, path)
105
136
  @object = object
106
137
  @trail, *@trails = path.split '.'
107
138
  @is_array = @trail[-2..-1] == '[]'
108
139
  @is_value = @trail[-1] == '!'
140
+ @is_opt = @trail[-1] == '?'
109
141
  @performer = performer_class.new @object, @trail, @trails
110
142
  end
111
143
 
@@ -121,6 +153,8 @@ module Jumunge
121
153
  JuArray
122
154
  elsif @is_value
123
155
  JuValue
156
+ elsif @is_opt
157
+ JuOpt
124
158
  else
125
159
  JuOther
126
160
  end
@@ -129,7 +163,7 @@ module Jumunge
129
163
  end
130
164
  end
131
165
  end
132
- private_constant :Jumunge, :JuArray, :JuValue, :JuOther, :JuThru
166
+ private_constant :Jumunge, :JuArray, :JuValue, :JuOther, :JuThru, :JuOpt
133
167
 
134
168
  def jumunge(object, *paths)
135
169
  paths.inject(object) do |result, path|
@@ -1,3 +1,3 @@
1
1
  module Jumunge
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jumunge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miyucy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.15'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '0'
55
55
  description: Write a longer description or delete this line.
56
56
  email:
57
57
  - fistfvck@gmail.com
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.6.13
94
+ rubygems_version: 2.7.7
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Write a short summary, because Rubygems requires one.