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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62adbf205bca2bcc8145f98ec3db81e0e4f727cefc8a6cd4feba20f89cad05c3
4
- data.tar.gz: 27865c6bc004b782554f351f9f06e7ba1dfb30c2c3b770fcb30d81017924fa97
3
+ metadata.gz: d7ba6db3d6933e6ec1a5880869caaa3094e2ee66b0f7d23b11704f38783d417f
4
+ data.tar.gz: 1000f48c9c6d47f4d988c474a8a96bc7a19cea02bc52b1a99b7b97ee9985faf6
5
5
  SHA512:
6
- metadata.gz: f21716870519e6fca63473053c7cbe7f09f447b7fe1515236523a1b9659fcb8fea8d19fac7492a376fde9afd1aef29a586d85ecfb6b086c171b2bd36fa59c095
7
- data.tar.gz: 76b8ae9036b3a5e95853b11a7b6cc330b44f0c1815de212949417fa32c8f8edfb3aab00335d974a745a7fe292b473ec26bb7f52a21bf739478889038cb79db25
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
- json = JSON.parse(File.read(file)) rescue json = nil
11
- json
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
@@ -20,7 +20,7 @@ module Spout
20
20
 
21
21
  json = begin
22
22
  if File.exist?(file_name)
23
- JSON.parse(File.read(file_name))
23
+ JSON.parse(File.read(file_name, encoding: "utf-8"))
24
24
  else
25
25
  @errors << "No corresponding #{@id}.json file found."
26
26
  nil
@@ -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}"
@@ -26,7 +26,7 @@ module Spout
26
26
  @domain_name = nil
27
27
 
28
28
  json = begin
29
- JSON.parse(File.read(file_name))
29
+ JSON.parse(File.read(file_name, encoding: "utf-8"))
30
30
  rescue => e
31
31
  error = e.message
32
32
  nil
@@ -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
@@ -3,5 +3,5 @@
3
3
  require "json"
4
4
 
5
5
  def json_value(file, key)
6
- begin JSON.parse(File.read(file))[key.to_s] rescue nil end
6
+ begin JSON.parse(File.read(file, encoding: "utf-8"))[key.to_s] rescue nil end
7
7
  end
@@ -5,7 +5,7 @@ module Spout
5
5
  module JsonValidation
6
6
  def assert_valid_json(item, msg = nil)
7
7
  result = begin
8
- !!JSON.parse(File.read(item))
8
+ !!JSON.parse(File.read(item, encoding: "utf-8"))
9
9
  rescue JSON::ParserError => e
10
10
  error = e
11
11
  false
@@ -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
@@ -5,7 +5,7 @@ module Spout
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  TINY = 0
8
- BUILD = "beta1" # "pre", "rc", "rc2", nil
8
+ BUILD = "beta2" # "pre", "rc", "rc2", nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join(".").freeze
11
11
  end
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.beta1
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-30 00:00:00.000000000 Z
11
+ date: 2019-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler