tengine_support 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.12
1
+ 0.3.13
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'active_support/core_ext/hash/deep_dup'
3
+ require 'active_support/core_ext/hash/keys'
4
+
5
+ class Hash
6
+
7
+ # Return a new hash with all keys converted to strings recursively.
8
+ def deep_stringify_keys
9
+ deep_dup.deep_stringify_keys!
10
+ end
11
+
12
+ # Destructively convert all keys to strings recursively.
13
+ def deep_stringify_keys!
14
+ stringify_keys! # active_support/core_ext/hash/keysのメソッドをそのまま使う
15
+ values.each do |value|
16
+ value.deep_stringify_keys! if value.respond_to?(:deep_stringify_keys!)
17
+ end
18
+ self
19
+ end
20
+
21
+ # Return a new hash with all keys converted to symbols recursively, as long as
22
+ # they respond to +to_sym+.
23
+ def deep_symbolize_keys
24
+ deep_dup.deep_symbolize_keys!
25
+ end
26
+
27
+ # Destructively convert all keys to symbols recursively, as long as they respond
28
+ # to +to_sym+.
29
+ def deep_symbolize_keys!
30
+ symbolize_keys! # active_support/core_ext/hash/keysのメソッドをそのまま使う
31
+ values.each do |value|
32
+ value.deep_symbolize_keys! if value.respond_to?(:deep_symbolize_keys!)
33
+ end
34
+ self
35
+ end
36
+
37
+ end
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # このファイルはクラスやモジュールを定義せず、tengine/support/core_ext/*.rbをrequireするだけです
4
+ Dir.chdir(File.expand_path("../../../", File.dirname(__FILE__))) do
5
+ Dir['tengine/support/core_ext/hash'].each do |f|
6
+ require File.basename(f)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # このファイルはクラスやモジュールを定義せず、tengine/support/core_ext/*.rbをrequireするだけです
4
+ Dir.chdir(File.expand_path("../../", File.dirname(__FILE__))) do
5
+ Dir['tengine/support/core_ext'].each do |f|
6
+ require File.basename(f)
7
+ end
8
+ end
@@ -0,0 +1,85 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
3
+
4
+ require 'active_support/core_ext/hash/deep_dup'
5
+ require 'tengine/support/core_ext/hash/keys'
6
+
7
+ describe "tengine/support/core_ext/hash/keys" do
8
+
9
+ test_hashs ={
10
+ :deep_stringify_keys_result => {
11
+ 'a' => 1,
12
+ 'b' => {
13
+ 'foo' => 2,
14
+ 'bar' => {
15
+ 'hoge' => "3",
16
+ "wake" => {}.freeze,
17
+ }.freeze
18
+ }.freeze,
19
+ 'c' => {
20
+ 'baz' => "4"
21
+ }.freeze
22
+ }.freeze,
23
+
24
+ :deep_symbolize_keys_result => {
25
+ :a => 1,
26
+ :b => {
27
+ :foo => 2,
28
+ :bar => {
29
+ :hoge => "3",
30
+ :wake => {}.freeze,
31
+ }.freeze
32
+ }.freeze,
33
+ :c => {
34
+ :baz => "4"
35
+ }.freeze
36
+ }.freeze,
37
+
38
+ :mixed_key_hash => {
39
+ 'a' => 1,
40
+ :b => {
41
+ :foo => 2,
42
+ 'bar' => {
43
+ 'hoge' => "3",
44
+ :wake => {}.freeze,
45
+ }.freeze
46
+ }.freeze,
47
+ :c => {
48
+ 'baz' => "4"
49
+ }.freeze
50
+ }.freeze
51
+ }
52
+
53
+ require 'pp'
54
+
55
+ [:deep_stringify_keys, :deep_symbolize_keys].each do |method_name|
56
+ test_hashs.keys.each do |target_name|
57
+ context target_name do
58
+ describe ".#{method_name}" do
59
+ it "should returns #{method_name}_result" do
60
+ original = test_hashs[target_name]
61
+ converted = original.send(method_name)
62
+ converted.object_id.should_not == original.object_id # object_id is changed
63
+ converted.should == test_hashs[:"#{method_name}_result"]
64
+ original.should == test_hashs[target_name]
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+
71
+ test_hashs.keys.each do |target_name|
72
+ context target_name do
73
+ describe ".#{method_name}!" do
74
+ it "should equals :#{method_name}_result" do
75
+ original = test_hashs[target_name].deep_dup
76
+ result = original.send(:"#{method_name}!")
77
+ result.object_id.should == original.object_id
78
+ original.should == test_hashs[:"#{method_name}_result"]
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tengine_support"
8
- s.version = "0.3.12"
8
+ s.version = "0.3.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["saishu", "w-irie", "taigou", "totty", "hiroshinakao", "g-morita", "guemon", "aoetk", "hattori-at-nt", "t-yamada", "y-karashima", "akm"]
12
- s.date = "2011-11-19"
12
+ s.date = "2011-11-21"
13
13
  s.description = "tengine_support provides utility classes/modules which is not included in active_support. It doesn't depend on other tengine gems."
14
14
  s.email = "tengine@nautilus-technologies.com"
