scaffold_parser 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb +20 -3
- data/lib/scaffold_parser/scaffolders/xsd/parser/handlers/klass.rb +10 -5
- data/lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb +2 -2
- data/lib/scaffold_parser/scaffolders/xsd/parser/handlers/module.rb +10 -5
- data/lib/scaffold_parser/scaffolders/xsd/parser/handlers/proxy_list_method.rb +2 -2
- data/lib/scaffold_parser/scaffolders/xsd/parser/handlers/submodel_method.rb +2 -2
- data/scaffold_parser.gemspec +7 -6
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96091a0980204269f8a932357cb225cd1d2d9ae8
|
4
|
+
data.tar.gz: 7ab015075a04be35f3199cfd399b6b14747b1bdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df55b57182decf235dca79704cef3238b60330143620ddf55ab351126ff4c6457d42fe00724e7bcd92193db3b25a73d5b5aa636014b6a3dc75765ba8dd812963
|
7
|
+
data.tar.gz: 61fa3c5464cd7c0e8970daa7d96f7a113e238e11ea0362d0cece1b679a1ae86a4607ab48428b26195fcb9060dd34c7eea797843b04a3df2f655c1ed03c302304
|
@@ -7,6 +7,22 @@ module ScaffoldParser
|
|
7
7
|
include BaseMethod
|
8
8
|
include Utils
|
9
9
|
|
10
|
+
def to_s
|
11
|
+
f = StringIO.new
|
12
|
+
|
13
|
+
f.puts "def #{method_name}"
|
14
|
+
f.puts indent(method_body.lines).join
|
15
|
+
f.puts "end"
|
16
|
+
|
17
|
+
f.puts
|
18
|
+
|
19
|
+
f.puts "def #{method_name}_attributes"
|
20
|
+
f.puts " attributes_at '#{at}'"
|
21
|
+
f.puts "end"
|
22
|
+
|
23
|
+
f.string.strip
|
24
|
+
end
|
25
|
+
|
10
26
|
def method_body
|
11
27
|
"at '#{at}'"
|
12
28
|
end
|
@@ -15,12 +31,13 @@ module ScaffoldParser
|
|
15
31
|
[source.xmlns_prefix, "#{source.name}"].compact.join(':')
|
16
32
|
end
|
17
33
|
|
18
|
-
def
|
19
|
-
"hash[:#{method_name}] = #{method_name} if has? '#{at}'"
|
34
|
+
def to_h_method
|
35
|
+
"hash[:#{method_name}] = #{method_name} if has? '#{at}'\n"\
|
36
|
+
"hash[:#{method_name}_attributes] = #{method_name}_attributes if has? '#{at}'"
|
20
37
|
end
|
21
38
|
|
22
39
|
def to_builder
|
23
|
-
"root << build_element('#{at}', data[:#{method_name}]) if data.key? :#{method_name}"
|
40
|
+
"root << build_element('#{at}', data[:#{method_name}], data[:#{method_name}_attributes]) if data.key? :#{method_name}"
|
24
41
|
end
|
25
42
|
|
26
43
|
def sequence(_)
|
@@ -56,10 +56,15 @@ module ScaffoldParser
|
|
56
56
|
f.puts if methods.any?
|
57
57
|
f.puts methods.map { |method| indent(method.to_s.lines).join }.join("\n\n")
|
58
58
|
f.puts if methods.any?
|
59
|
-
f.puts " def
|
60
|
-
f.puts " hash =
|
59
|
+
f.puts " def to_h"
|
60
|
+
f.puts " hash = {}"
|
61
|
+
f.puts " hash[:attributes] = attributes"
|
61
62
|
f.puts
|
62
|
-
methods.each
|
63
|
+
methods.each do |method|
|
64
|
+
method.to_h_method.lines.each do |line|
|
65
|
+
f.puts " #{line}"
|
66
|
+
end
|
67
|
+
end
|
63
68
|
f.puts if methods.any?
|
64
69
|
if includes.any?
|
65
70
|
f.puts " mega.inject(hash) { |memo, r| memo.merge r }"
|
@@ -96,8 +101,8 @@ module ScaffoldParser
|
|
96
101
|
f.puts
|
97
102
|
f.puts " def builder"
|
98
103
|
f.puts " root = Ox::Element.new(name)"
|
99
|
-
f.puts " if data.
|
100
|
-
f.puts " data
|
104
|
+
f.puts " if data.key? :attributes"
|
105
|
+
f.puts " data[:attributes].each { |k, v| root[k] = v }"
|
101
106
|
f.puts " end"
|
102
107
|
f.puts
|
103
108
|
if inherit_from
|
@@ -24,11 +24,11 @@ module ScaffoldParser
|
|
24
24
|
[source.xmlns_prefix, "#{source.name}"].compact.join(':')
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def to_h_method
|
28
28
|
if item_class == 'String'
|
29
29
|
"hash[:#{method_name}] = #{method_name} if has? '#{name_with_prefix}'"
|
30
30
|
else
|
31
|
-
"hash[:#{method_name}] = #{method_name}.map(&:
|
31
|
+
"hash[:#{method_name}] = #{method_name}.map(&:to_h) if has? '#{name_with_prefix}'"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -35,10 +35,15 @@ module ScaffoldParser
|
|
35
35
|
methods.each { |method| template.methods << indent(method.to_s.lines).join }
|
36
36
|
|
37
37
|
meth = StringIO.new
|
38
|
-
meth.puts " def
|
39
|
-
meth.puts " hash =
|
38
|
+
meth.puts " def to_h"
|
39
|
+
meth.puts " hash = {}"
|
40
|
+
meth.puts " hash[:attributes] = attributes"
|
40
41
|
meth.puts
|
41
|
-
methods.each
|
42
|
+
methods.each do |method|
|
43
|
+
method.to_h_method.lines.each do |line|
|
44
|
+
meth.puts " #{line}"
|
45
|
+
end
|
46
|
+
end
|
42
47
|
meth.puts
|
43
48
|
meth.puts " hash"
|
44
49
|
meth.puts " end"
|
@@ -60,8 +65,8 @@ module ScaffoldParser
|
|
60
65
|
meth = StringIO.new
|
61
66
|
meth.puts " def builder"
|
62
67
|
meth.puts " root = Ox::Element.new(name)"
|
63
|
-
meth.puts " if data.
|
64
|
-
meth.puts " data
|
68
|
+
meth.puts " if data.key? :attributes"
|
69
|
+
meth.puts " data[:attributes].each { |k, v| root[k] = v }"
|
65
70
|
meth.puts " end"
|
66
71
|
meth.puts
|
67
72
|
meth.puts methods.map { |method| indent(indent(method.to_builder.lines)).join }.join("\n")
|
@@ -22,11 +22,11 @@ module ScaffoldParser
|
|
22
22
|
[source.xmlns_prefix, "#{source.name}"].compact.join(':')
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def to_h_method
|
26
26
|
if item_class == 'String'
|
27
27
|
"hash[:#{method_name}] = #{method_name} if has? '#{name_with_prefix}'"
|
28
28
|
else
|
29
|
-
"hash[:#{method_name}] = #{method_name}.map(&:
|
29
|
+
"hash[:#{method_name}] = #{method_name}.map(&:to_h) if has? '#{name_with_prefix}'"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -32,8 +32,8 @@ module ScaffoldParser
|
|
32
32
|
[source.xmlns_prefix, "#{method_name}"].compact.join(':')
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
"hash[:#{method_name}] = #{method_name}.
|
35
|
+
def to_h_method
|
36
|
+
"hash[:#{method_name}] = #{method_name}.to_h if has? '#{at}'"
|
37
37
|
end
|
38
38
|
|
39
39
|
def to_builder
|
data/scaffold_parser.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'scaffold_parser'
|
6
|
-
spec.version = '0.
|
6
|
+
spec.version = '0.8.0'
|
7
7
|
spec.authors = ['Premysl Donat']
|
8
8
|
spec.email = ['pdonat@seznam.cz']
|
9
9
|
|
@@ -19,12 +19,13 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = ['scaffold_parser']
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.
|
23
|
-
spec.
|
24
|
-
|
22
|
+
spec.add_dependency 'xsd_model'
|
23
|
+
spec.add_dependency 'activesupport'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec'
|
25
28
|
spec.add_development_dependency 'pry'
|
26
29
|
spec.add_development_dependency 'pry-byebug'
|
27
|
-
spec.add_development_dependency 'nokogiri'
|
28
|
-
spec.add_development_dependency 'activesupport'
|
29
30
|
spec.add_development_dependency 'saharspec'
|
30
31
|
end
|
metadata
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffold_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Premysl Donat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: xsd_model
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: pry-byebug
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|