rego-ruby-ext 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.document +0 -0
- data/.rspec +0 -0
- data/Gemfile +14 -14
- data/LICENSE.txt +20 -20
- data/README.md +0 -0
- data/Rakefile +49 -49
- data/VERSION +1 -1
- data/init.rb +2 -2
- data/lib/boolean-ext.rb +11 -11
- data/lib/date-ext.rb +4 -4
- data/lib/enumerable-ext.rb +31 -31
- data/lib/nil-ext.rb +15 -15
- data/lib/numeric-ext.rb +5 -5
- data/lib/rego-ruby-ext.rb +4 -4
- data/lib/string-ext.rb +37 -37
- data/lib/string-interpolation.rb +50 -50
- data/lib/symbol-ext.rb +3 -3
- data/lib/time-ext.rb +7 -7
- data/rego-ruby-ext.gemspec +82 -83
- data/spec/boolean_spec.rb +18 -18
- data/spec/date_spec.rb +7 -7
- data/spec/enumerable_spec.rb +51 -51
- data/spec/nil_spec.rb +17 -17
- data/spec/numeric_spec.rb +7 -7
- data/spec/rego-ruby-ext_spec.rb +5 -5
- data/spec/spec_helper.rb +13 -13
- data/spec/string_interpolation_spec.rb +31 -31
- data/spec/string_spec.rb +39 -39
- data/spec/symbol_spec.rb +8 -8
- data/spec/time_spec.rb +7 -7
- metadata +84 -111
- data/lib/hash-ext.rb +0 -39
- data/spec/hash_spec.rb +0 -30
data/spec/string_spec.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe String do
|
4
|
-
describe "#to_params" do
|
5
|
-
it 'should return empty params hash for non url or url with no params' do
|
6
|
-
''.to_params.should == {}
|
7
|
-
'http://wiki.rego.co.il/doku.php'.to_params.should == {}
|
8
|
-
'http://wiki.rego.co.il/doku.php?'.to_params.should == {}
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should parse url return params hash" do
|
12
|
-
url = 'http://wiki.rego.co.il/doku.php?id=development:horizon3:plugins:core_extensions:start&do=edit&rev='
|
13
|
-
url.to_params.should == {:do=>"edit", :rev=>nil, :id=>"development:horizon3:plugins:core_extensions:start"}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#interpolate' do
|
18
|
-
"var is %{var1}!".interpolate(:var1 => 10).should == "var is 10!"
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#to_boolean' do
|
22
|
-
it 'should return nil for non boolean strings' do
|
23
|
-
"asdf".to_boolean.should be_nil
|
24
|
-
"0".to_boolean.should be_nil
|
25
|
-
end
|
26
|
-
it 'should return TrueClass for true strings' do
|
27
|
-
"true".to_boolean.should be_true
|
28
|
-
" true ".to_boolean.should be_true
|
29
|
-
" TRuE".to_boolean.should be_true
|
30
|
-
end
|
31
|
-
it 'should return FalseClass for true strings' do
|
32
|
-
"false".to_boolean.should be_false
|
33
|
-
" false ".to_boolean.should be_false
|
34
|
-
" FALse".to_boolean.should be_false
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
describe "#to_params" do
|
5
|
+
it 'should return empty params hash for non url or url with no params' do
|
6
|
+
''.to_params.should == {}
|
7
|
+
'http://wiki.rego.co.il/doku.php'.to_params.should == {}
|
8
|
+
'http://wiki.rego.co.il/doku.php?'.to_params.should == {}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse url return params hash" do
|
12
|
+
url = 'http://wiki.rego.co.il/doku.php?id=development:horizon3:plugins:core_extensions:start&do=edit&rev='
|
13
|
+
url.to_params.should == {:do=>"edit", :rev=>nil, :id=>"development:horizon3:plugins:core_extensions:start"}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#interpolate' do
|
18
|
+
"var is %{var1}!".interpolate(:var1 => 10).should == "var is 10!"
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#to_boolean' do
|
22
|
+
it 'should return nil for non boolean strings' do
|
23
|
+
"asdf".to_boolean.should be_nil
|
24
|
+
"0".to_boolean.should be_nil
|
25
|
+
end
|
26
|
+
it 'should return TrueClass for true strings' do
|
27
|
+
"true".to_boolean.should be_true
|
28
|
+
" true ".to_boolean.should be_true
|
29
|
+
" TRuE".to_boolean.should be_true
|
30
|
+
end
|
31
|
+
it 'should return FalseClass for true strings' do
|
32
|
+
"false".to_boolean.should be_false
|
33
|
+
" false ".to_boolean.should be_false
|
34
|
+
" FALse".to_boolean.should be_false
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/symbol_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Symbol do
|
4
|
-
it "should return false on empty? method call" do
|
5
|
-
:asdf.should_not be_empty
|
6
|
-
'y'.to_sym.should_not be_empty
|
7
|
-
end
|
8
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Symbol do
|
4
|
+
it "should return false on empty? method call" do
|
5
|
+
:asdf.should_not be_empty
|
6
|
+
'y'.to_sym.should_not be_empty
|
7
|
+
end
|
8
|
+
end
|
data/spec/time_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Time do
|
4
|
-
it "should return false on empty? method call" do
|
5
|
-
Time.now.should_not be_empty
|
6
|
-
end
|
7
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Time do
|
4
|
+
it "should return false on empty? method call" do
|
5
|
+
Time.now.should_not be_empty
|
6
|
+
end
|
7
|
+
end
|
metadata
CHANGED
@@ -1,108 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rego-ruby-ext
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 6
|
10
|
-
version: 0.0.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Alex Tkachev
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
prerelease: false
|
22
|
-
type: :development
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
32
|
-
version_requirements: *id001
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
33
14
|
name: rdoc
|
34
|
-
|
35
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
36
20
|
type: :development
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
|
-
requirements:
|
40
|
-
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 2
|
45
|
-
- 3
|
46
|
-
- 0
|
47
|
-
version: 2.3.0
|
48
|
-
version_requirements: *id002
|
49
|
-
name: rspec
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
52
34
|
type: :development
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 23
|
59
|
-
segments:
|
60
|
-
- 1
|
61
|
-
- 0
|
62
|
-
- 0
|
63
|
-
version: 1.0.0
|
64
|
-
version_requirements: *id003
|
65
|
-
name: bundler
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
35
|
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
68
48
|
type: :development
|
69
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
|
-
requirements:
|
72
|
-
- - ~>
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
hash: 7
|
75
|
-
segments:
|
76
|
-
- 1
|
77
|
-
- 6
|
78
|
-
- 4
|
79
|
-
version: 1.6.4
|
80
|
-
version_requirements: *id004
|
81
|
-
name: jeweler
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
49
|
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.8
|
84
62
|
type: :development
|
85
|
-
|
86
|
-
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
|
92
|
-
- 0
|
93
|
-
version: "0"
|
94
|
-
version_requirements: *id005
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.8
|
69
|
+
- !ruby/object:Gem::Dependency
|
95
70
|
name: rcov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
96
83
|
description: Ruby core extensions that are common for all ReGO projects
|
97
84
|
email: tkachev.alex@gmail.com
|
98
85
|
executables: []
|
99
|
-
|
100
86
|
extensions: []
|
101
|
-
|
102
|
-
extra_rdoc_files:
|
87
|
+
extra_rdoc_files:
|
103
88
|
- LICENSE.txt
|
104
89
|
- README.md
|
105
|
-
files:
|
90
|
+
files:
|
106
91
|
- .document
|
107
92
|
- .rspec
|
108
93
|
- Gemfile
|
@@ -114,7 +99,6 @@ files:
|
|
114
99
|
- lib/boolean-ext.rb
|
115
100
|
- lib/date-ext.rb
|
116
101
|
- lib/enumerable-ext.rb
|
117
|
-
- lib/hash-ext.rb
|
118
102
|
- lib/nil-ext.rb
|
119
103
|
- lib/numeric-ext.rb
|
120
104
|
- lib/rego-ruby-ext.rb
|
@@ -126,7 +110,6 @@ files:
|
|
126
110
|
- spec/boolean_spec.rb
|
127
111
|
- spec/date_spec.rb
|
128
112
|
- spec/enumerable_spec.rb
|
129
|
-
- spec/hash_spec.rb
|
130
113
|
- spec/nil_spec.rb
|
131
114
|
- spec/numeric_spec.rb
|
132
115
|
- spec/rego-ruby-ext_spec.rb
|
@@ -136,37 +119,27 @@ files:
|
|
136
119
|
- spec/symbol_spec.rb
|
137
120
|
- spec/time_spec.rb
|
138
121
|
homepage: http://github.com/alextk/rego-ruby-ext
|
139
|
-
licenses:
|
122
|
+
licenses:
|
140
123
|
- MIT
|
124
|
+
metadata: {}
|
141
125
|
post_install_message:
|
142
126
|
rdoc_options: []
|
143
|
-
|
144
|
-
require_paths:
|
127
|
+
require_paths:
|
145
128
|
- lib
|
146
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
none: false
|
157
|
-
requirements:
|
158
|
-
- - ">="
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
hash: 3
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
version: "0"
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
164
139
|
requirements: []
|
165
|
-
|
166
140
|
rubyforge_project:
|
167
|
-
rubygems_version:
|
141
|
+
rubygems_version: 2.4.6
|
168
142
|
signing_key:
|
169
|
-
specification_version:
|
143
|
+
specification_version: 4
|
170
144
|
summary: Some basic ruby core classes extensions with tests
|
171
145
|
test_files: []
|
172
|
-
|
data/lib/hash-ext.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
|
3
|
-
# Merges self with another hash, recursively.
|
4
|
-
#
|
5
|
-
# This code was lovingly stolen from some random gem:
|
6
|
-
# http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
|
7
|
-
#
|
8
|
-
# Thanks to whoever made it.
|
9
|
-
|
10
|
-
def deep_merge(hash)
|
11
|
-
target = dup
|
12
|
-
|
13
|
-
hash.keys.each do |key|
|
14
|
-
if hash[key].is_a? Hash and self[key].is_a? Hash
|
15
|
-
target[key] = target[key].deep_merge(hash[key])
|
16
|
-
next
|
17
|
-
end
|
18
|
-
|
19
|
-
target[key] = hash[key]
|
20
|
-
end
|
21
|
-
|
22
|
-
target
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# From: http://www.gemtacular.com/gemdocs/cerberus-0.2.2/doc/classes/Hash.html
|
27
|
-
# File lib/cerberus/utils.rb, line 42
|
28
|
-
|
29
|
-
def deep_merge!(second)
|
30
|
-
second.each_pair do |k,v|
|
31
|
-
if self[k].is_a?(Hash) and second[k].is_a?(Hash)
|
32
|
-
self[k].deep_merge!(second[k])
|
33
|
-
else
|
34
|
-
self[k] = second[k]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
data/spec/hash_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Hash do
|
4
|
-
describe '#deep_merge' do
|
5
|
-
it 'should not modify original hash' do
|
6
|
-
h1 = {:a => 1, :b => 2}
|
7
|
-
h2 = h1.deep_merge(:c => 3)
|
8
|
-
h2.should_not == h1
|
9
|
-
h2.should include(:c)
|
10
|
-
h1.should_not include(:c)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should merge non deep hash regularly' do
|
14
|
-
h = {:a => 1, :b => 2}.deep_merge({:a => 3, :c => 4})
|
15
|
-
h.should include(:a)
|
16
|
-
h.should include(:c)
|
17
|
-
h[:c].should == 4
|
18
|
-
h[:a].should == 3
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should merge recursively' do
|
22
|
-
h = {:a => 1, :b =>2, :c => {:c1 => 1, :c2 => 2}, :d => 4}.deep_merge(:b => 'bb', :c => {:c2 => 'cc'})
|
23
|
-
h[:a].should == 1
|
24
|
-
h[:b].should == 'bb'
|
25
|
-
h[:c][:c1].should == 1
|
26
|
-
h[:c][:c2].should == 'cc'
|
27
|
-
h[:d].should == 4
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|