saxomattic 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/saxomattic.rb +3 -2
- data/lib/saxomattic/version.rb +1 -1
- data/saxomattic.gemspec +2 -1
- data/spec/saxomattic_spec.rb +22 -17
- metadata +62 -24
- checksums.yaml +0 -7
data/lib/saxomattic.rb
CHANGED
@@ -8,7 +8,8 @@ require "active_support/core_ext/string/conversions"
|
|
8
8
|
module Saxomattic
|
9
9
|
ACTIVE_ATTR_ATTRIBUTES = [
|
10
10
|
:default,
|
11
|
-
:type
|
11
|
+
:type,
|
12
|
+
:typecaster
|
12
13
|
].freeze
|
13
14
|
|
14
15
|
SAX_MACHINE_ATTRIBUTES = [
|
@@ -23,7 +24,7 @@ module Saxomattic
|
|
23
24
|
klass.extend(HookManagementMethods)
|
24
25
|
klass.__send__(:include, ::SAXMachine)
|
25
26
|
klass._capture_sax_machine_methods(klass)
|
26
|
-
# Keep these in this order as the initialize call in
|
27
|
+
# Keep these in this order as the initialize call in
|
27
28
|
# sax-machine doesn't `super` so we need it to be last in
|
28
29
|
klass.__send__(:include, ::ActiveAttr::Model)
|
29
30
|
klass._capture_active_attr_methods(klass)
|
data/lib/saxomattic/version.rb
CHANGED
data/saxomattic.gemspec
CHANGED
@@ -21,8 +21,9 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency "activesupport"
|
22
22
|
gem.add_dependency "sax-machine"
|
23
23
|
|
24
|
+
gem.add_development_dependency "nokogiri", ">= 1.6"
|
24
25
|
gem.add_development_dependency "pry"
|
25
26
|
gem.add_development_dependency "rake"
|
26
|
-
gem.add_development_dependency "rspec"
|
27
|
+
gem.add_development_dependency "rspec", ">= 3.4"
|
27
28
|
gem.add_development_dependency "simplecov"
|
28
29
|
end
|
data/spec/saxomattic_spec.rb
CHANGED
@@ -27,7 +27,7 @@ class SaxTesterSomething
|
|
27
27
|
|
28
28
|
attribute :baz
|
29
29
|
attribute :foo, :type => Integer
|
30
|
-
attribute :iso_8701, :
|
30
|
+
attribute :iso_8701, :typecaster => ActiveAttr::Typecasting::DateTypecaster.new
|
31
31
|
attribute :date, :type => Date
|
32
32
|
attribute :datetime, :type => DateTime
|
33
33
|
attribute :embedded, :elements => true, :class => SaxTesterEmbedded, :default => []
|
@@ -36,7 +36,7 @@ class SaxTesterSomething
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe ::Saxomattic do
|
39
|
-
|
39
|
+
let(:iso_8701) { "2013-01-13" }
|
40
40
|
let(:embedded_message) { "HERE!" }
|
41
41
|
let(:embedception_type) { "TYPE" }
|
42
42
|
let(:embedception_value) { "VALUE" }
|
@@ -46,7 +46,7 @@ describe ::Saxomattic do
|
|
46
46
|
<<-XML
|
47
47
|
<test>
|
48
48
|
<baz>#{baz}</baz>
|
49
|
-
<iso_8701
|
49
|
+
<iso_8701>#{iso_8701}</iso_8701>
|
50
50
|
<datetime>#{DateTime.now}</datetime>
|
51
51
|
<embedded>
|
52
52
|
<foo>2</foo>
|
@@ -71,39 +71,44 @@ describe ::Saxomattic do
|
|
71
71
|
subject { SaxTesterSomething.parse(xml) }
|
72
72
|
|
73
73
|
it "extracts elements when declared as attribute" do
|
74
|
-
subject.baz.
|
74
|
+
expect(subject.baz).to eq(baz)
|
75
75
|
end
|
76
76
|
|
77
77
|
context "TypeCasting" do
|
78
78
|
it "typecasts integers when declared with type => Integer" do
|
79
|
-
subject.foo.
|
79
|
+
expect(subject.foo).to eq(foo)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "typecasts Dates when declared with type => Date" do
|
83
|
-
subject.date.
|
84
|
-
subject.date.
|
83
|
+
expect(subject.date).to be_a(Date)
|
84
|
+
expect(subject.date).to eq(Date.today)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "typecasts Dates when declared with typecaster => ActiveAttr::Typecasting::DateTypecaster" do
|
88
|
+
expect(subject.iso_8701).to be_a(Date)
|
89
|
+
expect(subject.iso_8701).to eq(iso_8701.to_date)
|
85
90
|
end
|
86
91
|
|
87
92
|
it "embedded" do
|
88
|
-
subject.embedded.
|
89
|
-
subject.embedded.first.embed.
|
93
|
+
expect(subject.embedded).to be_a(Array)
|
94
|
+
expect(subject.embedded.first.embed).to eq(embedded_message)
|
90
95
|
end
|
91
96
|
|
92
97
|
it "typecasts embedded fields" do
|
93
|
-
subject.embedded.first.foo.
|
98
|
+
expect(subject.embedded.first.foo).to eq(foo)
|
94
99
|
end
|
95
100
|
|
96
101
|
it "embeds values further" do
|
97
|
-
subject.embedded.first.embedception
|
98
|
-
subject.embedded.first.embedception.type.
|
99
|
-
subject.embedded.first.embedception.value.
|
100
|
-
subject.embedded.first.embedception.not_even_used
|
102
|
+
expect(subject.embedded.first.embedception?).to be true
|
103
|
+
expect(subject.embedded.first.embedception.type).to eq(embedception_type)
|
104
|
+
expect(subject.embedded.first.embedception.value).to eq(embedception_value)
|
105
|
+
expect(subject.embedded.first.embedception.not_even_used?).to be false
|
101
106
|
end
|
102
107
|
|
103
108
|
it "extracts multiple children from a parent element" do
|
104
|
-
subject.children.size.
|
105
|
-
subject.children.first.name.
|
106
|
-
subject.children.last.name.
|
109
|
+
expect(subject.children.size).to eq 2
|
110
|
+
expect(subject.children.first.name).to eq "John"
|
111
|
+
expect(subject.children.last.name).to eq "Paul"
|
107
112
|
end
|
108
113
|
end
|
109
114
|
|
metadata
CHANGED
@@ -1,114 +1,145 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saxomattic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Brandon Dewitt
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-02-14 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: active_attr
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: activesupport
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: sax-machine
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: nokogiri
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.6'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.6'
|
55
78
|
- !ruby/object:Gem::Dependency
|
56
79
|
name: pry
|
57
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
58
82
|
requirements:
|
59
|
-
- - '>='
|
83
|
+
- - ! '>='
|
60
84
|
- !ruby/object:Gem::Version
|
61
85
|
version: '0'
|
62
86
|
type: :development
|
63
87
|
prerelease: false
|
64
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
65
90
|
requirements:
|
66
|
-
- - '>='
|
91
|
+
- - ! '>='
|
67
92
|
- !ruby/object:Gem::Version
|
68
93
|
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: rake
|
71
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
72
98
|
requirements:
|
73
|
-
- - '>='
|
99
|
+
- - ! '>='
|
74
100
|
- !ruby/object:Gem::Version
|
75
101
|
version: '0'
|
76
102
|
type: :development
|
77
103
|
prerelease: false
|
78
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
79
106
|
requirements:
|
80
|
-
- - '>='
|
107
|
+
- - ! '>='
|
81
108
|
- !ruby/object:Gem::Version
|
82
109
|
version: '0'
|
83
110
|
- !ruby/object:Gem::Dependency
|
84
111
|
name: rspec
|
85
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
86
114
|
requirements:
|
87
|
-
- - '>='
|
115
|
+
- - ! '>='
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
117
|
+
version: '3.4'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
93
122
|
requirements:
|
94
|
-
- - '>='
|
123
|
+
- - ! '>='
|
95
124
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
125
|
+
version: '3.4'
|
97
126
|
- !ruby/object:Gem::Dependency
|
98
127
|
name: simplecov
|
99
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
100
130
|
requirements:
|
101
|
-
- - '>='
|
131
|
+
- - ! '>='
|
102
132
|
- !ruby/object:Gem::Version
|
103
133
|
version: '0'
|
104
134
|
type: :development
|
105
135
|
prerelease: false
|
106
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
107
138
|
requirements:
|
108
|
-
- - '>='
|
139
|
+
- - ! '>='
|
109
140
|
- !ruby/object:Gem::Version
|
110
141
|
version: '0'
|
111
|
-
description: ' A gem to combine all the wonderful that is sax-machine with the magic
|
142
|
+
description: ! ' A gem to combine all the wonderful that is sax-machine with the magic
|
112
143
|
that is active_attr '
|
113
144
|
email:
|
114
145
|
- brandonsdewitt+saxomattic@gmail.com
|
@@ -128,26 +159,33 @@ files:
|
|
128
159
|
- spec/spec_helper.rb
|
129
160
|
homepage: https://github.com/abrandoned/saxomattic.git
|
130
161
|
licenses: []
|
131
|
-
metadata: {}
|
132
162
|
post_install_message:
|
133
163
|
rdoc_options: []
|
134
164
|
require_paths:
|
135
165
|
- lib
|
136
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
137
168
|
requirements:
|
138
|
-
- - '>='
|
169
|
+
- - ! '>='
|
139
170
|
- !ruby/object:Gem::Version
|
140
171
|
version: '0'
|
172
|
+
segments:
|
173
|
+
- 0
|
174
|
+
hash: -3127210426165399770
|
141
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
142
177
|
requirements:
|
143
|
-
- - '>='
|
178
|
+
- - ! '>='
|
144
179
|
- !ruby/object:Gem::Version
|
145
180
|
version: '0'
|
181
|
+
segments:
|
182
|
+
- 0
|
183
|
+
hash: -3127210426165399770
|
146
184
|
requirements: []
|
147
185
|
rubyforge_project:
|
148
|
-
rubygems_version:
|
186
|
+
rubygems_version: 1.8.24
|
149
187
|
signing_key:
|
150
|
-
specification_version:
|
188
|
+
specification_version: 3
|
151
189
|
summary: By including a module "Saxomattic" you can declare xml structured documents
|
152
190
|
with active_attr goodies
|
153
191
|
test_files:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: b12ac5bd1693fef3a04e55e1a4c3b6a5744187fb
|
4
|
-
data.tar.gz: a71d3a1ec6b984994816225eefd10b6a26d59392
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 2cb7dbfa427fe80d28dae02ecec9110d6d92fcd9a17cabb860b2afa3bcec2c9f8c4cb26c3465fcc16a4e0cda2254022c298de74c119b4eb4f8fec90c3f31503a
|
7
|
-
data.tar.gz: b1070ceb502984877161ca7337f91d82db6c0da159d6aebf4deb660d40e473673841e1d574903acbdcfa3ed429f0b25549334c2378f7cd03da902715e9ae3622
|