ruby3mf 0.1.7 → 0.1.8

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: 0005d2dc2997eb363b5ddf6843fa2e67f51b0e3e
4
- data.tar.gz: c0a75099c98df0e7dc9ed4f73b5c67d20ee333ba
3
+ metadata.gz: 28365afa35fee85496d68bd42bce1b2f2c8c9881
4
+ data.tar.gz: abb54781a8012d7526662ff118502f5ee55fa0f1
5
5
  SHA512:
6
- metadata.gz: 4aa121c5851a4b579aa261eda32712d0f3532b4529d95108b33ce4ff49e93fc43a1b33a9a0305d7b9912eaf1d6059cd7648abed1655cb40f78fc5b69ade391ae
7
- data.tar.gz: eb813c2f3f33a70bff2a38979ce0a46babc95f5365ee0dc2c55560eb17bed2d9d66e31bcc228278882d799de5f9b255edec8e8cbaa9b7dd65f2150763520fe00
6
+ metadata.gz: 73d47d9de40fda1e701f11452c6feab4c479a59798a23d439045ec7810fba6b43a2aa639b9f48c7c475d061524b8d71b0b3a316de851f9c3d8f2a24e8c82137a
7
+ data.tar.gz: ffd4f47c393311dba9c00d3aa78fb5aa1eaf2e128af72d28d4d724569064631e162409925fc9691c46045ba4cad402ab779ca4695e66d1bc9a0108daf4122e66
data/lib/ruby3mf.rb CHANGED
@@ -2,7 +2,6 @@ require_relative "ruby3mf/version"
2
2
  require_relative "ruby3mf/log3mf"
3
3
  require_relative "ruby3mf/document"
4
4
  require_relative "ruby3mf/content_types"
5
- require_relative "ruby3mf/hash"
6
5
  require_relative "ruby3mf/model3mf"
7
6
  require_relative "ruby3mf/relationships"
8
7
  require_relative "ruby3mf/thumbnail3mf"
@@ -17,7 +17,7 @@ require 'singleton'
17
17
  # end
18
18
  # end
19
19
  #
20
- # Log3mf.pp
20
+ # Log3mf.to_json
21
21
 
22
22
 
23
23
  class Log3mf
@@ -100,39 +100,24 @@ class Log3mf
100
100
  "#{doc_urls[spec]}#page=#{page}"
101
101
  end
102
102
 
103
- def to_json
103
+ def to_hash
104
104
  @log_list.collect { |ent|
105
105
  h = { context: ent[0], severity: ent[1], message: ent[2] }
106
106
  h[:spec_ref] = spec_link(ent[3][:spec], ent[3][:page]) if (ent[3] && ent[3][:page])
107
107
  h
108
- }.to_json
108
+ }
109
109
  end
110
110
 
111
- def self.to_json
112
- Log3mf.instance.to_json
111
+ def self.to_hash
112
+ Log3mf.instance.to_hash
113
113
  end
114
114
 
115
- # Pretty print our errors!
116
- def to_pp
117
- s = []
118
- s << "<i>Listing #{@log_list.size} log lines:</i>"
119
- longest_context = @log_list.collect { |logline| logline[0].size }.max
120
- longest_severity = @log_list.collect { |logline| logline[1].size }.max
121
-
122
- @log_list.each do |logline|
123
- msg = logline[2]
124
- if logline[3] && logline[3][:page]
125
- msg = "<a href=\"#{spec_link(logline[3][:spec], logline[3][:page])}\" target=\"_blank\">#{msg}</a>"
126
- end
127
- s << "[#{logline[0].ljust(longest_context)}] #{logline[1].to_s.upcase.ljust(longest_severity)} #{msg}"
128
- end
129
- s << "<br/>"
130
- s.map! { |row| row.include?("ERROR") ? "<b>#{row}</b>" : row }
131
- s.join("<br/>")
115
+ def to_json
116
+ to_hash.to_json
132
117
  end
133
118
 
134
- def self.to_pp
135
- Log3mf.instance.to_pp
119
+ def self.to_json
120
+ Log3mf.instance.to_json
136
121
  end
137
122
  end
138
123
 
@@ -1,3 +1,3 @@
1
1
  module Ruby3mf
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby3mf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Whitmarsh, Jeff Porter, and William Hertling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-28 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,7 +133,6 @@ files:
133
133
  - lib/ruby3mf.rb
134
134
  - lib/ruby3mf/content_types.rb
135
135
  - lib/ruby3mf/document.rb
136
- - lib/ruby3mf/hash.rb
137
136
  - lib/ruby3mf/log3mf.rb
138
137
  - lib/ruby3mf/model3mf.rb
139
138
  - lib/ruby3mf/relationships.rb
data/lib/ruby3mf/hash.rb DELETED
@@ -1,58 +0,0 @@
1
- # https://gist.github.com/huy/819999
2
- require 'nokogiri'
3
-
4
- class Hash
5
- class << self
6
- def from_xml(xml_doc)
7
- begin
8
- return { xml_doc.root.name.to_sym => xml_node_to_hash(xml_doc.root)}
9
- rescue Exception => e
10
- # raise your custom exception here
11
- end
12
- end
13
-
14
- def xml_node_to_hash(node)
15
- # If we are at the root of the document, start the hash
16
- if node.element?
17
- result_hash = {}
18
- if node.attributes != {}
19
- attributes = {}
20
- node.attributes.keys.each do |key|
21
- attributes[node.attributes[key].name.to_sym] = node.attributes[key].value
22
- end
23
- end
24
- if node.children.size > 0
25
- node.children.each do |child|
26
- result = xml_node_to_hash(child)
27
-
28
- if child.name == "text"
29
- unless child.next_sibling || child.previous_sibling
30
- return result unless attributes
31
- result_hash[child.name.to_sym] = result
32
- end
33
- elsif result_hash[child.name.to_sym]
34
-
35
- if result_hash[child.name.to_sym].is_a?(Object::Array)
36
- result_hash[child.name.to_sym] << result
37
- else
38
- result_hash[child.name.to_sym] = [result_hash[child.name.to_sym]] << result
39
- end
40
- else
41
- result_hash[child.name.to_sym] = result
42
- end
43
- end
44
- if attributes
45
- #add code to remove non-data attributes e.g. xml schema, namespace here
46
- #if there is a collision then node content supersets attributes
47
- result_hash = attributes.merge(result_hash)
48
- end
49
- return result_hash
50
- else
51
- return attributes
52
- end
53
- else
54
- return node.content.to_s
55
- end
56
- end
57
- end
58
- end