xml_parser 0.3.2 → 0.3.3

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: 98a5fc0719d620a1f7778f325fa84790bddebd1b
4
- data.tar.gz: aa967cb4fa2a611211a5d53daee4ddba4427e3a2
3
+ metadata.gz: 4b96b2cc750d00075521029a293cfe21e34e0bb5
4
+ data.tar.gz: 952758a9f2ccc3c21b74baf96515c825bc2ecfc0
5
5
  SHA512:
6
- metadata.gz: 911cd14d34160dc528fa5e3992d57c3effe48270858d8f6caf610ab744b63faaec8cb1b49d44116f2c6c7b5bb63930eef0b2dee24eddf957b31dba87537f94df
7
- data.tar.gz: 24354755fe0d9d5828c6604a19ae8cf9dad973bf219dcd6f6a6828ba7a45fcc28f8715f98d651cfec08919954848457065465308fdfe91316ae0084ef754278c
6
+ metadata.gz: 86a3dac02129d5dc96466a128679d0b098d0ee151563f7e8aef5b28e1289cea54c0249a9022ab6dbe5d895b282b77a7d084bb99330b96eb43e8888b119e1b675
7
+ data.tar.gz: c33623fbd341dde8f6a24f60ea48b5c41073f10a6bd71167ed0463c55d467232d662e4378749d2c15caefa4e6a0e226a1dc5fb0be8df311511543b0beac080dc
data/README.md CHANGED
@@ -39,8 +39,10 @@ match_values = doc.xpath_map("/sample/test/@name") { |elm|
39
39
  puts elm
40
40
  }
41
41
 
42
- # parse xml from yaml file
43
- doc = XmlParser::Document.from_yml("/var/home/hoge.yml", "root_element_name", "default_attr_name")
42
+ # parse xml from yaml file.
43
+ # initialize from yaml string, use XmlParser::Document.from_yml method.
44
+ # only yaml of the hash form is dealing.
45
+ doc = XmlParser::Document.from_yml_file("/var/home/hoge.yml", "root_element_name", "default_attr_name")
44
46
 
45
47
  # parse xml from hash
46
48
  doc = XmlParser::Document.from_hash({a: "v1", b: "v2"}, "root_element_name", "default_attr_name")
@@ -91,12 +91,25 @@ module XmlParser
91
91
  XmlParser::Document.new(xml_str)
92
92
  end
93
93
 
94
+ # initialize from yml string.
95
+ # @param [String] yml_string yaml string.
96
+ # @param [String] root_name root element name
97
+ # @param [String] attr_name attribute name
98
+ # @return [XmlParser::Document] parser
99
+ def self.from_yml(yml_string, root_name="root", attr_name="value")
100
+
101
+ # load yml string.
102
+ yml = YAML.load(yml_string)
103
+ # parse to xml.
104
+ parse_xml_from_hash(yml, root_name, attr_name)
105
+ end
106
+
94
107
  # initialize from yml file.
95
108
  # @param [String] filepath read yml filepath. absolute.
96
109
  # @param [String] root_name root element name
97
110
  # @param [String] attr_name attribute name
98
111
  # @return [XmlParser::Document] parser
99
- def self.from_yml(filepath, root_name="root", attr_name="value")
112
+ def self.from_yml_file(filepath, root_name="root", attr_name="value")
100
113
 
101
114
  # load yml file.
102
115
  yml = YAML.load_file(filepath)
@@ -1,3 +1,3 @@
1
1
  module XmlParser
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - h.shigemoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler