xml_parser 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a95b2b27cfa5f5ab70441e1a2b7ab0b7cd7c6bee
4
- data.tar.gz: 0b1a426678e054a71e0635ca88760001492bde05
3
+ metadata.gz: 6d6516f5dde191fe52f58147ee8a8333faea0abd
4
+ data.tar.gz: e529124eecaeccb34f653cdab202889f61ac5572
5
5
  SHA512:
6
- metadata.gz: 945b5b59de0c90d40f324e4b4cf502bb47ae677bea17e68a8fdcf78fa97c9e47dfaf40e826d704e9a31e9ab60e5af9fd97c9db83cde9788baf9ab1f65b3b23bc
7
- data.tar.gz: 9b64de0d372f70d3afa275e3c97e83daed57944817afd6c3fbf432c874f837b84082fd67f26c7c0cbc0f1d9d5f049af1d4db27c1def07e8e54e482d2467973e0
6
+ metadata.gz: e05aae54a7607a93820e1895feac7d176b5214c32984e7f9c1a3977ead5fc54ee319b964b38c912967f15f90b8038a58bc91262a68f6ff28e9f374c95bdcb2b7
7
+ data.tar.gz: bf827d10eb6b6fa9dd89309c89b6ff4f63d800330db63b313adf3cfe2b3b2adfc116efc14055bcd08ac0f1799a4c37a55b98527aceb4e654a47da0fe07e29ff9
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xml_parser`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
5
  Parse Xml Document and String.
6
- Now, Parse String method only.
6
+ From String, and File.
7
7
 
8
8
  ## Installation
9
9
 
@@ -10,6 +10,7 @@ module XmlParser
10
10
  # constructor.
11
11
  # @param [String] xml_str xml string.
12
12
  def initialize(xml_str)
13
+
13
14
  @doc = REXML::Document.new(xml_str)
14
15
  end
15
16
 
@@ -42,6 +43,18 @@ module XmlParser
42
43
  }
43
44
  end
44
45
 
46
+ # xml decl info.
47
+ # @return [REXML::XMLDecl] xml decl
48
+ def decl
49
+ @doc.xml_decl
50
+ end
51
+
52
+ # get document.
53
+ # @return [REXML::Document] document
54
+ def document
55
+ @doc
56
+ end
57
+
45
58
  # initialize from File.
46
59
  # @param [String] filepath read fileptah. absolute.
47
60
  # @return [XmlParser::Document] parser.
@@ -8,31 +8,37 @@ module XmlParser
8
8
 
9
9
  # normalize string.
10
10
  # @param [String] str target string.
11
- # @param [REXML:DocType] doctype document type.
11
+ # @param [REXML::DocType] doctype document type.
12
12
  # @param [Array] filter entity filter.
13
13
  # @return [String] normalize string.
14
14
  def self.normalize(str, doctype=nil, filter=nil)
15
15
 
16
- # normalize.
17
16
  REXML::Text.normalize(str, doctype, filter)
18
17
  end
19
18
 
20
19
  # normalize string array.
21
20
  # @param [Array] strs target string array.
22
- # @param [REXML:DocType] doctype document type.
21
+ # @param [REXML::DocType] doctype document type.
23
22
  # @param [Array] filter entity filter.
24
23
  # @return [Array] normalize string array.
25
24
  def self.multi_normalize(strs, doctype=nil, filter=nil)
26
25
 
27
26
  # multi string normalize.
28
27
  strs.map { |str|
29
- normalize(str, doctype, filter)
28
+ value = normalize(str, doctype, filter)
29
+
30
+ # if block_given?, do block process.
31
+ if block_given?
32
+ yield value
33
+ else
34
+ value
35
+ end
30
36
  }
31
37
  end
32
38
 
33
39
  # unnormalize string.
34
40
  # @param [String] str target string.
35
- # @param [REXML:DocType] doctype document type.
41
+ # @param [REXML::DocType] doctype document type.
36
42
  # @param [Array] filter entity filter.
37
43
  # @return [String] unnormalize string.
38
44
  def self.unnormalize(str, doctype=nil, filter=nil)
@@ -42,13 +48,21 @@ module XmlParser
42
48
 
43
49
  # unnormalize string array.
44
50
  # @param [Array] strs target string array.
45
- # @param [REXML:DocType] doctype document type.
51
+ # @param [REXML::DocType] doctype document type.
46
52
  # @param [Array] filter entity filter.
47
53
  # @return [Array] unnormalize string array.
48
54
  def self.multi_unnormalize(strs, doctype=nil, filter=nil)
49
55
 
56
+ # multi string unnormalize.
50
57
  strs.map { |str|
51
- unnormalize(str, doctype, filter)
58
+ value = unnormalize(str, doctype, filter)
59
+
60
+ # if block_given?, do block process.
61
+ if block_given?
62
+ yield value
63
+ else
64
+ value
65
+ end
52
66
  }
53
67
  end
54
68
  end
@@ -1,3 +1,3 @@
1
1
  module XmlParser
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/xml_parser.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["corporation.ore@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Parse Xml Document and String.}
13
- spec.description = %q{Parse Xml Document and String.Now, Parse String method only.}
13
+ spec.description = %q{Parse Xml Document and String.From String, and File.}
14
14
  spec.homepage = "https://github.com/h-shigemoto/xml_parser"
15
15
  spec.license = "MIT"
16
16
 
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.2.0
4
+ version: 0.2.1
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-21 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: Parse Xml Document and String.Now, Parse String method only.
55
+ description: Parse Xml Document and String.From String, and File.
56
56
  email:
57
57
  - corporation.ore@gmail.com
58
58
  executables: []