tagen 1.1.0 → 1.1.1
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.
- data/Gemfile +5 -3
- data/Gemfile.lock +14 -18
- data/lib/tagen/core/array.rb +7 -6
- data/lib/tagen/core/hash.rb +12 -11
- data/lib/tagen/erb.rb +2 -4
- data/lib/tagen/version.rb +1 -1
- data/spec/tagen/core/array_spec.rb +6 -7
- data/spec/tagen/core/hash_spec.rb +6 -6
- data/spec/tagen/erb_spec.rb +4 -4
- data/tagen.gemspec +10 -8
- metadata +15 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
tagen (0.2.4)
|
5
|
-
activesupport
|
6
|
-
pd
|
7
|
-
|
8
1
|
GEM
|
9
2
|
remote: http://rubygems.org/
|
10
3
|
specs:
|
11
|
-
activesupport (3.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rspec-
|
17
|
-
rspec-
|
18
|
-
|
19
|
-
rspec-
|
4
|
+
activesupport (3.1.3)
|
5
|
+
multi_json (~> 1.0)
|
6
|
+
diff-lcs (1.1.3)
|
7
|
+
multi_json (1.0.3)
|
8
|
+
rspec (2.7.0)
|
9
|
+
rspec-core (~> 2.7.0)
|
10
|
+
rspec-expectations (~> 2.7.0)
|
11
|
+
rspec-mocks (~> 2.7.0)
|
12
|
+
rspec-core (2.7.1)
|
13
|
+
rspec-expectations (2.7.0)
|
20
14
|
diff-lcs (~> 1.1.2)
|
21
|
-
rspec-mocks (2.
|
15
|
+
rspec-mocks (2.7.0)
|
16
|
+
watchr (0.7)
|
22
17
|
|
23
18
|
PLATFORMS
|
24
19
|
ruby
|
25
20
|
|
26
21
|
DEPENDENCIES
|
22
|
+
activesupport (~> 3.1.0)
|
27
23
|
rspec
|
28
|
-
|
24
|
+
watchr
|
data/lib/tagen/core/array.rb
CHANGED
@@ -98,12 +98,13 @@ class Array
|
|
98
98
|
|
99
99
|
alias original_grep grep
|
100
100
|
|
101
|
+
# confict with awesome_print which extend grep, too
|
101
102
|
# add grep(arr rb/tage)
|
102
|
-
def grep(pat_s, &blk)
|
103
|
-
pats = Array===pat_s ? pat_s : [pat_s]
|
104
|
-
pats.each.with_object([]) { |k, memo|
|
105
|
-
memo.push *self.original_grep(k)
|
106
|
-
}
|
107
|
-
end
|
103
|
+
#def grep(pat_s, &blk)
|
104
|
+
#pats = Array===pat_s ? pat_s : [pat_s]
|
105
|
+
#pats.each.with_object([]) { |k, memo|
|
106
|
+
#memo.push *self.original_grep(k)
|
107
|
+
#}
|
108
|
+
#end
|
108
109
|
|
109
110
|
end # class Array
|
data/lib/tagen/core/hash.rb
CHANGED
@@ -14,7 +14,8 @@ class Hash
|
|
14
14
|
keys.length==1 ? values[0] : values
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
# confict with awesome_print which extend Array#grep
|
18
|
+
#
|
18
19
|
# grep pat at hash's keys, and return a new hash.
|
19
20
|
# @see Array#grep
|
20
21
|
#
|
@@ -24,15 +25,15 @@ class Hash
|
|
24
25
|
# foo.grep(:a) #=> {a: 1}
|
25
26
|
#
|
26
27
|
# @return [Hash]
|
27
|
-
def grep(pat_s)
|
28
|
-
|
29
|
-
|
30
|
-
filtered_keys = pats.each.with_object([]) { |pat, memo|
|
31
|
-
memo.push *self.keys.grep(pat)
|
32
|
-
}
|
33
|
-
filtered_keys.each.with_object({}) { |k,memo|
|
34
|
-
memo[k] = self[k]
|
35
|
-
}
|
36
|
-
end
|
28
|
+
#def grep(pat_s)
|
29
|
+
# pats = Array===pat_s ? pat_s : [pat_s]
|
30
|
+
#
|
31
|
+
# filtered_keys = pats.each.with_object([]) { |pat, memo|
|
32
|
+
# memo.push *self.keys.grep(pat)
|
33
|
+
# }
|
34
|
+
# filtered_keys.each.with_object({}) { |k,memo|
|
35
|
+
# memo[k] = self[k]
|
36
|
+
# }
|
37
|
+
# end
|
37
38
|
|
38
39
|
end # class Hash
|
data/lib/tagen/erb.rb
CHANGED
@@ -10,7 +10,7 @@ class ERB
|
|
10
10
|
# erb.result(nil, a: 1) #=> "1"
|
11
11
|
#
|
12
12
|
# @param [Hash,OpenOption] locals
|
13
|
-
def result
|
13
|
+
def result(bind=nil, locals={})
|
14
14
|
bind ||= TOPLEVEL_BINDING
|
15
15
|
if locals.empty?
|
16
16
|
original_result bind
|
@@ -20,9 +20,7 @@ class ERB
|
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
|
-
def result_with_locals
|
24
|
-
locals = locals.class.to_s=="OpenOption" ? locals._data : locals
|
25
|
-
|
23
|
+
def result_with_locals(bind, locals)
|
26
24
|
@locals = locals
|
27
25
|
evalstr = <<-EOF
|
28
26
|
def run_erb
|
data/lib/tagen/version.rb
CHANGED
@@ -33,11 +33,10 @@ describe Array do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe "#grep" do
|
37
|
-
it "supports array as an argument" do
|
38
|
-
a = [:a, :b, :c]
|
39
|
-
a.grep([:a, :b]).should == [:a, :b]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
36
|
+
#describe "#grep" do
|
37
|
+
#it "supports array as an argument" do
|
38
|
+
#a = [:a, :b, :c]
|
39
|
+
#a.grep([:a, :b]).should == [:a, :b]
|
40
|
+
#end
|
41
|
+
#end
|
43
42
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Hash do
|
4
|
-
describe "#grep" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
4
|
+
#describe "#grep" do
|
5
|
+
# it "works" do
|
6
|
+
# a = {a: 1, b: 2, c: 3}
|
7
|
+
# a.grep([:a, :b]).should == {a: 1, b: 2}
|
8
|
+
# end
|
9
|
+
#end
|
10
10
|
end
|
data/spec/tagen/erb_spec.rb
CHANGED
@@ -21,10 +21,10 @@ describe ERB do
|
|
21
21
|
@erb.result(nil, "a" => 2).should == "2"
|
22
22
|
end
|
23
23
|
|
24
|
-
it "support OpenOption" do
|
25
|
-
o = OpenOption.new(a: 1)
|
26
|
-
|
27
|
-
end
|
24
|
+
#it "support OpenOption" do
|
25
|
+
#o = OpenOption.new(a: 1)
|
26
|
+
#@erb.result(nil, o).should == '1'
|
27
|
+
#end
|
28
28
|
|
29
29
|
end
|
30
30
|
end
|
data/tagen.gemspec
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
$: << File.expand_path(
|
2
|
-
require
|
1
|
+
$: << File.expand_path('../lib', __FILE__)
|
2
|
+
require 'tagen/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
5
|
+
s.name = 'tagen'
|
6
6
|
s.version = Tagen::VERSION
|
7
|
-
s.summary =
|
7
|
+
s.summary = 'a core and extra extension to ruby library'
|
8
8
|
s.description = <<-EOF
|
9
9
|
a core and extra extension to ruby library.
|
10
10
|
EOF
|
11
11
|
|
12
|
-
s.author =
|
13
|
-
s.email =
|
14
|
-
s.homepage =
|
15
|
-
s.rubyforge_project =
|
12
|
+
s.author = 'Guten'
|
13
|
+
s.email = 'ywzhaifei@gmail.com'
|
14
|
+
s.homepage = 'http://github.com/GutenYe/tagen'
|
15
|
+
s.rubyforge_project = 'xx'
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
|
+
|
19
|
+
s.add_dependency 'activesupport', '~>3.1.0'
|
18
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
dependencies:
|
12
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: &23214320 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *23214320
|
14
25
|
description: ! "a core and extra extension to ruby library. \n"
|
15
26
|
email: ywzhaifei@gmail.com
|
16
27
|
executables: []
|
@@ -100,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
111
|
version: '0'
|
101
112
|
requirements: []
|
102
113
|
rubyforge_project: xx
|
103
|
-
rubygems_version: 1.8.
|
114
|
+
rubygems_version: 1.8.11
|
104
115
|
signing_key:
|
105
116
|
specification_version: 3
|
106
117
|
summary: a core and extra extension to ruby library
|