flammarion-utils 0.1.14 → 0.2.0
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.
- data/bin/xml-explorer +66 -0
- metadata +22 -4
data/bin/xml-explorer
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'flammarion'
|
3
|
+
require 'oga'
|
4
|
+
|
5
|
+
x = Oga.parse_xml(ARGF)
|
6
|
+
|
7
|
+
$f = Flammarion::Engraving.new
|
8
|
+
def f; $f; end;
|
9
|
+
|
10
|
+
def node_window; f.pane("nodewindow", weight: 0.85); end
|
11
|
+
|
12
|
+
def history_window; f.pane("history", weight: 0.15);end
|
13
|
+
|
14
|
+
history_window
|
15
|
+
node_window
|
16
|
+
|
17
|
+
f.orientation = :horizontal
|
18
|
+
|
19
|
+
f.pane("default").hide
|
20
|
+
|
21
|
+
module Oga
|
22
|
+
module XML
|
23
|
+
module Traversal
|
24
|
+
def element_children
|
25
|
+
children.select{|c| c.is_a? Element}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
class Document
|
29
|
+
def parent; self; end
|
30
|
+
def attributes; []; end
|
31
|
+
def name; "Document"; end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_history(node)
|
37
|
+
history = [node]
|
38
|
+
history << history.last.parent until history.last.parent.is_a? Oga::XML::Document
|
39
|
+
history_window.clear
|
40
|
+
history.reverse.each do |n|
|
41
|
+
history_window.button("#{n.name} #{n.attributes.map(&:to_xml).join(" ")}") do
|
42
|
+
display(n)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_button(n)
|
48
|
+
node_window.subpane("buttons").button("#{n.name} #{n.attributes.map(&:to_xml).join(" ")}") do |c|
|
49
|
+
display(n)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def display(node)
|
54
|
+
add_history(node)
|
55
|
+
node_window.clear
|
56
|
+
node_window.markdown("# #{node.name}")
|
57
|
+
node_window.table node.attributes.map{|a| [a.name.to_s.light_magenta, a.value]}
|
58
|
+
node_window.input("CSS", history:true) do |m|
|
59
|
+
node_window.subpane("buttons").clear
|
60
|
+
node.css(m['text']).each {|n| add_button(n) }
|
61
|
+
end
|
62
|
+
node.element_children.each {|n| add_button(n) }
|
63
|
+
end
|
64
|
+
|
65
|
+
display(x.root_node.element_children.first)
|
66
|
+
f.wait_until_closed
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flammarion-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: flammarion
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,13 +26,30 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: oga
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: Extra tools using the Flammarion toolkit.
|
31
47
|
email: zach.geek@gmail.com
|
32
48
|
executables:
|
33
49
|
- fwrap
|
34
50
|
- slim-engrave
|
35
51
|
- flammarion-repl
|
52
|
+
- xml-explorer
|
36
53
|
- flammarion-services
|
37
54
|
- frake
|
38
55
|
- markdown-browser
|
@@ -46,6 +63,7 @@ files:
|
|
46
63
|
- bin/fwrap
|
47
64
|
- bin/slim-engrave
|
48
65
|
- bin/flammarion-repl
|
66
|
+
- bin/xml-explorer
|
49
67
|
- bin/flammarion-services
|
50
68
|
- bin/frake
|
51
69
|
- bin/markdown-browser
|