recursive-open-struct 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +50 -0
- data/.rspec +0 -1
- data/Gemfile +1 -14
- data/Rakefile +15 -41
- data/lib/recursive_open_struct.rb +5 -0
- data/recursive-open-struct.gemspec +27 -48
- data/spec/recursive_open_struct_spec.rb +6 -0
- metadata +87 -86
- data/Gemfile.lock +0 -31
- data/VERSION +0 -1
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
.DS_Store
|
31
|
+
|
32
|
+
# For TextMate
|
33
|
+
*.tmproj
|
34
|
+
tmtags
|
35
|
+
|
36
|
+
# For emacs:
|
37
|
+
*~
|
38
|
+
\#*
|
39
|
+
.\#*
|
40
|
+
|
41
|
+
# For vim:
|
42
|
+
*.swp
|
43
|
+
|
44
|
+
# For redcar:
|
45
|
+
#.redcar
|
46
|
+
|
47
|
+
# For rubinius:
|
48
|
+
#*.rbc
|
49
|
+
|
50
|
+
Gemfile.lock
|
data/.rspec
CHANGED
data/Gemfile
CHANGED
@@ -1,15 +1,2 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
# Add dependencies required to use your gem here.
|
4
|
-
# Example:
|
5
|
-
# gem "activesupport", ">= 2.3.5"
|
6
|
-
|
7
|
-
# Add dependencies to develop your gem here.
|
8
|
-
# Include everything needed to run rake, tests, features, etc.
|
9
|
-
group :development do
|
10
|
-
gem 'rspec' #, "~> 2.3.0"
|
11
|
-
gem 'bundler' #, "~> 1.0.0"
|
12
|
-
gem 'jeweler' #, "~> 1.6.0"
|
13
|
-
gem 'rcov' if RUBY_VERSION =~ /^1\.8/
|
14
|
-
gem 'rdoc'
|
15
|
-
end
|
2
|
+
gemspec
|
data/Rakefile
CHANGED
@@ -1,54 +1,25 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "recursive-open-struct"
|
18
|
-
gem.homepage = "http://github.com/aetherknight/recursive-open-struct"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs}
|
21
|
-
gem.description = <<EOF
|
22
|
-
RecursiveOpenStruct is a subclass of OpenStruct. It differs from
|
23
|
-
OpenStruct in that it allows nested hashes to be treated in a recursive
|
24
|
-
fashion. For example:
|
25
|
-
|
26
|
-
ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } })
|
27
|
-
ros.a.b # 'c'
|
28
|
-
|
29
|
-
Also, nested hashes can still be accessed as hashes:
|
30
|
-
|
31
|
-
ros.a_as_a_hash # { :b => 'c' }
|
32
|
-
EOF
|
33
|
-
gem.email = "aetherknight@gmail.com"
|
34
|
-
gem.authors = ["William (B.J.) Snow Orvis"]
|
35
|
-
# dependencies defined in Gemfile
|
36
|
-
end
|
37
|
-
Jeweler::RubygemsDotOrgTasks.new
|
4
|
+
require 'bundler/gem_tasks'
|
38
5
|
|
39
|
-
require 'rspec/core'
|
40
6
|
require 'rspec/core/rake_task'
|
41
7
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
42
8
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
43
9
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
10
|
+
namespace :spec do
|
11
|
+
desc "Create rspec code coverage (1.9+)"
|
12
|
+
task :coverage do
|
13
|
+
ENV['COVERAGE'] = 'true'
|
14
|
+
Rake::Task["spec"].execute
|
15
|
+
end
|
16
|
+
desc "Rspec code coverage (1.8.7)"
|
17
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
18
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
19
|
+
spec.rcov = true
|
20
|
+
end
|
48
21
|
end
|
49
22
|
|
50
|
-
task :default => :spec
|
51
|
-
|
52
23
|
require 'rdoc/task'
|
53
24
|
Rake::RDocTask.new do |rdoc|
|
54
25
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
@@ -58,3 +29,6 @@ Rake::RDocTask.new do |rdoc|
|
|
58
29
|
rdoc.rdoc_files.include('README*')
|
59
30
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
60
31
|
end
|
32
|
+
|
33
|
+
task :default => :spec
|
34
|
+
|
@@ -1,12 +1,17 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
|
3
3
|
class RecursiveOpenStruct < OpenStruct
|
4
|
+
VERSION = "0.4.0"
|
4
5
|
|
5
6
|
def initialize(h=nil, args={})
|
6
7
|
@recurse_over_arrays = args.fetch(:recurse_over_arrays,false)
|
7
8
|
super(h)
|
8
9
|
end
|
9
10
|
|
11
|
+
def to_h
|
12
|
+
@table.dup
|
13
|
+
end
|
14
|
+
|
10
15
|
def new_ostruct_member(name)
|
11
16
|
name = name.to_sym
|
12
17
|
unless self.respond_to?(name)
|
@@ -1,61 +1,40 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
3
|
+
require './lib/recursive_open_struct'
|
4
|
+
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = "recursive-open-struct"
|
8
|
-
s.version =
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
7
|
+
s.version = RecursiveOpenStruct::VERSION
|
11
8
|
s.authors = ["William (B.J.) Snow Orvis"]
|
12
|
-
s.date = "2013-01-05"
|
13
|
-
s.description = "RecursiveOpenStruct is a subclass of OpenStruct. It differs from\nOpenStruct in that it allows nested hashes to be treated in a recursive\nfashion. For example:\n\n ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } })\n ros.a.b # 'c'\n\nAlso, nested hashes can still be accessed as hashes:\n\n ros.a_as_a_hash # { :b => 'c' }\n"
|
14
9
|
s.email = "aetherknight@gmail.com"
|
10
|
+
s.date = Time.now.utc.strftime("%Y-%m-%d")
|
11
|
+
s.homepage = "http://github.com/aetherknight/recursive-open-struct"
|
12
|
+
s.licenses = ["MIT"]
|
13
|
+
|
14
|
+
s.summary = "OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs"
|
15
|
+
s.description = <<-QUOTE .gsub(/^ /,'')
|
16
|
+
RecursiveOpenStruct is a subclass of OpenStruct. It differs from
|
17
|
+
OpenStruct in that it allows nested hashes to be treated in a recursive
|
18
|
+
fashion. For example:
|
19
|
+
|
20
|
+
ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } })
|
21
|
+
ros.a.b # 'c'
|
22
|
+
|
23
|
+
Also, nested hashes can still be accessed as hashes:
|
24
|
+
|
25
|
+
ros.a_as_a_hash # { :b => 'c' }
|
26
|
+
QUOTE
|
27
|
+
|
28
|
+
s.files = `git ls-files`.split("\n")
|
29
|
+
s.test_files = `git ls-files spec`.split("\n")
|
30
|
+
s.require_paths = ["lib"]
|
15
31
|
s.extra_rdoc_files = [
|
16
32
|
"LICENSE.txt",
|
17
33
|
"README.rdoc"
|
18
34
|
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
"Gemfile",
|
23
|
-
"Gemfile.lock",
|
24
|
-
"LICENSE.txt",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"lib/recursive-open-struct.rb",
|
29
|
-
"lib/recursive_open_struct.rb",
|
30
|
-
"recursive-open-struct.gemspec",
|
31
|
-
"spec/recursive_open_struct_spec.rb",
|
32
|
-
"spec/spec_helper.rb"
|
33
|
-
]
|
34
|
-
s.homepage = "http://github.com/aetherknight/recursive-open-struct"
|
35
|
-
s.licenses = ["MIT"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = "1.8.24"
|
38
|
-
s.summary = "OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs"
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
45
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
46
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
47
|
-
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
50
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
51
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
52
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
53
|
-
end
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
57
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
58
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
59
|
-
end
|
36
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
37
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
38
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
60
39
|
end
|
61
40
|
|
@@ -17,6 +17,12 @@ describe RecursiveOpenStruct do
|
|
17
17
|
ros.asdf.should == "John Smith"
|
18
18
|
end
|
19
19
|
|
20
|
+
it "can be converted back to a hash" do
|
21
|
+
h = { :asdf => 'John Smith' }
|
22
|
+
ros = RecursiveOpenStruct.new(h)
|
23
|
+
ros.to_h.should == h
|
24
|
+
end
|
25
|
+
|
20
26
|
it "can modify an existing key" do
|
21
27
|
h = { :blah => 'John Smith' }
|
22
28
|
ros = RecursiveOpenStruct.new(h)
|
metadata
CHANGED
@@ -1,131 +1,132 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: recursive-open-struct
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- William (B.J.) Snow Orvis
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-05-26 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: rspec
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
23
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: bundler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
33
25
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
38
33
|
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bundler
|
39
37
|
prerelease: false
|
40
|
-
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
54
47
|
type: :development
|
55
|
-
|
56
|
-
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
63
50
|
name: rdoc
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
51
|
prerelease: false
|
72
|
-
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
73
53
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: |
|
64
|
+
RecursiveOpenStruct is a subclass of OpenStruct. It differs from
|
65
|
+
OpenStruct in that it allows nested hashes to be treated in a recursive
|
66
|
+
fashion. For example:
|
67
|
+
|
68
|
+
ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } })
|
69
|
+
ros.a.b # 'c'
|
70
|
+
|
71
|
+
Also, nested hashes can still be accessed as hashes:
|
72
|
+
|
73
|
+
ros.a_as_a_hash # { :b => 'c' }
|
74
|
+
|
83
75
|
email: aetherknight@gmail.com
|
84
76
|
executables: []
|
77
|
+
|
85
78
|
extensions: []
|
86
|
-
|
79
|
+
|
80
|
+
extra_rdoc_files:
|
87
81
|
- LICENSE.txt
|
88
82
|
- README.rdoc
|
89
|
-
files:
|
83
|
+
files:
|
90
84
|
- .document
|
85
|
+
- .gitignore
|
91
86
|
- .rspec
|
92
87
|
- Gemfile
|
93
|
-
- Gemfile.lock
|
94
88
|
- LICENSE.txt
|
95
89
|
- README.rdoc
|
96
90
|
- Rakefile
|
97
|
-
- VERSION
|
98
91
|
- lib/recursive-open-struct.rb
|
99
92
|
- lib/recursive_open_struct.rb
|
100
93
|
- recursive-open-struct.gemspec
|
101
94
|
- spec/recursive_open_struct_spec.rb
|
102
95
|
- spec/spec_helper.rb
|
96
|
+
has_rdoc: true
|
103
97
|
homepage: http://github.com/aetherknight/recursive-open-struct
|
104
|
-
licenses:
|
98
|
+
licenses:
|
105
99
|
- MIT
|
106
100
|
post_install_message:
|
107
101
|
rdoc_options: []
|
108
|
-
|
102
|
+
|
103
|
+
require_paths:
|
109
104
|
- lib
|
110
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
106
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
117
112
|
- 0
|
118
|
-
|
119
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
115
|
none: false
|
121
|
-
requirements:
|
122
|
-
- -
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
125
123
|
requirements: []
|
124
|
+
|
126
125
|
rubyforge_project:
|
127
|
-
rubygems_version: 1.
|
126
|
+
rubygems_version: 1.3.7
|
128
127
|
signing_key:
|
129
128
|
specification_version: 3
|
130
129
|
summary: OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs
|
131
|
-
test_files:
|
130
|
+
test_files:
|
131
|
+
- spec/recursive_open_struct_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
data/Gemfile.lock
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.3)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.8.4)
|
7
|
-
bundler (~> 1.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
|
-
rdoc
|
11
|
-
json (1.7.5)
|
12
|
-
rake (0.9.2.2)
|
13
|
-
rdoc (3.12)
|
14
|
-
json (~> 1.4)
|
15
|
-
rspec (2.11.0)
|
16
|
-
rspec-core (~> 2.11.0)
|
17
|
-
rspec-expectations (~> 2.11.0)
|
18
|
-
rspec-mocks (~> 2.11.0)
|
19
|
-
rspec-core (2.11.1)
|
20
|
-
rspec-expectations (2.11.3)
|
21
|
-
diff-lcs (~> 1.1.3)
|
22
|
-
rspec-mocks (2.11.3)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
bundler
|
29
|
-
jeweler
|
30
|
-
rdoc
|
31
|
-
rspec
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.1
|