cot 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/cot/enum.rb +4 -0
- data/lib/cot/version.rb +1 -1
- data/spec/lib/cot/enum_spec.rb +26 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8903cd5e703422db57575411b464c7ec5b156a
|
4
|
+
data.tar.gz: 193b05ad13a36ac2d81a74637293e475c3a30ca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43371ff3f3487036d52a1a20b77124d2343d481086f28bf4fb66ca9931502e7c404bf9581eed999c0955cf5f15c22271e3e34fa9e859e6756e38a495a57a718a
|
7
|
+
data.tar.gz: cb310e1923f79143151107a448a209d839fadb669f07d816428740ecd157402209a81a80292795acce9eafd5c6504ffe3a84a834857d18543cb942e3715da10f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,7 @@ thingy = ExampleObject.new(id: :my_id, name: 'awesome name', createdOn: Time.now
|
|
39
39
|
thingy.id # 5
|
40
40
|
thingy.name # awesome name
|
41
41
|
ExampleObject.types.first # 1
|
42
|
+
ExampleObject.types[:third] # 3
|
42
43
|
thingy.types.fourth # 4
|
43
44
|
thingy.item # NestedClass instance
|
44
45
|
thingy.item.foo # 'this is nested.foo'
|
@@ -73,6 +74,7 @@ Frame provides some helpful methods:
|
|
73
74
|
- search\_property adds the parameter to the search mapping. It takes an optional from argument which inidates the property has an alternate key in the incoming/outgoing data.
|
74
75
|
- enum takes a name and a block
|
75
76
|
- Enums are defined on the instances and the class
|
77
|
+
- Enum defines a method for each entry and also allows readonly hash access
|
76
78
|
- The block expects a series of entries to be declared
|
77
79
|
- enum starts counting at 1 by default
|
78
80
|
- Each entry will have the value of 1 higher than the previous by default
|
data/lib/cot/enum.rb
CHANGED
data/lib/cot/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Cot::Enum do
|
3
|
+
before :each do
|
4
|
+
class TestObject < Cot::Frame
|
5
|
+
enum :types do
|
6
|
+
entry :first
|
7
|
+
entry :third, value: 3
|
8
|
+
entry :fourth
|
9
|
+
end
|
10
|
+
end
|
11
|
+
@foo = TestObject.new
|
12
|
+
end
|
13
|
+
subject(:enum) { @foo.types }
|
14
|
+
it 'defines methods for each entry' do
|
15
|
+
expect(enum.first).to eq 1
|
16
|
+
expect(enum.third).to eq 3
|
17
|
+
expect(enum.fourth).to eq 4
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'allows hash access' do
|
21
|
+
expect(enum).to respond_to :[]
|
22
|
+
expect(enum[:first]).to eq 1
|
23
|
+
expect(enum[:third]).to eq 3
|
24
|
+
expect(enum[:fourth]).to eq 4
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Henrich
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/cot/rspec/matchers.rb
|
137
137
|
- lib/cot/version.rb
|
138
138
|
- spec/lib/cot/collection_spec.rb
|
139
|
+
- spec/lib/cot/enum_spec.rb
|
139
140
|
- spec/lib/cot/frame_spec.rb
|
140
141
|
- spec/spec_helper.rb
|
141
142
|
homepage: http://github.com/crimsonknave/cot
|
@@ -164,5 +165,6 @@ specification_version: 4
|
|
164
165
|
summary: Simplifies creating models for rest based resources
|
165
166
|
test_files:
|
166
167
|
- spec/lib/cot/collection_spec.rb
|
168
|
+
- spec/lib/cot/enum_spec.rb
|
167
169
|
- spec/lib/cot/frame_spec.rb
|
168
170
|
- spec/spec_helper.rb
|