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 CHANGED
@@ -1,12 +1,13 @@
1
1
  Tagen, a core and extra extension to Ruby library.
2
2
  ==========================================
3
3
 
4
- **Homepage**: [https://github.com/GutenYe/tagen](https://github.com/GutenYe/tagen) <br/>
5
- **Author**: Guten <br/>
6
- **Contributors**: See Contributors section below <br/>
7
- **License**: MIT License <br/>
8
- **Documentation**: [http://rubydoc.info/gems/tagen/frames](http://rubydoc.info/gems/tagen/frames) <br/>
9
- **Issue Tracker**: [https://github.com/GutenYe/tagen/issues](https://github.com/GutenYe/tagen/issues) <br/>
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
- * report bugs/featues to issue tracker.
72
- * fork it and pull a request.
73
- * improve documentation.
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
- WORD-III
73
+ * [contributors](https://github.com/<%=github.username%>/<%=project%>/contributors)
80
74
 
81
75
 
82
76
  Copyright
83
77
  ---------
84
- Copyright &copy; 2011 by Guten. this library released under MIT-License, See {file:LICENSE} for futher details.
85
78
 
86
- asddf
87
- asdf
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.
@@ -26,6 +26,7 @@ require "pd"
26
26
  core/symbol
27
27
  core/array
28
28
  core/hash
29
+ core/extend_hash
29
30
  core/re
30
31
 
31
32
  core/time
@@ -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
@@ -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,10 @@
1
+ module Tagen
2
+ module VERSION
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 4
6
+ PRE = nil
7
+
8
+ IS = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
9
+ end
10
+ end
@@ -33,5 +33,11 @@ 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
36
42
 
37
43
  end
@@ -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
+
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+
3
+ describe Hash do
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
+ end
@@ -1,5 +1,5 @@
1
- $: << "."
2
- require "version"
1
+ $: << File.expand_path("../lib", __FILE__)
2
+ require "tagen/version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tagen"
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
- date: 2011-07-05 00:00:00 Z
14
- dependencies:
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
- prerelease: false
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: "0"
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
- requirement: &id002 !ruby/object:Gem::Requirement
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: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
35
33
  type: :runtime
36
- version_requirements: *id002
37
- description: |
38
- an extension to ruby core and gem library. use some active_support/core_ext, but smaller than active_support. active_support is mainly target to Rails, but tagen is target to generic ruby development.
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: "0"
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: "0"
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.
data/version.rb DELETED
@@ -1,9 +0,0 @@
1
- module Tagen
2
- module VERSION
3
- MAJOR = 1
4
- MINOR = 0
5
- PATCH = 3
6
-
7
- IS = [MAJOR, MINOR, PATCH].join(".")
8
- end
9
- end