boxgrinder-core 0.1.2 → 0.1.3
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/CHANGELOG +4 -0
- data/Manifest +0 -32
- data/Rakefile +13 -21
- data/boxgrinder-core.gemspec +7 -4
- data/lib/boxgrinder-core/models/appliance-config.rb +6 -5
- data/rubygem-boxgrinder-core.spec +29 -16
- metadata +20 -6
- data/lib/openhash/openhash.rb +0 -92
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
CHANGELOG
|
|
2
|
-
LICENSE
|
|
3
|
-
Manifest
|
|
4
|
-
README
|
|
5
|
-
Rakefile
|
|
6
|
-
boxgrinder-core.gemspec
|
|
7
|
-
lib/boxgrinder-core.rb
|
|
8
|
-
lib/boxgrinder-core/defaults.rb
|
|
9
|
-
lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
|
10
|
-
lib/boxgrinder-core/helpers/appliance-helper.rb
|
|
11
|
-
lib/boxgrinder-core/helpers/exec-helper.rb
|
|
12
|
-
lib/boxgrinder-core/helpers/log-helper.rb
|
|
13
|
-
lib/boxgrinder-core/helpers/queue-helper.rb
|
|
14
|
-
lib/boxgrinder-core/models/appliance-config.rb
|
|
15
|
-
lib/boxgrinder-core/models/config.rb
|
|
16
|
-
lib/boxgrinder-core/models/task.rb
|
|
17
|
-
lib/boxgrinder-core/validators/appliance-config-validator.rb
|
|
18
|
-
lib/boxgrinder-core/validators/errors.rb
|
|
19
|
-
lib/openhash/openhash.rb
|
|
20
|
-
rubygem-boxgrinder-core.spec
|
|
21
|
-
spec/helpers/appliance-config-helper-spec.rb
|
|
22
|
-
spec/helpers/appliance-helper-spec.rb
|
|
23
|
-
spec/helpers/exec-helper-spec.rb
|
|
24
|
-
spec/helpers/log-helper-spec.rb
|
|
25
|
-
spec/helpers/queue-helper-spec.rb
|
|
26
|
-
spec/rspec/ls/one
|
|
27
|
-
spec/rspec/ls/two
|
|
28
|
-
spec/rspec/rspec-config-helper.rb
|
|
29
|
-
spec/rspec/src/appliances/ephemeral-repo.appl
|
|
30
|
-
spec/rspec/src/appliances/full.appl
|
|
31
|
-
spec/rspec/src/appliances/repo.appl
|
|
32
|
-
spec/validators/appliance-config-validator-spec.rb
|
data/Rakefile
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
require 'rubygems'
|
|
20
20
|
require 'spec/rake/spectask'
|
|
21
21
|
require 'echoe'
|
|
22
|
+
require 'rbconfig'
|
|
22
23
|
|
|
23
24
|
Echoe.new("boxgrinder-core") do |p|
|
|
24
25
|
p.project = "BoxGrinder"
|
|
@@ -26,7 +27,7 @@ Echoe.new("boxgrinder-core") do |p|
|
|
|
26
27
|
p.summary = "Core library for BoxGrinder"
|
|
27
28
|
p.url = "http://www.jboss.org/boxgrinder"
|
|
28
29
|
p.email = "info@boxgrinder.org"
|
|
29
|
-
p.runtime_dependencies = ['open4 >=1.0.0']
|
|
30
|
+
p.runtime_dependencies = ['open4 >=1.0.0', 'hashery >=1.3.0']
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
desc "Run all tests"
|
|
@@ -46,32 +47,23 @@ Spec::Rake::SpecTask.new('spec:coverage') do |t|
|
|
|
46
47
|
t.verbose = true
|
|
47
48
|
end
|
|
48
49
|
|
|
49
|
-
topdir = "#{Dir.pwd}/pkg/rpmbuild"
|
|
50
|
-
directory "#{topdir}/SOURCES"
|
|
51
|
-
|
|
52
|
-
task 'gem:copy' => [:clean, :manifest, :gem, 'rpm:topdir'] do
|
|
53
|
-
Dir["**/pkg/*.gem"].each { |gem| FileUtils.cp(gem, "#{topdir}/SOURCES", :verbose => true) }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
task 'rpm:topdir' do
|
|
57
|
-
FileUtils.mkdir_p(["#{topdir}/SOURCES", "#{topdir}/RPMS", "#{topdir}/BUILD", "#{topdir}/SPECS", "#{topdir}/SRPMS"], :verbose => true)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
50
|
desc "Create RPM"
|
|
61
|
-
task
|
|
51
|
+
task :rpm, :target, :version, :arch, :needs => ['clean', 'gem'] do |t, args|
|
|
52
|
+
target = args[:target] || 'fedora'
|
|
53
|
+
version = args[:version] || 'rawhide'
|
|
54
|
+
arch = args[:arch] || RbConfig::CONFIG['host_cpu']
|
|
55
|
+
|
|
62
56
|
Dir["**/rubygem-*.spec"].each do |spec|
|
|
63
|
-
`
|
|
57
|
+
`mock -v -r #{target}-#{version}-#{arch} --buildsrpm --sources pkg/*.gem --spec #{spec} --resultdir pkg/`
|
|
58
|
+
exit 1 unless $? == 0
|
|
59
|
+
`mock -v -r #{target}-#{version}-#{arch} --rebuild pkg/*.rpm --resultdir pkg/`
|
|
64
60
|
exit 1 unless $? == 0
|
|
65
61
|
end
|
|
66
62
|
end
|
|
67
63
|
|
|
68
64
|
desc "Install RPM"
|
|
69
|
-
task 'rpm:install' => [
|
|
70
|
-
puts "sudo yum -y remove rubygem-boxgrinder-core"
|
|
65
|
+
task 'rpm:install' => [:rpm] do
|
|
71
66
|
system "sudo yum -y remove rubygem-boxgrinder-core"
|
|
67
|
+
system "sudo yum -y localinstall --nogpgcheck pkg/*.rpm"
|
|
72
68
|
exit 1 unless $? == 0
|
|
73
|
-
|
|
74
|
-
puts "sudo yum -y --nogpgcheck localinstall #{topdir}/RPMS/noarch/*.rpm"
|
|
75
|
-
system "sudo yum -y --nogpgcheck localinstall #{topdir}/RPMS/noarch/*.rpm"
|
|
76
|
-
exit 1 unless $? == 0
|
|
77
|
-
end
|
|
69
|
+
end
|
data/boxgrinder-core.gemspec
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{boxgrinder-core}
|
|
5
|
-
s.version = "0.1.
|
|
5
|
+
s.version = "0.1.3"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Marek Goldmann"]
|
|
9
|
-
s.date = %q{2010-11-
|
|
9
|
+
s.date = %q{2010-11-23}
|
|
10
10
|
s.description = %q{Core library for BoxGrinder}
|
|
11
11
|
s.email = %q{info@boxgrinder.org}
|
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb"
|
|
13
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "
|
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb"]
|
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/helpers/queue-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "rubygem-boxgrinder-core.spec", "spec/helpers/appliance-config-helper-spec.rb", "spec/helpers/appliance-helper-spec.rb", "spec/helpers/exec-helper-spec.rb", "spec/helpers/log-helper-spec.rb", "spec/helpers/queue-helper-spec.rb", "spec/rspec/ls/one", "spec/rspec/ls/two", "spec/rspec/rspec-config-helper.rb", "spec/rspec/src/appliances/ephemeral-repo.appl", "spec/rspec/src/appliances/full.appl", "spec/rspec/src/appliances/repo.appl", "spec/validators/appliance-config-validator-spec.rb"]
|
|
14
14
|
s.homepage = %q{http://www.jboss.org/boxgrinder}
|
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-core", "--main", "README"]
|
|
16
16
|
s.require_paths = ["lib"]
|
|
@@ -24,10 +24,13 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
26
26
|
s.add_runtime_dependency(%q<open4>, [">= 1.0.0"])
|
|
27
|
+
s.add_runtime_dependency(%q<hashery>, [">= 1.3.0"])
|
|
27
28
|
else
|
|
28
29
|
s.add_dependency(%q<open4>, [">= 1.0.0"])
|
|
30
|
+
s.add_dependency(%q<hashery>, [">= 1.3.0"])
|
|
29
31
|
end
|
|
30
32
|
else
|
|
31
33
|
s.add_dependency(%q<open4>, [">= 1.0.0"])
|
|
34
|
+
s.add_dependency(%q<hashery>, [">= 1.3.0"])
|
|
32
35
|
end
|
|
33
36
|
end
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
18
18
|
|
|
19
|
+
require 'rubygems'
|
|
19
20
|
require 'boxgrinder-core/defaults'
|
|
20
|
-
require '
|
|
21
|
+
require 'hashery/opencascade'
|
|
21
22
|
|
|
22
23
|
module BoxGrinder
|
|
23
24
|
class ApplianceConfig
|
|
@@ -27,13 +28,13 @@ module BoxGrinder
|
|
|
27
28
|
|
|
28
29
|
@variables = {}
|
|
29
30
|
|
|
30
|
-
@os =
|
|
31
|
+
@os = OpenCascade.new
|
|
31
32
|
|
|
32
33
|
@os.name = nil
|
|
33
34
|
@os.version = nil
|
|
34
35
|
@os.password = nil
|
|
35
36
|
|
|
36
|
-
@hardware =
|
|
37
|
+
@hardware = OpenCascade.new
|
|
37
38
|
|
|
38
39
|
@hardware.cpus = APPLIANCE_DEFAULTS[:hardware][:cpus]
|
|
39
40
|
@hardware.memory = APPLIANCE_DEFAULTS[:hardware][:memory]
|
|
@@ -41,7 +42,7 @@ module BoxGrinder
|
|
|
41
42
|
|
|
42
43
|
@post = {}
|
|
43
44
|
|
|
44
|
-
@packages =
|
|
45
|
+
@packages = OpenCascade.new
|
|
45
46
|
@packages.includes = []
|
|
46
47
|
@packages.excludes = []
|
|
47
48
|
|
|
@@ -81,7 +82,7 @@ module BoxGrinder
|
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
def initialize_paths
|
|
84
|
-
@path =
|
|
85
|
+
@path = OpenCascade.new
|
|
85
86
|
|
|
86
87
|
@path.os = "#{@os.name}/#{@os.version}"
|
|
87
88
|
@path.main = "#{@hardware.arch}/#{@path.os}"
|
|
@@ -5,20 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
Summary: Core library for BoxGrinder
|
|
7
7
|
Name: rubygem-%{gemname}
|
|
8
|
-
Version: 0.1.
|
|
9
|
-
Release:
|
|
8
|
+
Version: 0.1.3
|
|
9
|
+
Release: 3%{?dist}
|
|
10
10
|
Group: Development/Languages
|
|
11
11
|
License: LGPLv3+
|
|
12
12
|
URL: http://www.jboss.org/boxgrinder
|
|
13
13
|
Source0: http://rubygems.org/gems/%{gemname}-%{version}.gem
|
|
14
|
-
Buildroot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
|
15
14
|
|
|
16
15
|
Requires: ruby(abi) = %{rubyabi}
|
|
17
|
-
Requires:
|
|
18
|
-
Requires:
|
|
19
|
-
|
|
20
|
-
BuildRequires:
|
|
21
|
-
BuildRequires:
|
|
16
|
+
Requires: rubygem(open4)
|
|
17
|
+
Requires: rubygem(hashery)
|
|
18
|
+
|
|
19
|
+
BuildRequires: rubygem(rake)
|
|
20
|
+
BuildRequires: rubygem(rspec)
|
|
21
|
+
BuildRequires: rubygem(open4)
|
|
22
|
+
BuildRequires: rubygem(hashery)
|
|
23
|
+
BuildRequires: rubygem(echoe)
|
|
22
24
|
|
|
23
25
|
BuildArch: noarch
|
|
24
26
|
Provides: rubygem(%{gemname}) = %{version}
|
|
@@ -35,24 +37,22 @@ Requires:%{name} = %{version}-%{release}
|
|
|
35
37
|
Documentation for %{name}
|
|
36
38
|
|
|
37
39
|
%prep
|
|
40
|
+
%setup -q -c -T
|
|
41
|
+
mkdir -p .%{gemdir}
|
|
42
|
+
gem install --local --install-dir .%{gemdir} \
|
|
43
|
+
--force --rdoc %{SOURCE0}
|
|
38
44
|
|
|
39
45
|
%build
|
|
40
46
|
|
|
41
47
|
%install
|
|
42
|
-
rm -rf %{buildroot}
|
|
43
48
|
mkdir -p %{buildroot}%{gemdir}
|
|
44
|
-
|
|
45
|
-
--force --rdoc %{SOURCE0}
|
|
49
|
+
cp -a .%{gemdir}/* %{buildroot}%{gemdir}/
|
|
46
50
|
|
|
47
51
|
%check
|
|
48
|
-
pushd
|
|
52
|
+
pushd .%{geminstdir}
|
|
49
53
|
rake spec
|
|
50
|
-
rm -rf log
|
|
51
54
|
popd
|
|
52
55
|
|
|
53
|
-
%clean
|
|
54
|
-
rm -rf %{buildroot}
|
|
55
|
-
|
|
56
56
|
%files
|
|
57
57
|
%defattr(-, root, root, -)
|
|
58
58
|
%dir %{geminstdir}
|
|
@@ -73,6 +73,19 @@ rm -rf %{buildroot}
|
|
|
73
73
|
%{gemdir}/doc/%{gemname}-%{version}
|
|
74
74
|
|
|
75
75
|
%changelog
|
|
76
|
+
* Wed Nov 17 2010 <mgoldman@redhat.com> - 0.1.3-3
|
|
77
|
+
- Added: BuildRequires: rubygem(echoe)
|
|
78
|
+
- Changed the way Gem is installed and tests are exeuted
|
|
79
|
+
|
|
80
|
+
* Mon Nov 15 2010 <mgoldman@redhat.com> - 0.1.3-2
|
|
81
|
+
- Removing unecessary Requires: rubygems
|
|
82
|
+
|
|
83
|
+
* Mon Nov 15 2010 <mgoldman@redhat.com> - 0.1.3-1
|
|
84
|
+
- Removed BuildRoot tag
|
|
85
|
+
- Adjusted Requires and BuildRequires
|
|
86
|
+
- Different approach for testing
|
|
87
|
+
- [BGBUILD-98] Use hashery gem
|
|
88
|
+
|
|
76
89
|
* Tue Nov 09 2010 <mgoldman@redhat.com> - 0.1.2-1
|
|
77
90
|
- [BGBUILD-87] Set default filesystem to ext4 for Fedora 13+
|
|
78
91
|
- [BGBUILD-65] Allow to specify own repos overriding default repos provided for selected OS
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: boxgrinder-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 29
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 0.1.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.1.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Marek Goldmann
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-11-
|
|
18
|
+
date: 2010-11-23 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -34,6 +34,22 @@ dependencies:
|
|
|
34
34
|
version: 1.0.0
|
|
35
35
|
type: :runtime
|
|
36
36
|
version_requirements: *id001
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: hashery
|
|
39
|
+
prerelease: false
|
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 27
|
|
46
|
+
segments:
|
|
47
|
+
- 1
|
|
48
|
+
- 3
|
|
49
|
+
- 0
|
|
50
|
+
version: 1.3.0
|
|
51
|
+
type: :runtime
|
|
52
|
+
version_requirements: *id002
|
|
37
53
|
description: Core library for BoxGrinder
|
|
38
54
|
email: info@boxgrinder.org
|
|
39
55
|
executables: []
|
|
@@ -56,7 +72,6 @@ extra_rdoc_files:
|
|
|
56
72
|
- lib/boxgrinder-core/models/task.rb
|
|
57
73
|
- lib/boxgrinder-core/validators/appliance-config-validator.rb
|
|
58
74
|
- lib/boxgrinder-core/validators/errors.rb
|
|
59
|
-
- lib/openhash/openhash.rb
|
|
60
75
|
files:
|
|
61
76
|
- CHANGELOG
|
|
62
77
|
- LICENSE
|
|
@@ -76,7 +91,6 @@ files:
|
|
|
76
91
|
- lib/boxgrinder-core/models/task.rb
|
|
77
92
|
- lib/boxgrinder-core/validators/appliance-config-validator.rb
|
|
78
93
|
- lib/boxgrinder-core/validators/errors.rb
|
|
79
|
-
- lib/openhash/openhash.rb
|
|
80
94
|
- rubygem-boxgrinder-core.spec
|
|
81
95
|
- spec/helpers/appliance-config-helper-spec.rb
|
|
82
96
|
- spec/helpers/appliance-helper-spec.rb
|
data/lib/openhash/openhash.rb
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# The MIT License
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2005 Thomas Sawyer
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
22
|
-
|
|
23
|
-
class OpenHash < Hash
|
|
24
|
-
|
|
25
|
-
# New OpenHash.
|
|
26
|
-
def initialize(data={})
|
|
27
|
-
super()
|
|
28
|
-
merge!(data)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
def <<(x)
|
|
33
|
-
case x
|
|
34
|
-
when Hash
|
|
35
|
-
update(x)
|
|
36
|
-
when Array
|
|
37
|
-
x.each_slice(2) do |(k, v)|
|
|
38
|
-
self[k] = v
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
def respond_to?(name)
|
|
45
|
-
key?(name.to_sym) || super(name)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
def to_h
|
|
50
|
-
dup
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
def to_hash
|
|
55
|
-
dup
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
def inspect
|
|
60
|
-
super
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Omit specific Hash methods from slot protection.
|
|
64
|
-
def omit!(*methods)
|
|
65
|
-
methods.reject!{ |x| x.to_s =~ /^__/ }
|
|
66
|
-
(
|
|
67
|
-
class << self;
|
|
68
|
-
self;
|
|
69
|
-
end).class_eval{ private *methods }
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Route get and set calls.
|
|
73
|
-
def method_missing(s, *a, &b)
|
|
74
|
-
type = s.to_s[-1, 1]
|
|
75
|
-
name = s.to_s.sub(/[!?=]$/, '')
|
|
76
|
-
key = name.to_sym
|
|
77
|
-
case type
|
|
78
|
-
when '='
|
|
79
|
-
self[key] = a[0]
|
|
80
|
-
#when '!'
|
|
81
|
-
# self[s] = OpenHash.new
|
|
82
|
-
when '?'
|
|
83
|
-
key?(key)
|
|
84
|
-
else
|
|
85
|
-
if key?(key)
|
|
86
|
-
self[key]
|
|
87
|
-
else
|
|
88
|
-
nil # super(s, *a, &b)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|