contact_congress_parser 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0828d362f5db1d93fed2885c415d78f6748975d
4
- data.tar.gz: 22974433a83a98e48d8396e8c1fd0282958fee69
3
+ metadata.gz: 3973947ae671d93c75458fb84d38372092b8640f
4
+ data.tar.gz: 0f9eadd1a6eb74e9fd75b6d5d87ead0b2f3bc75d
5
5
  SHA512:
6
- metadata.gz: e1b0a2d8fc8e8854e287dbd6db9467fba0ca00dcf56f8ee0894ee430b4222da10511f037eedc67d92b007d0fc2e5ca050cde252c2f981144265f8d41735d8879
7
- data.tar.gz: d9f2ae8a4be27d6129aa90b848658c067c3653e953aae60e7a3ed663762de8fda110e7e1684aaccba44480560253968c79ce5218650a93ef70f932224ece00ac
6
+ metadata.gz: 2c3e24d048db8d05e5a307e2e5e165057de8863552b65026606dd074a3fd0fa0df842f9431b0ddbf58819849c274599f68ce17f81946f073c14a02c0920a4051
7
+ data.tar.gz: d6cd66f6234e3b72c27485c398774a77ce10ed243d0af05ee8e2ec8a27e548879f8fe1a8761c63a2310f85ac69fad707fd4ca71a32a08c81db0c2a81cceb9555
@@ -1,71 +1,73 @@
1
- class ContactCongressParser::Action
2
- attr_reader :name, :data
1
+ module ContactCongressParser
2
+ class Action
3
+ attr_reader :name, :data
3
4
 
4
- def self.create_from_step(step)
5
- name = step.keys.first
6
- values = step.values.first
5
+ def self.create_from_step(step)
6
+ name = step.keys.first
7
+ values = step.values.first
7
8
 
8
- if values.class == Array
9
- values.map { |value| self.new(name, value) }
10
- else
11
- self.new(name, values)
9
+ if values.class == Array
10
+ values.map { |value| self.new(name, value) }
11
+ else
12
+ self.new(name, values)
13
+ end
12
14
  end
13
- end
14
15
 
15
- def initialize(name, data)
16
- @name = name
17
- @data = data
18
- end
16
+ def initialize(name, data)
17
+ @name = name
18
+ @data = data
19
+ end
19
20
 
20
- def to_s
21
- name == 'wait' ? '' : name + ' ' + send("#{name}_args")
22
- end
21
+ def to_s
22
+ name == 'wait' ? '' : name + ' ' + send("#{name}_args")
23
+ end
23
24
 
24
- def visit_args
25
- '"' + path(data) + '"'
26
- end
25
+ def visit_args
26
+ '"' + path(data) + '"'
27
+ end
27
28
 
28
- def find_args
29
- to_find = data['value'] || data['selector']
30
- '"' + to_find + '"'
31
- end
29
+ def find_args
30
+ to_find = data['value'] || data['selector']
31
+ '"' + to_find + '"'
32
+ end
32
33
 
33
- def fill_in_args
34
- '"' + escape_quotes(@data['selector']) + '"' +
35
- ', with: ' +
36
- field(@data['value'])
37
- end
34
+ def fill_in_args
35
+ '"' + escape_quotes(@data['selector']) + '"' +
36
+ ', with: ' +
37
+ field(@data['value'])
38
+ end
38
39
 
39
- def select_args
40
- field(@data['value'], options: @data['options'])
41
- end
42
-
43
- def choose_args
44
- select_args
45
- end
40
+ def select_args
41
+ field(@data['value'], options: @data['options'])
42
+ end
43
+
44
+ def choose_args
45
+ select_args
46
+ end
46
47
 
47
- def check_args
48
- '"' + @data['selector'] + '"'
49
- end
48
+ def check_args
49
+ '"' + @data['selector'] + '"'
50
+ end
50
51
 
51
- def uncheck_args
52
- check_args
53
- end
52
+ def uncheck_args
53
+ check_args
54
+ end
54
55
 
55
- def click_on_args
56
- find_args
57
- end
56
+ def click_on_args
57
+ find_args
58
+ end
58
59
 
59
- private
60
- def path(uri)
61
- URI.parse(uri).path
62
- end
60
+ private
61
+ def path(uri)
62
+ URI.parse(uri).path
63
+ end
63
64
 
64
- def field(name, options=nil)
65
- Field.new(name, options).to_s
66
- end
65
+ def field(name, options=nil)
66
+ Field.new(name, options).to_s
67
+ end
67
68
 
