tagen 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -20
- data/lib/tagen/core.rb +1 -0
- data/lib/tagen/core/array.rb +10 -0
- data/lib/tagen/core/extend_hash.rb +21 -0
- data/lib/tagen/core/hash.rb +21 -0
- data/lib/tagen/version.rb +10 -0
- data/spec/tagen/core/array_spec.rb +6 -0
- data/spec/tagen/core/extend_hash_spec.rb +35 -0
- data/spec/tagen/core/hash_spec.rb +10 -0
- data/tagen.gemspec +2 -2
- metadata +42 -46
- data/LICENSE +0 -20
- data/version.rb +0 -9
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
Tagen, a core and extra extension to Ruby library.
|
2
2
|
==========================================
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
| Homepage: | https://github.com/GutenYe/tagen |
|
5
|
+
|----------------|-----------------------------------------|
|
6
|
+
| Author: | Guten |
|
7
|
+
| License: | MIT LICENSE |
|
8
|
+
| Documentation: | http://rubydoc.info/gems/tagen/frames |
|
9
|
+
| Issue Tracker: | https://github.com/GutenYe/tagen/issues |
|
10
|
+
|
10
11
|
|
11
12
|
Overview
|
12
13
|
--------
|
@@ -36,12 +37,6 @@ or
|
|
36
37
|
|
37
38
|
this will add #path method to Pathname, see API doc.
|
38
39
|
|
39
|
-
Requirements
|
40
|
-
------------
|
41
|
-
|
42
|
-
tested: ruby1.9 linux
|
43
|
-
|
44
|
-
|
45
40
|
An Introduction to PyFormat
|
46
41
|
---------------------------
|
47
42
|
|
@@ -68,20 +63,25 @@ Install
|
|
68
63
|
Contributing
|
69
64
|
-------------
|
70
65
|
|
71
|
-
*
|
72
|
-
*
|
73
|
-
*
|
74
|
-
* feel free to post any ideas.
|
66
|
+
* Feel free to join the project and make contributions (by submitting a pull request)
|
67
|
+
* Submit any bugs/features/ideas to github issue tracker
|
68
|
+
* Coding Style Guide: https://gist.github.com/1105334
|
75
69
|
|
76
70
|
Contributors
|
77
71
|
------------
|
78
72
|
|
79
|
-
|
73
|
+
* [contributors](https://github.com/<%=github.username%>/<%=project%>/contributors)
|
80
74
|
|
81
75
|
|
82
76
|
Copyright
|
83
77
|
---------
|
84
|
-
Copyright © 2011 by Guten. this library released under MIT-License, See {file:LICENSE} for futher details.
|
85
78
|
|
86
|
-
|
87
|
-
|
79
|
+
(the MIT License)
|
80
|
+
|
81
|
+
Copyright (c) 2011 Guten
|
82
|
+
|
83
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
84
|
+
|
85
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
86
|
+
|
87
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/tagen/core.rb
CHANGED
data/lib/tagen/core/array.rb
CHANGED
@@ -96,4 +96,14 @@ class Array
|
|
96
96
|
ret
|
97
97
|
end
|
98
98
|
|
99
|
+
alias original_grep grep
|
100
|
+
|
101
|
+
# add grep(arr rb/tage)
|
102
|
+
def grep(pat_s, &blk)
|
103
|
+
pats = Array.wrap(pat_s)
|
104
|
+
pats.each.with_object([]) { |k, memo|
|
105
|
+
memo.push *self.original_grep(k)
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
99
109
|
end # class Array
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class ExtendHash < Hash
|
2
|
+
def []=(key, value)
|
3
|
+
key = key.to_sym if String === key
|
4
|
+
super(key, value)
|
5
|
+
end
|
6
|
+
|
7
|
+
def [](key)
|
8
|
+
key = key.to_sym if String === key
|
9
|
+
super(key)
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(name, *args)
|
13
|
+
if name =~ /=$/
|
14
|
+
store(name[0...-1].to_sym, args[0])
|
15
|
+
elsif has_key?(name)
|
16
|
+
fetch(name)
|
17
|
+
else
|
18
|
+
raise NoMethodError, "-- :#{name}, #{args.inspect}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/tagen/core/hash.rb
CHANGED
@@ -14,4 +14,25 @@ class Hash
|
|
14
14
|
keys.length==1 ? values[0] : values
|
15
15
|
end
|
16
16
|
|
17
|
+
|
18
|
+
# grep pat at hash's keys, and return a new hash.
|
19
|
+
# @see Array#grep
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
#
|
23
|
+
# foo = {a: 1, b: 2}
|
24
|
+
# foo.grep(:a) #=> {a: 1}
|
25
|
+
#
|
26
|
+
# @return [Hash]
|
27
|
+
def grep(pat_s)
|
28
|
+
pats = Array.wrap(pat_s)
|
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
|
37
|
+
|
17
38
|
end # class Hash
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "tagen/core/extend_hash"
|
3
|
+
|
4
|
+
describe ExtendHash do
|
5
|
+
describe "#[]" do
|
6
|
+
it "convert string-key to symbol-key" do
|
7
|
+
h = ExtendHash.new
|
8
|
+
h.store(:ok, 1)
|
9
|
+
h["ok"].should == 1
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#[]=" do
|
14
|
+
it "convert string-key to symbol-key" do
|
15
|
+
h = ExtendHash.new
|
16
|
+
h["ok"] = 1
|
17
|
+
h[:ok] = 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#method_missing" do
|
22
|
+
it "#key" do
|
23
|
+
h = ExtendHash.new
|
24
|
+
h[:ok] = 1
|
25
|
+
h.ok.should == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
it "#key=" do
|
29
|
+
h = ExtendHash.new
|
30
|
+
h.ok = 1
|
31
|
+
h.ok.should == 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/tagen.gemspec
CHANGED
metadata
CHANGED
@@ -1,55 +1,52 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagen
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
4
5
|
prerelease:
|
5
|
-
version: 1.0.3
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Guten
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &23815820 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: pd
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *23815820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: pd
|
27
|
+
requirement: &23813820 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
35
33
|
type: :runtime
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *23813820
|
36
|
+
description: ! 'an extension to ruby core and gem library. use some active_support/core_ext,
|
37
|
+
but smaller than active_support. active_support is mainly target to Rails, but tagen
|
38
|
+
is target to generic ruby development.
|
39
39
|
|
40
|
+
'
|
40
41
|
email: ywzhaifei@gmail.com
|
41
42
|
executables: []
|
42
|
-
|
43
43
|
extensions: []
|
44
|
-
|
45
44
|
extra_rdoc_files: []
|
46
|
-
|
47
|
-
files:
|
45
|
+
files:
|
48
46
|
- .gitignore
|
49
47
|
- .yardopts
|
50
48
|
- Gemfile
|
51
49
|
- Gemfile.lock
|
52
|
-
- LICENSE
|
53
50
|
- README.md
|
54
51
|
- Rakefile
|
55
52
|
- TODO
|
@@ -64,6 +61,7 @@ files:
|
|
64
61
|
- lib/tagen/core/array/extract_options.rb
|
65
62
|
- lib/tagen/core/enumerable.rb
|
66
63
|
- lib/tagen/core/enumerator.rb
|
64
|
+
- lib/tagen/core/extend_hash.rb
|
67
65
|
- lib/tagen/core/hash.rb
|
68
66
|
- lib/tagen/core/io.rb
|
69
67
|
- lib/tagen/core/kernel.rb
|
@@ -87,6 +85,7 @@ files:
|
|
87
85
|
- lib/tagen/poppler.rb
|
88
86
|
- lib/tagen/socket.rb
|
89
87
|
- lib/tagen/tree.rb
|
88
|
+
- lib/tagen/version.rb
|
90
89
|
- lib/tagen/vim.rb
|
91
90
|
- lib/tagen/xmpp4r.rb
|
92
91
|
- lib/tagen/xmpp4r/roster.rb
|
@@ -96,6 +95,8 @@ files:
|
|
96
95
|
- spec/tagen/core/array/extract_options_spec.rb
|
97
96
|
- spec/tagen/core/array_spec.rb
|
98
97
|
- spec/tagen/core/enumerator_spec.rb
|
98
|
+
- spec/tagen/core/extend_hash_spec.rb
|
99
|
+
- spec/tagen/core/hash_spec.rb
|
99
100
|
- spec/tagen/core/module_spec.rb
|
100
101
|
- spec/tagen/core/open_option_spec.rb
|
101
102
|
- spec/tagen/core/string/pyformat_spec.rb
|
@@ -103,33 +104,28 @@ files:
|
|
103
104
|
- spec/tagen/erb_spec.rb
|
104
105
|
- tagen.gemspec
|
105
106
|
- tagen.watchr
|
106
|
-
- version.rb
|
107
107
|
homepage: http://github.com/GutenYe/tagen
|
108
108
|
licenses: []
|
109
|
-
|
110
109
|
post_install_message:
|
111
110
|
rdoc_options: []
|
112
|
-
|
113
|
-
require_paths:
|
111
|
+
require_paths:
|
114
112
|
- lib
|
115
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
114
|
none: false
|
117
|
-
requirements:
|
118
|
-
- -
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version:
|
121
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
120
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version:
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
127
125
|
requirements: []
|
128
|
-
|
129
126
|
rubyforge_project: xx
|
130
127
|
rubygems_version: 1.8.5
|
131
128
|
signing_key:
|
132
129
|
specification_version: 3
|
133
130
|
summary: a core and extra extension to ruby library
|
134
131
|
test_files: []
|
135
|
-
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Guten
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
'Software'), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|