contact_congress_parser 0.0.8 → 0.0.9
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 +4 -4
- data/lib/contact_congress_parser/field.rb +39 -18
- data/lib/contact_congress_parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f606f2a626261c661b7a173b8a4d79741eee103b
|
4
|
+
data.tar.gz: ccc6e758a9665417c588b117f9347723fb03887e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 303ebac0d3da7adb7daf45375b49684de875e721946e7dca3b0656a7daae9dbc7263f088c06e3af153ea370f301c44f057ce4a85adc13b265cf42033b98af0ec
|
7
|
+
data.tar.gz: c9ed5abfd075ff8e990d94763fb0abaf7abf641060d16c6e6989c51f4fdbb92ebad121ce0ba15a5d7b1579efce7d97b472217cb89c713462cd6e1445b5ef776c
|
@@ -5,8 +5,6 @@ module ContactCongressParser
|
|
5
5
|
def initialize(name, options={})
|
6
6
|
@name = normalize_field_name(name)
|
7
7
|
@options = options
|
8
|
-
@field_options = opts_to_array(options[:options])
|
9
|
-
@field_options = escape_opts_quotes(@field_options) if field_options
|
10
8
|
end
|
11
9
|
|
12
10
|
def to_s
|
@@ -58,28 +56,51 @@ module ContactCongressParser
|
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
|
-
def
|
62
|
-
|
63
|
-
when Array then opts
|
64
|
-
when Hash then opts.keys
|
65
|
-
when String then [opts]
|
66
|
-
end
|
59
|
+
def options_str
|
60
|
+
Options.new(options[:options]).to_s + options_required_str
|
67
61
|
end
|
68
62
|
|
69
|
-
def
|
70
|
-
|
63
|
+
def options_required_str
|
64
|
+
required.nil? ? "" : ", required: #{required}"
|
71
65
|
end
|
72
66
|
|
73
|
-
|
74
|
-
|
75
|
-
|
67
|
+
# Note this is a class for options[:options] not the entire set of options
|
68
|
+
# that include options[:required], etc.
|
69
|
+
class Options
|
70
|
+
def initialize(options)
|
71
|
+
@options = options
|
72
|
+
if @options
|
73
|
+
to_array
|
74
|
+
strip
|
75
|
+
escape_quotes
|
76
|
+
hashify
|
77
|
+
end
|
78
|
+
end
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
def to_s
|
81
|
+
@options || ''
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def to_array
|
86
|
+
@options = case @options
|
87
|
+
when Array then @options
|
88
|
+
when Hash then @options.keys
|
89
|
+
when String then [@options]
|
90
|
+
end
|
91
|
+
end
|
80
92
|
|
81
|
-
|
82
|
-
|
93
|
+
def strip
|
94
|
+
@options.map! { |option| option.strip }
|
95
|
+
end
|
96
|
+
|
97
|
+
def escape_quotes
|
98
|
+
@options.map! { |option| option.gsub('"', '\"') }
|
99
|
+
end
|
100
|
+
|
101
|
+
def hashify
|
102
|
+
@options = ", options: [\"" + @options.join("\", \"") + "\"]"
|
103
|
+
end
|
83
104
|
end
|
84
105
|
end
|
85
106
|
end
|