68
- def escape_quotes(str)
69
- str.gsub('"', '\"')
69
+ def escape_quotes(str)
70
+ str.gsub('"', '\"')
71
+ end
70
72
  end
71
73
  end
@@ -1,32 +1,34 @@
1
- class ContactCongressParser::Field
2
- attr_reader :name, :field_options
1
+ module ContactCongressParser
2
+ class Field
3
+ attr_reader :name, :field_options
3
4
 
4
- def initialize(name, options=nil)
5
- @name = name
6
- @options = options
7
- @field_options = opts_to_array(options[:options]) if options
8
- @field_options = escape_opts_quotes(@field_options) if field_options
9
- end
5
+ def initialize(name, options=nil)
6
+ @name = name
7
+ @options = options
8
+ @field_options = opts_to_array(options[:options]) if options
9
+ @field_options = escape_opts_quotes(@field_options) if field_options
10
+ end
10
11
 
11
- def to_s
12
- "field(\"#{name}\"#{options_str})"
13
- end
12
+ def to_s
13
+ "field(\"#{name}\"#{options_str})"
14
+ end
14
15
 
15
16
 
16
- private
17
- def opts_to_array(opts)
18
- case opts
19
- when Array then opts
20
- when Hash then opts.keys
21
- when String then [opts]
17
+ private
18
+ def opts_to_array(opts)
19
+ case opts
20
+ when Array then opts
21
+ when Hash then opts.keys
22
+ when String then [opts]
23
+ end
22
24
  end
23
- end
24
25
 
25
- def escape_opts_quotes(opts)
26
- opts.map { |str| str.gsub('"', '\"') }
27
- end
26
+ def escape_opts_quotes(opts)
27
+ opts.map { |str| str.gsub('"', '\"') }
28
+ end
28
29
 
29
- def options_str
30
- field_options.nil? ? "" : ", options: [\"" + field_options.join("\", \"") + "\"]"
30
+ def options_str
31
+ field_options.nil? ? "" : ", options: [\"" + field_options.join("\", \"") + "\"]"
32
+ end
31
33
  end
32
34
  end
@@ -1,40 +1,42 @@
1
- class ContactCongressParser::Parser
2
- attr_reader :write_io
1
+ module ContactCongressParser
2
+ class Parser
3
+ attr_reader :write_io
3
4
 
4
- def self.parse(read_io, write_io)
5
- self.new(read_io, write_io).parse
6
- end
5
+ def self.parse(read_io, write_io)
6
+ self.new(read_io, write_io).parse
7
+ end
7
8
 
8
- def initialize(read_io, write_io)
9
- @yaml = YAML.load(read_io.read)
10
- @write_io = write_io
11
- end
9
+ def initialize(read_io, write_io)
10
+ @yaml = YAML.load(read_io.read)
11
+ @write_io = write_io
12
+ end
12
13
 
13
- def actions
14
- @actions ||= steps.map { |step| Action.create_from_step(step) }.flatten
15
- end
14
+ def actions
15
+ @actions ||= steps.map { |step| Action.create_from_step(step) }.flatten
16
+ end
16
17
 
17
- def parse
18
- create_form do
19
- actions.each { |action| write_io.puts tab + action.to_s }
18
+ def parse
19
+ create_form do
20
+ actions.each { |action| write_io.puts tab + action.to_s }
21
+ end
20
22
  end
21
- end
22
23
 
23
- def create_form(&block)
24
- write_io.puts("Conformity::Form.new('#{domain}') do")
25
- yield
26
- write_io.puts("end")
27
- end
24
+ def create_form(&block)
25
+ write_io.puts("Conformity::Form.new('#{domain}') do")
26
+ yield
27
+ write_io.puts("end")
28
+ end
28
29
 
29
- def domain
30
- @domain ||= URI.parse(steps.first['visit']).host
31
- end
30
+ def domain
31
+ @domain ||= URI.parse(steps.first['visit']).host
32
+ end
32
33
 
33
- def steps
34
- @steps ||= @yaml['contact_form']['steps']
35
- end
34
+ def steps
35
+ @steps ||= @yaml['contact_form']['steps']
36
+ end
36
37
 
37
- def tab
38
- ' '
38
+ def tab
39
+ ' '
40
+ end
39
41
  end
40
42
  end
@@ -1,3 +1,3 @@
1
1
  module ContactCongressParser
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contact_congress_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikias Kalpaxis