code_terminator 0.4.11 → 0.4.12

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: 9b76dd452042adda33c441f4a7e84c6dcb1d5f26
4
- data.tar.gz: 20d8fcaee74dc97e05af018c83e5776d85eaed70
3
+ metadata.gz: 847ca2a1c19db2b0e2d79d447836878f9725b9eb
4
+ data.tar.gz: 2f1f1be2cd538ffc884d6754275201aab30af77a
5
5
  SHA512:
6
- metadata.gz: 74548c5bbfd5d923759db75f972f727e286b3f778ea86d392fd8816021dfb3a0266560c864499dc95558a0d1a30e289c7d7e1df7424ce1d8ac3e41b9e813d677
7
- data.tar.gz: 0f3cf3d0e45ab2765274601f337e583ac49939e245dfd4abafb88c2ec8b1896123d4f873aa337b78422c22500a16f10fdf6ce7cae989000a8b7422c7d554a860
6
+ metadata.gz: 1586c71b4e2cfdfeef009493894143cf6cf26caa54872b78c1ee7f380bfc26e555e9ce5aa387acc82aae33d27646d98b90a63c1253c1e706470213f5646ef173
7
+ data.tar.gz: 208ca278235f28a3a7cc854f7c3fa9391776d0bd8f9be88e901e591a5e6008a92ea903a2fa8706a8291bba9de0db80afdf33b42ce77495bd356c536c8846b655
@@ -48,49 +48,72 @@ class CodeTerminator::Html
48
48
 
49
49
  def get_elements(source)
50
50
  @elements = Array.new
51
+ #How to read if is an url
51
52
  if @source_type == "url"
52
53
  reader = Nokogiri::HTML(open(source).read)
53
54
  else
54
55
  reader = Nokogiri::HTML(File.open(source))
55
56
  end
57
+ #remove empty spaces from reader
56
58
  reader = remove_empty_text(reader)
59
+ node = Hash.new
60
+ node[:parent] = ""
61
+ node[:tag] = "html"
62
+ @elements << node
63
+
64
+ #search elements from body section
57
65
  if !reader.at('body').nil?
66
+ node = Hash.new
67
+ node[:parent] = "html"
68
+ node[:tag] = "body"
69
+ @elements << node
70
+
58
71
  reader.at('body').attribute_nodes.each do |element_attribute|
72
+ node = Hash.new
59
73
  node[:parent] = "html"
60
74
  node[:tag] = "body"
61
75
  node[:attribute] = element_attribute.name if !element_attribute.name.nil?
62
76
  node[:value] = element_attribute.value if !element_attribute.value.nil?
63
77
  @elements << node
64
78
  end
65
- end
79
+ end
80
+ #end search
66
81
 
82
+ #search elements from head section
67
83
  if !reader.at('head').nil?
68
- reader.at('head').children.each do |child|
69
- if child.attribute_nodes.empty?
70
- node = Hash.new
71
- node[:parent] = "head"
72
- node[:tag] = child.name
73
- node[:content] = child.text if !child.text.nil?
74
- @elements << node
75
- else
76
- child.attribute_nodes.each do |element_attribute|
77
- node = Hash.new
78
- node[:parent] = "head"
79
- if child.name == "#cdata-section"
80
- node[:tag] = "text"
81
- else
82
- node[:tag] = child.name
83
- end
84
- # node[:tag] = ( ? "text", child.name)
85
- node[:content] = child.text if !child.text.nil?
86
- node[:attribute] = element_attribute.name if !element_attribute.name.nil?
87
- node[:value] = element_attribute.value if !element_attribute.value.nil?
88
- @elements << node
89
- end
90
- end
91
- add_children(child) if child.children.any?
92
- end
84
+ node = Hash.new
85
+ node[:parent] = "html"
86
+ node[:tag] = "head"
87
+ @elements << node
88
+ reader.at('head').children.each do |child|
89
+ if child.attribute_nodes.empty?
90
+ node = Hash.new
91
+ node[:parent] = "head"
92
+ node[:tag] = child.name
93
+ node[:content] = child.text if !child.text.nil?
94
+ @elements << node
95
+ else
96
+ child.attribute_nodes.each do |element_attribute|
97
+ node = Hash.new
98
+ node[:parent] = "head"
99
+ if child.name == "#cdata-section"
100
+ node[:tag] = "text"
101
+ else
102
+ node[:tag] = child.name
103
+ end
104
+ # node[:tag] = ( ? "text", child.name)
105
+ node[:content] = child.text if !child.text.nil?
106
+ node[:attribute] = element_attribute.name if !element_attribute.name.nil?
107
+ node[:value] = element_attribute.value if !element_attribute.value.nil?
108
+ @elements << node
109
+ end
110
+ end
111
+ add_children(child) if child.children.any?
112
+ end
93
113
  end
114
+ #end search elements
115
+
116
+ #search elements inside body (children)
94
117
  if !reader.at('body').nil?
95
118
  reader.at('body').children.each do |child|
96
119
  if child.attribute_nodes.empty?
@@ -112,6 +135,8 @@ class CodeTerminator::Html
112
135
  add_children(child) if child.children.any?
113
136
  end
114
137
  end
138
+ #end search elements
139
+
115
140
  @elements
116
141
  end
117
142
 
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.4.11"
2
+ VERSION = "0.4.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_terminator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evelin Ponce
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler