setsumei 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,10 @@ module Setsumei
3
3
  class Key
4
4
  def Key.for(name,options = { given: [name] } )
5
5
  possible_keys = options[:given]
6
- lower_camel_case(name,possible_keys) || at_symbol_case(name,possible_keys) || upper_camel_case(name,possible_keys)
6
+ direct(name,possible_keys) || lower_camel_case(name,possible_keys) || at_symbol_case(name,possible_keys) || upper_camel_case(name,possible_keys)
7
+ end
8
+ def Key.direct name, keys = nil
9
+ return_if name.to_s, in: keys
7
10
  end
8
11
  def Key.lower_camel_case name, keys = nil
9
12
  lower_camel_case = name.to_s.gsub(/_[a-zA-Z]/) { |a| a[1].upcase }
@@ -1,3 +1,3 @@
1
1
  module Setsumei
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -8,6 +8,11 @@ module Setsumei
8
8
 
9
9
  subject { Key.for :attribute_name, given: hash_keys }
10
10
 
11
+ specify do
12
+ hash_keys.concat ["AttributeName", "attributeName", "@attributeName","attribute_name"]
13
+ subject.should == "attribute_name"
14
+ end
15
+
11
16
  specify do
12
17
  hash_keys.concat ["AttributeName", "attributeName", "@attributeName"]
13
18
  subject.should == "attributeName"
@@ -24,6 +29,27 @@ module Setsumei
24
29
  end
25
30
  end
26
31
 
32
+ describe "direct(name,keys)" do
33
+ let(:name) { 'attribute_name' }
34
+ let(:keys) { [] }
35
+
36
+ subject { Key.direct :attribute_name, keys }
37
+
38
+ it "should return name when keys contain name" do
39
+ keys << name
40
+ subject.should == name
41
+ end
42
+ it "should return nil when keys do not contain name" do
43
+ subject.should be_nil
44
+ end
45
+
46
+ context "keys are ommited" do
47
+ it "should return name" do
48
+ Key.direct(:attribute_name).should == "attribute_name"
49
+ end
50
+ end
51
+ end
52
+
27
53
  describe "lower_camel_case(name,keys)" do
28
54
  let(:keys) { [] }
29
55
 
metadata CHANGED
@@ -1,72 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: setsumei
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
4
5
  prerelease:
5
- version: 0.0.9
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Jon Rowe
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-16 00:00:00 +01:00
12
+ date: 2011-07-18 00:00:00.000000000 +01:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: json
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2161615340 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
25
23
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
24
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2161615340
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &2161614920 !ruby/object:Gem::Requirement
31
29
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
36
34
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: autotest-standalone
40
35
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2161614920
37
+ - !ruby/object:Gem::Dependency
38
+ name: autotest-standalone
39
+ requirement: &2161614500 !ruby/object:Gem::Requirement
42
40
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
47
45
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: ruby-debug19
51
46
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2161614500
48
+ - !ruby/object:Gem::Dependency
49
+ name: ruby-debug19
50
+ requirement: &2161614080 !ruby/object:Gem::Requirement
53
51
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
58
56
  type: :development
59
- version_requirements: *id004
60
- description: A tool for describing API's as ruby objects. Currently supports building these objects from JSON
61
- email:
57
+ prerelease: false
58
+ version_requirements: *2161614080
59
+ description: A tool for describing API's as ruby objects. Currently supports building
60
+ these objects from JSON
61
+ email:
62
62
  - hello@jonrowe.co.uk
63
63
  executables: []
64
-
65
64
  extensions: []
66
-
67
65
  extra_rdoc_files: []
68
-
69
- files:
66
+ files:
70
67
  - .gitignore
71
68
  - .rspec
72
69
  - Gemfile
@@ -105,32 +102,29 @@ files:
105
102
  has_rdoc: true
106
103
  homepage: https://github.com/JonRowe/setsumei
107
104
  licenses: []
108
-
109
105
  post_install_message:
110
106
  rdoc_options: []
111
-
112
- require_paths:
107
+ require_paths:
113
108
  - lib
114
- required_ruby_version: !ruby/object:Gem::Requirement
109
+ required_ruby_version: !ruby/object:Gem::Requirement
115
110
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: "0"
120
- required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
116
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
126
121
  requirements: []
127
-
128
122
  rubyforge_project:
129
123
  rubygems_version: 1.6.2
130
124
  signing_key:
131
125
  specification_version: 3
132
126
  summary: A tool for describing API's as ruby objects
133
- test_files:
127
+ test_files:
134
128
  - spec/setsumei/build/key_spec.rb
135
129
  - spec/setsumei/build_spec.rb
136
130
  - spec/setsumei/describable/boolean_attribute_spec.rb