xml-mapping_extensions 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58fe30758a9f3eee417329e21e489a1fcb05cee3
4
- data.tar.gz: 5ce03257e351534e12cd07bbe7c0ccfa6e4e5689
3
+ metadata.gz: 6974aa25a580ab47d6ffc41468fe2afb54c6ad91
4
+ data.tar.gz: 4fd09884318b53fdbdf1f3de954fbe87677e867a
5
5
  SHA512:
6
- metadata.gz: 470de71e5c996ec025d632218bb7f4a626f22362bcf345dd079b8107a6f3053a9868de32efd7b9283c0cf8ef660f3a4010a2b9fb8d01b40c7066b28fcfd114c6
7
- data.tar.gz: 0747764d15df2ce7c9441985b6417f071e718c955e69959651295ea7a82302ad127612d71f92a8e0ee2f5c7390613b0dfea55f9bc9c77fb97cbe364ba76ffc66
6
+ metadata.gz: 54d02c4c2bbae8388b21956cdc68f7183e100c321c3eb38ae3c54c597308fe6969d20e296aac0375eea25a886565e120eec9b815c72cfa1ad1ca4e5c7f27329d
7
+ data.tar.gz: bb25f1d1b4de7cdf86d8110a2b1264f4b8f31fa83058418a4c3743ff7499160764c7377dd47222a76f754a6c8131d3dfad249bd0f6ab921ccfad50db35e0f5ec
data/.gitignore CHANGED
@@ -15,15 +15,9 @@
15
15
  *.a
16
16
  mkmf.log
17
17
 
18
- # Rails engine
18
+ # Gem
19
19
 
20
- .bundle/
21
- log/*.log
22
- spec/dummy/db/*.sqlite3
23
- spec/dummy/db/*.sqlite3-journal
24
- spec/dummy/log/*.log
25
- spec/dummy/tmp/
26
- spec/dummy/.sass-cache
20
+ xml-mapping_extensions*gem
27
21
 
28
22
  # IntellJ
29
23
 
@@ -39,4 +33,4 @@ spec/dummy/.sass-cache
39
33
 
40
34
  # Mac OS
41
35
 
42
- .DS_Store
36
+ .DS_Store
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.0 (16 November 2015)
2
+
3
+ - Fixed `EnumNodeBase` to correctly parse string values as enum instances,
4
+ and to correctly map enum instances to string values.
5
+ (See [ruby-enum issue #6](https://github.com/dblock/ruby-enum/issues/6).)
6
+
1
7
  ## 0.1.1 (24 September 2015)
2
8
 
3
9
  - Added support for UTC "Zulu" time designator to `DateNode`
data/example.rb CHANGED
@@ -50,6 +50,4 @@ xml = elem.save_to_xml
50
50
  formatter = REXML::Formatters::Pretty.new
51
51
  formatter.compact = true
52
52
 
53
- puts(formatter.write(xml, ""))
54
-
55
-
53
+ puts(formatter.write(xml, ''))
@@ -16,7 +16,13 @@ module XML
16
16
 
17
17
  def to_value(xml_text)
18
18
  enum_class = self.class::ENUM_CLASS
19
- enum_class.parse(xml_text)
19
+ enum_class.map do |_, enum|
20
+ return enum if enum.value == xml_text
21
+ end
22
+ end
23
+
24
+ def to_xml_text(value)
25
+ value.value
20
26
  end
21
27
 
22
28
  end
@@ -1,6 +1,6 @@
1
1
  module XML
2
2
  module MappingExtensions
3
3
  # The version of this gem
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
@@ -8,6 +8,7 @@ module XML
8
8
 
9
9
  define :FOO, 'foo'
10
10
  define :BAR, 'bar'
11
+ define :BAZ_QUX, 'baz_qux'
11
12
  end
12
13
 
13
14
  class MyEnumNode < EnumNodeBase
@@ -39,11 +40,15 @@ module XML
39
40
  end
40
41
 
41
42
  it 'parses an enum value' do
42
- expect(to_my_enum('foo')).to eq(MyEnum::FOO)
43
+ MyEnum.map do |_, enum|
44
+ expect(to_my_enum(enum.value)).to eq(enum)
45
+ end
43
46
  end
44
47
 
45
48
  it 'transforms an enum to a string' do
46
- expect(to_text(MyEnum::BAR)).to eq('bar')
49
+ MyEnum.map do |_, enum|
50
+ expect(to_text(enum)).to eq(enum.value)
51
+ end
47
52
  end
48
53
 
49
54
  it 'parses a missing value as nil' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-mapping_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  requirements: []
206
206
  rubyforge_project:
207
- rubygems_version: 2.4.8
207
+ rubygems_version: 2.4.6
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: Some extensions for for XML::Mapping