arboretum 0.0.4 → 0.0.5
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 +4 -4
- data/lib/arboretum/doctree.rb +6 -0
- data/lib/arboretum/scandent.rb +4 -4
- data/lib/arboretum/xml.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d56161149a6eda21e434c732c103c4ac08151cbd
|
4
|
+
data.tar.gz: e539ed1220aa196f007baa50c9bc053230c7b2fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c885a0ba1c59e55cb2cad5375dc8007d5ae8200021a5a105e8e942c34d0829fb2b88c7b4214be04b6bf608a8e040555c2b2d724661c99a9b07c1ccec2255dc8b
|
7
|
+
data.tar.gz: f03ceac44a40dfdbbdef468792c9780dac288305ceb71b9e23577580d1f71ed3d141a984c38f4889e55b82d400588e4c1733727aeebc655c49db11f64d671cb7
|
data/lib/arboretum/doctree.rb
CHANGED
@@ -1279,6 +1279,12 @@ module Arboretum
|
|
1279
1279
|
@group
|
1280
1280
|
end
|
1281
1281
|
|
1282
|
+
def text_string
|
1283
|
+
full_string = ''
|
1284
|
+
@group.each {|element| full_string << element.text_string}
|
1285
|
+
full_string
|
1286
|
+
end
|
1287
|
+
|
1282
1288
|
def +(other)
|
1283
1289
|
ElementGroup.new(self.group + other.group)
|
1284
1290
|
end
|
data/lib/arboretum/scandent.rb
CHANGED
@@ -66,15 +66,15 @@ module Arboretum
|
|
66
66
|
|
67
67
|
def initialize(steps=[])
|
68
68
|
# Make sure that the listener stems from the root element
|
69
|
-
if !steps
|
70
|
-
if steps
|
69
|
+
if !steps.first.nil? and steps.first.element_ref != :ELEMENT_ROOT
|
70
|
+
if steps.first.element_ref.nil?
|
71
71
|
implied_step = [
|
72
72
|
[:T_TILDE, '~', :STATE_ROOT_PATH],
|
73
73
|
[:T_SLASH2, '//', :STATE_ROOT_PATH]
|
74
74
|
]
|
75
75
|
steps.unshift(Parser.parse_step_tokens(implied_step, :PATH_LISTENER))
|
76
|
-
|
77
|
-
steps
|
76
|
+
elsif steps.first.element_ref == :ELEMENT_SELF
|
77
|
+
steps.first.element_ref = :ELEMENT_ROOT
|
78
78
|
end
|
79
79
|
end
|
80
80
|
# Make sure there are no misplaced :ELEMENT_SELF references
|
data/lib/arboretum/xml.rb
CHANGED
@@ -12,9 +12,10 @@ module Arboretum
|
|
12
12
|
|
13
13
|
class ArboretumIO
|
14
14
|
def self.read(file_path, style: :clean, type: :auto)
|
15
|
+
origin_file = caller_locations.first.absolute_path[0..(caller_locations.first.absolute_path.rindex(/\/.+\..+/))]
|
15
16
|
sax_parser = ArboretumSax.new(style)
|
16
17
|
type = file_path[(file_path.rindex(/\..+/))+1..-1].to_sym if type == :auto
|
17
|
-
File.open(file_path, 'r') do |f|
|
18
|
+
File.open(origin_file+file_path, 'r') do |f|
|
18
19
|
case type
|
19
20
|
when :xml, :xhtml
|
20
21
|
Ox.sax_parse(sax_parser, f, :skip => :skip_off)
|
@@ -29,12 +30,13 @@ module Arboretum
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def self.write(tree, file_path, style: :pretty, type: :auto)
|
33
|
+
origin_file = caller_locations.first.absolute_path[0..(caller_locations.first.absolute_path.rindex(/\/.+\..+/))]
|
32
34
|
type = file_path[(file_path.rindex(/\..+/))+1..-1].to_sym if type == :auto
|
33
35
|
if ![:xml, :xhtml, :html].include?(type)
|
34
36
|
puts "Warning: Invalid file type `#{type}` given for write. Using `:xml` instead..."
|
35
37
|
type = :xml
|
36
38
|
end
|
37
|
-
File.open(file_path, 'w') do |f|
|
39
|
+
File.open(origin_file+file_path, 'w') do |f|
|
38
40
|
f.write(tree.dump_markup(style, type))
|
39
41
|
end
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arboretum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tomjw64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ox
|