spout 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spout/commands/exporter.rb +1 -1
- data/lib/spout/commands/graphs.rb +1 -1
- data/lib/spout/helpers/json_loader.rb +5 -2
- data/lib/spout/helpers/subject_loader.rb +3 -3
- data/lib/spout/models/coverage_result.rb +3 -3
- data/lib/spout/models/domain.rb +1 -1
- data/lib/spout/models/form.rb +1 -1
- data/lib/spout/models/variable.rb +1 -1
- data/lib/spout/tests/domain_existence_validation.rb +2 -2
- data/lib/spout/tests/domain_format.rb +1 -1
- data/lib/spout/tests/form_existence_validation.rb +2 -2
- data/lib/spout/tests/form_name_format.rb +1 -1
- data/lib/spout/tests/form_name_match.rb +1 -1
- data/lib/spout/tests/json_helper.rb +1 -1
- data/lib/spout/tests/json_validation.rb +1 -1
- data/lib/spout/tests/variable_display_name_length.rb +1 -1
- data/lib/spout/tests/variable_name_format.rb +1 -1
- data/lib/spout/tests/variable_name_match.rb +1 -1
- data/lib/spout/tests/variable_type_validation.rb +1 -1
- data/lib/spout/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ba6db3d6933e6ec1a5880869caaa3094e2ee66b0f7d23b11704f38783d417f
|
4
|
+
data.tar.gz: 1000f48c9c6d47f4d988c474a8a96bc7a19cea02bc52b1a99b7b97ee9985faf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18fb6eab1720ffbf069a083dab7f5caf0082718bdff5f30aa028e532302bb58435222f888fa96e7f23de88a86d86351e2487b0b8ee60d8d3cf9c44d94e0f8ba1
|
7
|
+
data.tar.gz: e7d9b7669c65f625cd33018b9902519d7b58d93f4277de2295b303c903b6b1f16876eeba8358f68f9f02a555bd0c8ecf1fa68c8427690f157e258ec188209710
|
@@ -45,7 +45,7 @@ module Spout
|
|
45
45
|
%w(folder) + keys
|
46
46
|
end
|
47
47
|
Dir.glob("#{type}/**/*.json").sort.each do |file|
|
48
|
-
json = JSON.parse(File.read(file)) rescue false
|
48
|
+
json = JSON.parse(File.read(file, encoding: "utf-8")) rescue false
|
49
49
|
if json
|
50
50
|
relative_folder = generic_folder_path(file, type)
|
51
51
|
if include_domain_name
|
@@ -79,7 +79,7 @@ module Spout
|
|
79
79
|
|
80
80
|
def load_current_progress
|
81
81
|
@progress_file = File.join(@graphs_folder, ".progress.json")
|
82
|
-
@progress = JSON.parse(File.read(@progress_file)) rescue @progress = {}
|
82
|
+
@progress = JSON.parse(File.read(@progress_file, encoding: "utf-8")) rescue @progress = {}
|
83
83
|
@progress = {} if !@progress.is_a?(Hash) || @clean || @progress["SPOUT_VERSION"] != Spout::VERSION::STRING
|
84
84
|
@progress["SPOUT_VERSION"] = Spout::VERSION::STRING
|
85
85
|
end
|
@@ -7,8 +7,11 @@ module Spout
|
|
7
7
|
class JsonLoader
|
8
8
|
def self.get_json(file_name, file_type)
|
9
9
|
file = Dir.glob("#{file_type.to_s.downcase}s/**/#{file_name.to_s.downcase}.json", File::FNM_CASEFOLD).first
|
10
|
-
|
11
|
-
|
10
|
+
JSON.parse(File.read(file, encoding: "utf-8"))
|
11
|
+
rescue => e
|
12
|
+
puts "JsonLoader Warning".red
|
13
|
+
puts e.to_s.white
|
14
|
+
nil
|
12
15
|
end
|
13
16
|
|
14
17
|
def self.get_variable(variable_name)
|
@@ -100,7 +100,7 @@ module Spout
|
|
100
100
|
print "Converting numeric values to floats"
|
101
101
|
@variable_files.each_with_index do |variable_file, index|
|
102
102
|
print "\rConverting numeric values to floats:#{'% 3d' % ((index + 1) * 100 / variable_count)}%"
|
103
|
-
json = JSON.parse(File.read(variable_file)) rescue json = nil
|
103
|
+
json = JSON.parse(File.read(variable_file, encoding: "utf-8")) rescue json = nil
|
104
104
|
next unless json
|
105
105
|
next unless @valid_ids.include?(json["id"].to_s.downcase) || @valid_ids.size == 0
|
106
106
|
next unless %w(numeric integer).include?(json["type"])
|
@@ -122,7 +122,7 @@ module Spout
|
|
122
122
|
|
123
123
|
def load_variable_domains!
|
124
124
|
@variable_files.each do |variable_file|
|
125
|
-
json = JSON.parse(File.read(variable_file)) rescue json = nil
|
125
|
+
json = JSON.parse(File.read(variable_file, encoding: "utf-8")) rescue json = nil
|
126
126
|
next unless json
|
127
127
|
next unless json["type"] == "choices" || json["domain"].to_s.downcase.strip != ""
|
128
128
|
domain = json["domain"].to_s.downcase
|
@@ -133,7 +133,7 @@ module Spout
|
|
133
133
|
|
134
134
|
def get_json(file_name, file_type)
|
135
135
|
file = Dir.glob("#{file_type.to_s.downcase}s/**/#{file_name.to_s.downcase}.json", File::FNM_CASEFOLD).first
|
136
|
-
JSON.parse(File.read(file))
|
136
|
+
JSON.parse(File.read(file, encoding: "utf-8"))
|
137
137
|
rescue
|
138
138
|
nil
|
139
139
|
end
|
@@ -23,7 +23,7 @@ module Spout
|
|
23
23
|
def load_json(column)
|
24
24
|
file = Dir.glob("variables/**/#{column.to_s.downcase}.json", File::FNM_CASEFOLD).first
|
25
25
|
@file_name_test = !file.nil?
|
26
|
-
@json = JSON.parse(File.read(file)) rescue @json = {}
|
26
|
+
@json = JSON.parse(File.read(file, encoding: "utf-8")) rescue @json = {}
|
27
27
|
@json_id_test = (@json["id"].to_s.downcase == column)
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ module Spout
|
|
31
31
|
valid_values = []
|
32
32
|
if @json["type"] == "choices" || domain_name != ""
|
33
33
|
file = Dir.glob("domains/**/#{@json['domain'].to_s.downcase}.json", File::FNM_CASEFOLD).first
|
34
|
-
if json = JSON.parse(File.read(file)) rescue false
|
34
|
+
if json = JSON.parse(File.read(file, encoding: "utf-8")) rescue false
|
35
35
|
valid_values = json.collect { |hash| hash["value"] }
|
36
36
|
end
|
37
37
|
end
|
@@ -55,7 +55,7 @@ module Spout
|
|
55
55
|
true
|
56
56
|
else
|
57
57
|
domain_file = Dir.glob("domains/**/#{@json['domain'].to_s.downcase}.json", File::FNM_CASEFOLD).first
|
58
|
-
if domain_json = JSON.parse(File.read(domain_file)) rescue false
|
58
|
+
if domain_json = JSON.parse(File.read(domain_file, encoding: "utf-8")) rescue false
|
59
59
|
return domain_json.is_a?(Array)
|
60
60
|
end
|
61
61
|
false
|
data/lib/spout/models/domain.rb
CHANGED
data/lib/spout/models/form.rb
CHANGED
@@ -20,7 +20,7 @@ module Spout
|
|
20
20
|
@folder = file_name.to_s.gsub(/^#{dictionary_root}\/forms\/|#{@id}\.json$/, "")
|
21
21
|
|
22
22
|
json = begin
|
23
|
-
JSON.parse(File.read(file_name))
|
23
|
+
JSON.parse(File.read(file_name, encoding: "utf-8"))
|
24
24
|
rescue => e
|
25
25
|
form_name = file_name.to_s.gsub(/^(.*)\/|\.json$/, "").downcase
|
26
26
|
@errors << "Error Parsing #{form_name}.json: #{e.message}"
|
@@ -10,7 +10,7 @@ module Spout
|
|
10
10
|
file.split("/").last.to_s.downcase.split(".json").first
|
11
11
|
end
|
12
12
|
result = begin
|
13
|
-
domain_name = JSON.parse(File.read(item))["domain"]
|
13
|
+
domain_name = JSON.parse(File.read(item, encoding: "utf-8"))["domain"]
|
14
14
|
domain_names.include?(domain_name)
|
15
15
|
rescue JSON::ParserError
|
16
16
|
domain_name = ""
|
@@ -21,7 +21,7 @@ module Spout
|
|
21
21
|
end
|
22
22
|
|
23
23
|
Dir.glob("variables/**/*.json").each do |file|
|
24
|
-
if (not [nil, ""].include?(JSON.parse(File.read(file))["domain"]) rescue false)
|
24
|
+
if (not [nil, ""].include?(JSON.parse(File.read(file, encoding: "utf-8"))["domain"]) rescue false)
|
25
25
|
define_method("test_domain_exists: #{file}") do
|
26
26
|
assert_domain_existence file
|
27
27
|
end
|
@@ -6,7 +6,7 @@ module Spout
|
|
6
6
|
# Verifies the format of a domain.
|
7
7
|
def assert_domain_format(item)
|
8
8
|
result = begin
|
9
|
-
json = JSON.parse(File.read(item))
|
9
|
+
json = JSON.parse(File.read(item, encoding: "utf-8"))
|
10
10
|
if json.is_a?(Array)
|
11
11
|
json.empty? || json.select { |o| !o.is_a?(Hash) }.empty?
|
12
12
|
else
|
@@ -7,7 +7,7 @@ module Spout
|
|
7
7
|
form_names = Dir.glob("forms/**/*.json").collect{|file| file.split("/").last.to_s.downcase.split(".json").first}
|
8
8
|
|
9
9
|
result = begin
|
10
|
-
(form_names | JSON.parse(File.read(item))["forms"]).size == form_names.size
|
10
|
+
(form_names | JSON.parse(File.read(item, encoding: "utf-8"))["forms"]).size == form_names.size
|
11
11
|
rescue JSON::ParserError
|
12
12
|
false
|
13
13
|
end
|
@@ -18,7 +18,7 @@ module Spout
|
|
18
18
|
end
|
19
19
|
|
20
20
|
Dir.glob("variables/**/*.json").each do |file|
|
21
|
-
if (not [nil, ""].include?(JSON.parse(File.read(file))["forms"]) rescue false)
|
21
|
+
if (not [nil, ""].include?(JSON.parse(File.read(file, encoding: "utf-8"))["forms"]) rescue false)
|
22
22
|
define_method("test_form_exists: "+file) do
|
23
23
|
assert_form_existence file
|
24
24
|
end
|
@@ -8,7 +8,7 @@ module Spout
|
|
8
8
|
Dir.glob("forms/**/*.json").each do |file|
|
9
9
|
define_method("test_form_name_format: #{file}") do
|
10
10
|
message = "Form name format error. Name must start with a lowercase letter and be followed by lowercase letters, numbers, or underscores"
|
11
|
-
assert_match(/^[a-z]\w*$/, (begin JSON.parse(File.read(file))["id"] rescue nil end), message)
|
11
|
+
assert_match(/^[a-z]\w*$/, (begin JSON.parse(File.read(file, encoding: "utf-8"))["id"] rescue nil end), message)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -5,7 +5,7 @@ module Spout
|
|
5
5
|
module FormNameMatch
|
6
6
|
Dir.glob("forms/**/*.json").each do |file|
|
7
7
|
define_method("test_form_name_match: "+file) do
|
8
|
-
assert_equal file.gsub(/^.*\//, "").gsub(".json", "").downcase, (begin JSON.parse(File.read(file))["id"] rescue nil end)
|
8
|
+
assert_equal file.gsub(/^.*\//, "").gsub(".json", "").downcase, (begin JSON.parse(File.read(file, encoding: "utf-8"))["id"] rescue nil end)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -5,7 +5,7 @@ module Spout
|
|
5
5
|
module VariableDisplayNameLength
|
6
6
|
Dir.glob("variables/**/*.json").each do |file|
|
7
7
|
define_method("test_variable_display_name_length: "+file) do
|
8
|
-
assert_operator 255, :>=, (begin JSON.parse(File.read(file))["display_name"].size rescue 0 end)
|
8
|
+
assert_operator 255, :>=, (begin JSON.parse(File.read(file, encoding: "utf-8"))["display_name"].size rescue 0 end)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -8,7 +8,7 @@ module Spout
|
|
8
8
|
Dir.glob("variables/**/*.json").each do |file|
|
9
9
|
define_method("test_variable_name_format: #{file}") do
|
10
10
|
message = "Variable name format error. Name must start with a lowercase letter and be followed by lowercase letters, numbers, or underscores"
|
11
|
-
assert_match(/^[a-z]\w*$/, (begin JSON.parse(File.read(file))["id"] rescue nil end), message)
|
11
|
+
assert_match(/^[a-z]\w*$/, (begin JSON.parse(File.read(file, encoding: "utf-8"))["id"] rescue nil end), message)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -5,7 +5,7 @@ module Spout
|
|
5
5
|
module VariableNameMatch
|
6
6
|
Dir.glob("variables/**/*.json").each do |file|
|
7
7
|
define_method("test_variable_name_match: "+file) do
|
8
|
-
assert_equal file.gsub(/^.*\//, "").gsub(".json", "").downcase, (begin JSON.parse(File.read(file))["id"] rescue nil end)
|
8
|
+
assert_equal file.gsub(/^.*\//, "").gsub(".json", "").downcase, (begin JSON.parse(File.read(file, encoding: "utf-8"))["id"] rescue nil end)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -12,7 +12,7 @@ module Spout
|
|
12
12
|
|
13
13
|
Dir.glob("variables/**/*.json").each do |file|
|
14
14
|
define_method("test_variable_type: #{file}") do
|
15
|
-
assert_variable_type begin JSON.parse(File.read(file))["type"] rescue nil end
|
15
|
+
assert_variable_type begin JSON.parse(File.read(file, encoding: "utf-8"))["type"] rescue nil end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/spout/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|