15
15
  s.extra_rdoc_files = [
@@ -37,6 +37,9 @@ Gem::Specification.new do |s|
37
37
  "lib/tengine/support/config/definition/suite.rb",
38
38
  "lib/tengine/support/config/logger.rb",
39
39
  "lib/tengine/support/config/mongoid.rb",
40
+ "lib/tengine/support/core_ext.rb",
41
+ "lib/tengine/support/core_ext/hash.rb",
42
+ "lib/tengine/support/core_ext/hash/keys.rb",
40
43
  "lib/tengine/support/null_logger.rb",
41
44
  "lib/tengine/support/yaml_with_erb.rb",
42
45
  "lib/tengine_support.rb",
@@ -53,6 +56,7 @@ Gem::Specification.new do |s|
53
56
  "spec/tengine_support/config_spec/load_spec_01.yml.erb",
54
57
  "spec/tengine_support/config_spec/load_spec_02.yml.erb",
55
58
  "spec/tengine_support/config_spec/parse_spec.rb",
59
+ "spec/tengine_support/core_ext/hash/keys_spec.rb",
56
60
  "spec/tengine_support/null_logger_spec.rb",
57
61
  "spec/tengine_support/yaml_with_erb_spec.rb",
58
62
  "spec/tengine_support/yaml_with_erb_spec/test1.yml.erb",
@@ -64,7 +68,7 @@ Gem::Specification.new do |s|
64
68
  s.homepage = "http://github.com/tengine/tengine_support"
65
69
  s.licenses = ["MPL/LGPL"]
66
70
  s.require_paths = ["lib"]
67
- s.rubygems_version = "1.8.10"
71
+ s.rubygems_version = "1.8.11"
68
72
  s.summary = "tengine_support provides utility classes/modules which isn't included in active_support."
69
73
 
70
74
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tengine_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,11 +20,11 @@ authors:
20
20
  autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
- date: 2011-11-19 00:00:00.000000000Z
23
+ date: 2011-11-21 00:00:00.000000000Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70214217947760 !ruby/object:Gem::Requirement
27
+ requirement: &2163308740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70214217947760
35
+ version_requirements: *2163308740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70214217946120 !ruby/object:Gem::Requirement
38
+ requirement: &2163308140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70214217946120
46
+ version_requirements: *2163308140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &70214217945180 !ruby/object:Gem::Requirement
49
+ requirement: &2163307560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.7.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70214217945180
57
+ version_requirements: *2163307560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70214217944200 !ruby/object:Gem::Requirement
60
+ requirement: &2163306980 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.18
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70214217944200
68
+ version_requirements: *2163306980
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70214217927660 !ruby/object:Gem::Requirement
71
+ requirement: &2163306380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70214217927660
79
+ version_requirements: *2163306380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70214217926460 !ruby/object:Gem::Requirement
82
+ requirement: &2163305780 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.5.3
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70214217926460
90
+ version_requirements: *2163305780
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: autotest
93
- requirement: &70214217924640 !ruby/object:Gem::Requirement
93
+ requirement: &2163305180 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70214217924640
101
+ version_requirements: *2163305180
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdiscount
104
- requirement: &70214217922500 !ruby/object:Gem::Requirement
104
+ requirement: &2163273840 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70214217922500
112
+ version_requirements: *2163273840
113
113
  description: tengine_support provides utility classes/modules which is not included
114
114
  in active_support. It doesn't depend on other tengine gems.
115
115
  email: tengine@nautilus-technologies.com
@@ -139,6 +139,9 @@ files:
139
139
  - lib/tengine/support/config/definition/suite.rb
140
140
  - lib/tengine/support/config/logger.rb
141
141
  - lib/tengine/support/config/mongoid.rb
142
+ - lib/tengine/support/core_ext.rb
143
+ - lib/tengine/support/core_ext/hash.rb
144
+ - lib/tengine/support/core_ext/hash/keys.rb
142
145
  - lib/tengine/support/null_logger.rb
143
146
  - lib/tengine/support/yaml_with_erb.rb
144
147
  - lib/tengine_support.rb
@@ -155,6 +158,7 @@ files:
155
158
  - spec/tengine_support/config_spec/load_spec_01.yml.erb
156
159
  - spec/tengine_support/config_spec/load_spec_02.yml.erb
157
160
  - spec/tengine_support/config_spec/parse_spec.rb
161
+ - spec/tengine_support/core_ext/hash/keys_spec.rb
158
162
  - spec/tengine_support/null_logger_spec.rb
159
163
  - spec/tengine_support/yaml_with_erb_spec.rb
160
164
  - spec/tengine_support/yaml_with_erb_spec/test1.yml.erb
@@ -177,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
181
  version: '0'
178
182
  segments:
179
183
  - 0
180
- hash: -155991243744560425
184
+ hash: 830871800072270067
181
185
  required_rubygems_version: !ruby/object:Gem::Requirement
182
186
  none: false
183
187
  requirements:
@@ -186,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
190
  version: '0'
187
191
  requirements: []
188
192
  rubyforge_project:
189
- rubygems_version: 1.8.10
193
+ rubygems_version: 1.8.11
190
194
  signing_key:
191
195
  specification_version: 3
192
196
  summary: tengine_support provides utility classes/modules which isn't included in