rash 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rspec +3 -0
- data/Gemfile +2 -0
- data/README.rdoc +1 -1
- data/Rakefile +5 -33
- data/lib/hashie/rash.rb +26 -0
- data/lib/rash.rb +1 -28
- data/lib/rash/version.rb +3 -0
- data/rash.gemspec +11 -42
- data/spec/rash_spec.rb +16 -16
- data/spec/spec_helper.rb +2 -8
- metadata +46 -21
- data/VERSION +0 -1
- data/spec/spec.opts +0 -1
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,38 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "rash"
|
8
|
-
gem.summary = %Q{simple extension to Hashie::Mash for rubyified keys}
|
9
|
-
gem.description = %Q{simple extension to Hashie::Mash for rubyified keys, all keys are converted to underscore to eliminate horrible camelCasing}
|
10
|
-
gem.email = "tom.cocca@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/tcocca/rash"
|
12
|
-
gem.authors = ["tcocca"]
|
13
|
-
gem.add_dependency "hashie", ">= 0.4.0"
|
14
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'spec/rake/spectask'
|
23
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
-
spec.libs << 'lib' << 'spec'
|
25
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
spec.rcov = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :spec => :check_dependencies
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
35
6
|
|
7
|
+
task :test => :spec
|
36
8
|
task :default => :spec
|
37
9
|
|
38
10
|
require 'rake/rdoctask'
|
data/lib/hashie/rash.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
3
|
+
module Hashie
|
4
|
+
class Rash < Mash
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
def convert_key(key) #:nodoc:
|
9
|
+
underscore_string(key.to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
# converts a camel_cased string to a underscore string
|
13
|
+
# subs spaces with underscores, strips whitespace
|
14
|
+
# Same way ActiveSupport does string.underscore
|
15
|
+
def underscore_string(str)
|
16
|
+
str.to_s.strip.
|
17
|
+
gsub(' ', '_').
|
18
|
+
gsub(/::/, '/').
|
19
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
20
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
21
|
+
tr("-", "_").
|
22
|
+
downcase
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/rash.rb
CHANGED
@@ -1,28 +1 @@
|
|
1
|
-
require '
|
2
|
-
require 'hashie'
|
3
|
-
|
4
|
-
module Hashie
|
5
|
-
class Rash < Mash
|
6
|
-
|
7
|
-
protected
|
8
|
-
|
9
|
-
def convert_key(key) #:nodoc:
|
10
|
-
underscore_string(key.to_s)
|
11
|
-
end
|
12
|
-
|
13
|
-
# converts a camel_cased string to a underscore string
|
14
|
-
# subs spaces with underscores, strips whitespace
|
15
|
-
# Same way ActiveSupport does string.underscore
|
16
|
-
def underscore_string(str)
|
17
|
-
str.to_s.strip.
|
18
|
-
gsub(' ', '_').
|
19
|
-
gsub(/::/, '/').
|
20
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
21
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
22
|
-
tr("-", "_").
|
23
|
-
downcase
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
1
|
+
require 'hashie/rash'
|
data/lib/rash/version.rb
ADDED
data/rash.gemspec
CHANGED
@@ -1,58 +1,27 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rash/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = %q{rash}
|
8
|
-
s.version = "0.2.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
7
|
s.authors = ["tcocca"]
|
12
8
|
s.date = %q{2010-08-31}
|
13
9
|
s.description = %q{simple extension to Hashie::Mash for rubyified keys, all keys are converted to underscore to eliminate horrible camelCasing}
|
14
10
|
s.email = %q{tom.cocca@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/rash.rb",
|
27
|
-
"rash.gemspec",
|
28
|
-
"spec/rash_spec.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
11
|
s.homepage = %q{http://github.com/tcocca/rash}
|
33
12
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
13
|
s.rubygems_version = %q{1.3.5}
|
36
14
|
s.summary = %q{simple extension to Hashie::Mash for rubyified keys}
|
37
|
-
s.test_files = [
|
38
|
-
"spec/rash_spec.rb",
|
39
|
-
"spec/spec_helper.rb"
|
40
|
-
]
|
41
15
|
|
42
|
-
|
43
|
-
|
44
|
-
|
16
|
+
s.version = Rash::VERSION
|
17
|
+
s.platform = Gem::Platform::RUBY
|
18
|
+
|
19
|
+
s.add_dependency "hashie", '~> 1.0.0'
|
20
|
+
s.add_development_dependency "rspec", "~> 2.5.0"
|
45
21
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
s.add_dependency(%q<hashie>, [">= 0.4.0"])
|
51
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
52
|
-
end
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<hashie>, [">= 0.4.0"])
|
55
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
56
|
-
end
|
22
|
+
s.require_paths = ['lib']
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
57
26
|
end
|
58
27
|
|
data/spec/rash_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Hashie::Rash do
|
3
|
+
describe Hashie::Rash do
|
4
4
|
subject {
|
5
5
|
Hashie::Rash.new({
|
6
|
-
"varOne" => 1,
|
7
|
-
"two" => 2,
|
8
|
-
:three => 3,
|
9
|
-
:varFour => 4,
|
10
|
-
"fiveHumpHumps" => 5,
|
6
|
+
"varOne" => 1,
|
7
|
+
"two" => 2,
|
8
|
+
:three => 3,
|
9
|
+
:varFour => 4,
|
10
|
+
"fiveHumpHumps" => 5,
|
11
11
|
:nested => {
|
12
|
-
"NestedOne" => "One",
|
12
|
+
"NestedOne" => "One",
|
13
13
|
:two => "two",
|
14
14
|
"nested_three" => "three"
|
15
15
|
},
|
@@ -21,9 +21,9 @@ describe Hashie::Rash do
|
|
21
21
|
"trailing spaces " => "better safe than sorry"
|
22
22
|
})
|
23
23
|
}
|
24
|
-
|
24
|
+
|
25
25
|
it { should be_a(Hashie::Mash) }
|
26
|
-
|
26
|
+
|
27
27
|
it "should create a new rash where all the keys are underscored instead of camelcased" do
|
28
28
|
subject.var_one.should == 1
|
29
29
|
subject.two.should == 2
|
@@ -40,35 +40,35 @@ describe Hashie::Rash do
|
|
40
40
|
subject.spaced_key.should == "When would this happen?"
|
41
41
|
subject.trailing_spaces.should == "better safe than sorry"
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "should allow camelCased accessors" do
|
45
45
|
subject.varOne.should == 1
|
46
46
|
subject.varOne = "once"
|
47
47
|
subject.varOne.should == "once"
|
48
48
|
subject.var_one.should == "once"
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should allow camelCased accessors on nested hashes" do
|
52
52
|
subject.nested.nestedOne.should == "One"
|
53
53
|
subject.nested.nestedOne = "once"
|
54
54
|
subject.nested.nested_one.should == "once"
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should merge well with a Mash" do
|
58
58
|
subject.update Hashie::Mash.new(
|
59
59
|
:nested => {:fourTimes => "a charm"},
|
60
60
|
:nested3 => {:helloWorld => "hi"}
|
61
61
|
)
|
62
|
-
|
62
|
+
|
63
63
|
subject.nested.four_times.should == "a charm"
|
64
64
|
subject.nested.fourTimes.should == "a charm"
|
65
65
|
subject.nested3.hello_world.should == "hi"
|
66
66
|
subject.nested3.helloWorld.should == "hi"
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "should allow initializing reader" do
|
70
70
|
subject.nested3!.helloWorld = "hi"
|
71
71
|
subject.nested3.hello_world.should == "hi"
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'rash'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
1
|
+
require File.expand_path('../../lib/rash', __FILE__)
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
3
|
+
require 'rspec'
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- tcocca
|
@@ -14,44 +20,57 @@ default_executable:
|
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: hashie
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
|
-
- -
|
27
|
+
- - ~>
|
22
28
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 1.0.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: rspec
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
|
-
- -
|
43
|
+
- - ~>
|
32
44
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
45
|
+
hash: 27
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 5
|
49
|
+
- 0
|
50
|
+
version: 2.5.0
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
35
53
|
description: simple extension to Hashie::Mash for rubyified keys, all keys are converted to underscore to eliminate horrible camelCasing
|
36
54
|
email: tom.cocca@gmail.com
|
37
55
|
executables: []
|
38
56
|
|
39
57
|
extensions: []
|
40
58
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
43
|
-
- README.rdoc
|
59
|
+
extra_rdoc_files: []
|
60
|
+
|
44
61
|
files:
|
45
62
|
- .document
|
46
63
|
- .gitignore
|
64
|
+
- .rspec
|
65
|
+
- Gemfile
|
47
66
|
- LICENSE
|
48
67
|
- README.rdoc
|
49
68
|
- Rakefile
|
50
|
-
-
|
69
|
+
- lib/hashie/rash.rb
|
51
70
|
- lib/rash.rb
|
71
|
+
- lib/rash/version.rb
|
52
72
|
- rash.gemspec
|
53
73
|
- spec/rash_spec.rb
|
54
|
-
- spec/spec.opts
|
55
74
|
- spec/spec_helper.rb
|
56
75
|
has_rdoc: true
|
57
76
|
homepage: http://github.com/tcocca/rash
|
@@ -63,21 +82,27 @@ rdoc_options:
|
|
63
82
|
require_paths:
|
64
83
|
- lib
|
65
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
66
86
|
requirements:
|
67
87
|
- - ">="
|
68
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
69
92
|
version: "0"
|
70
|
-
version:
|
71
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
72
95
|
requirements:
|
73
96
|
- - ">="
|
74
97
|
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
75
101
|
version: "0"
|
76
|
-
version:
|
77
102
|
requirements: []
|
78
103
|
|
79
104
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.4.2
|
81
106
|
signing_key:
|
82
107
|
specification_version: 3
|
83
108
|
summary: simple extension to Hashie::Mash for rubyified keys
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|