spout 0.3.0.rc2 → 0.3.0.rc3

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: d5671a8b41975a9ab290e27c97afd2e145e3b268
4
- data.tar.gz: de9fbced0d2dd9f7b926cf266a3d7f44c64102de
3
+ metadata.gz: e50bf89439f62303ac004c28c0a8667703e30f4a
4
+ data.tar.gz: be7c8397dce6d4079f0d98b8e06923e2b1e685c3
5
5
  SHA512:
6
- metadata.gz: 92c999b5af0fb4832ba0f3fb1d9ab4302e060d7d4da38232a86358eae4e4de18c69390bf034cf672ee98a6250ce95d34b9a6ad05fd015ca29a20361dc49bf833
7
- data.tar.gz: b6dc0ec67ca26940e11be22af04179b34cfceef4484bd16413d773977a642c435ab33633e41c2aaf6602c5f6cccdfab966871f8d5fa3fdda4a41b7e4631278ef
6
+ metadata.gz: b5f53395b85e06a43ff229715046d2aa5d9875e71f5a655a7b50bc1d3da37496630ba0ec2f1b064b8219d04b11143f8fec75c3cb2a6f781593eb79b135380ca2
7
+ data.tar.gz: 2d382de9ab10cc0ccfaf9e6b203b290c2a2da7602fe6dad2baa4948d5b49f30ce82625db93717e500c6155b7d6545b64cad05d939b0afc44d60f1557fea54552
data/CHANGELOG.md CHANGED
@@ -3,10 +3,14 @@
3
3
  ### Enhancements
4
4
  - Tests now hide passing tests by default
5
5
  - To show all tests, use `spout tv`, or `bundle exec rake`
6
+ - Tests now include check for variable and domain name uniqueness across folders
7
+ - `include Spout::Tests::VariableNameUniqueness`
8
+ - `include Spout::Tests::DomainNameUniqueness`
6
9
  - Exports will now create a folder based on the version specified in the `VERSION` file located in the root of the data dictionary
7
10
  - If a version is specified, `spout export 1.0.1` then the command line version is used
8
11
  - If no version is specified, and no `VERSION` file exists, then the default `1.0.0` is used
9
12
  - The version must be specified on the first line in the `VERSION` file
13
+ - Spout can now create a new Spout project in a folder that was cloned from a Git repository
10
14
  - Use of Ruby 2.0.0-p247 is now recommended
11
15
 
12
16
  ## 0.2.0 (June 26, 2013)
data/lib/spout/actions.rb CHANGED
@@ -88,7 +88,7 @@ The FOLDER must be empty or new.
88
88
 
89
89
  EOT
90
90
 
91
- if @full_path == '' or (Dir.exists?(@full_path) and (Dir.entries(@full_path) - ['.', '..']).size > 0)
91
+ if @full_path == '' or ( Dir.exists?(@full_path) and (Dir.entries(@full_path) & ['.gitignore', '.ruby-version', '.travis.yml', 'Gemfile', 'Rakefile', 'domains', 'variables', 'test']).size > 0 )
92
92
  puts usage
93
93
  exit(0)
94
94
  end
@@ -18,19 +18,19 @@ namespace :dd do
18
18
 
19
19
  desc 'Create Data Dictionary from repository'
20
20
  task :create do
21
-
22
21
  folder = "dd/#{ENV['VERSION'] || standard_version}"
22
+ puts " create".colorize( :green ) + " #{folder}"
23
23
  FileUtils.mkpath folder
24
24
 
25
- case ENV['TYPE']
26
- when 'hybrid'
27
- hybrid_export(folder)
28
- else
29
- standard_export(folder)
30
- end
25
+ export_name = nil
26
+ additional_keys = []
31
27
 
28
+ if ENV['TYPE'] == 'hybrid'
29
+ export_name = 'hybrid'
30
+ additional_keys = [['hybrid', 'design_name'], ['hybrid', 'design_file'], ['hybrid', 'sensitivity'], ['hybrid', 'commonly_used']]
31
+ end
32
32
 
33
- puts "Data Dictionary Created in #{folder}"
33
+ expanded_export(folder, export_name, additional_keys)
34
34
  end
35
35
 
36
36
  desc 'Initialize JSON repository from a CSV file: CSV=datadictionary.csv'
@@ -49,18 +49,22 @@ def standard_version
49
49
  version == '' ? '1.0.0' : version
50
50
  end
51
51
 
52
- def standard_export(folder)
53
- CSV.open("#{folder}/variables.csv", "wb") do |csv|
52
+ def expanded_export(folder, export_name = nil, additional_keys = [])
53
+ variables_export_file = "#{[export_name, 'variables'].compact.join('-')}.csv"
54
+ puts " export".colorize( :blue ) + " #{folder}/#{variables_export_file}"
55
+ CSV.open("#{folder}/#{variables_export_file}", "wb") do |csv|
54
56
  keys = %w(id display_name description type units domain labels calculation)
55
- csv << ['folder'] + keys
57
+ csv << ['folder'] + keys + additional_keys.collect{|i| i[1]}
56
58
  Dir.glob("variables/**/*.json").each do |file|
57
59
  if json = JSON.parse(File.read(file)) rescue false
58
60
  variable_folder = variable_folder_path(file)
59
- csv << [variable_folder] + keys.collect{|key| json[key].kind_of?(Array) ? json[key].join(';') : json[key].to_s}
61
+ csv << [variable_folder] + keys.collect{|key| json[key].kind_of?(Array) ? json[key].join(';') : json[key].to_s} + additional_keys.collect{|i| other_property(i[0], json, i[1])}
60
62
  end
61
63
  end
62
64
  end
63
- CSV.open("#{folder}/domains.csv", "wb") do |csv|
65
+ domains_export_file = "#{[export_name, 'domains'].compact.join('-')}.csv"
66
+ puts " export".colorize( :blue ) + " #{folder}/#{domains_export_file}"
67
+ CSV.open("#{folder}/#{domains_export_file}", "wb") do |csv|
64
68
  keys = %w(value display_name description)
65
69
  csv << ['folder', 'domain_id'] + keys
66
70
  Dir.glob("domains/**/*.json").each do |file|
@@ -87,85 +91,8 @@ def variable_folder_path(file)
87
91
  file.gsub(/variables\//, '').split('/')[0..-2].join('/')
88
92
  end
89
93
 
90
- def hybrid_concept_type(json)
91
- if json['hybrid'] and json['hybrid']['type'].to_s != ''
92
- json['hybrid']['type']
93
- else
94
- hybrid_concept_type_map(json['type'])
95
- end
96
- end
97
-
98
- def hybrid_concept_type_map(variable_type)
99
- hybrid_types = { "choices" => "categorical",
100
- "numeric" => "continuous",
101
- "integer" => "continuous",
102
- "string" => "free text",
103
- "text" => "free text",
104
- "date" => "datetime",
105
- "time" => "datetime",
106
- "file" => "free text" }
107
- hybrid_types[variable_type] || variable_type
108
- end
109
-
110
- def hybrid_property(json, property)
111
- json['hybrid'] ? json['hybrid'][property] : ''
112
- end
113
-
114
- def hybrid_export(folder)
115
- domain_parents = {}
116
- CSV.open("#{folder}/hybrid.csv", "wb") do |csv|
117
- csv << ["Folder", "Short Name", "Description", "Concept Type", "Units", "Terms", "Internal Terms", "Parents", "Children", "Field Values", "Sensitivity", "Display Name", "Commonly Used", "Calculation", "Source Name", "Source File"]
118
- Dir.glob("variables/**/*.json").each do |file|
119
- if json = JSON.parse(File.read(file)) rescue false
120
- if json['domain'].to_s != ''
121
- domain_parents[json['domain'].to_s.downcase] ||= []
122
- domain_parents[json['domain'].to_s.downcase] << json['id'].to_s
123
- end
124
- row = [
125
- variable_folder_path(file), # Folder
126
- json['id'], # Short Name
127
- json['description'], # Description
128
- hybrid_concept_type(json), # Concept Type
129
- json['units'], # Units
130
- (json['labels'] || []).join(';'), # Terms
131
- '', # Internal Terms
132
- '', # Parents
133
- '', # Children
134
- '', # Field Values
135
- hybrid_property(json, 'access level'), # Sensitivity
136
- json['display_name'], # Display Name
137
- hybrid_property(json, 'most commonly used'), # Commonly Used
138
- json['calculation'], # Calculation
139
- hybrid_property(json, 'SOURCE'), # Source Name
140
- hybrid_property(json, 'filename') # Source File
141
- ]
142
- csv << row
143
- end
144
- end
145
- Dir.glob("domains/**/*.json").each do |file|
146
- if json = JSON.parse(File.read(file)) rescue false
147
- json.each do |option|
148
- row = [
149
- domain_folder_path(file), # Folder
150
- extract_domain_name(file)+'_'+option['value'].to_s, # Short Name
151
- option['description'], # Description
152
- 'boolean', # Concept Type
153
- '', # Units
154
- '', # Terms
155
- option['value'], # Internal Terms
156
- (domain_parents[extract_domain_name(file).downcase] || []).join(';'), # Parents
157
- '', # Children
158
- '', # Field Values
159
- '0', # Sensitivity
160
- option['display_name'], # Display Name
161
- '', # Commonly Used
162
- '', # Calculation
163
- ]
164
- csv << row
165
- end
166
- end
167
- end
168
- end
94
+ def other_property(parent, json, property)
95
+ json[parent] ? json[parent][property] : ''
169
96
  end
170
97
 
171
98
  def import_variables
data/lib/spout/tests.rb CHANGED
@@ -3,17 +3,21 @@ require 'test/unit'
3
3
  require 'rubygems'
4
4
  require 'json'
5
5
 
6
- require 'spout/tests/domain_existence_validation'
7
6
  require 'spout/tests/json_validation'
8
7
  require 'spout/tests/variable_type_validation'
8
+ require 'spout/tests/variable_name_uniqueness'
9
+ require 'spout/tests/domain_existence_validation'
9
10
  require 'spout/tests/domain_format'
11
+ require 'spout/tests/domain_name_uniqueness'
10
12
 
11
13
  module Spout
12
14
  module Tests
13
15
  include Spout::Tests::JsonValidation
14
16
  include Spout::Tests::VariableTypeValidation
17
+ include Spout::Tests::VariableNameUniqueness
15
18
  include Spout::Tests::DomainExistenceValidation
16
19
  include Spout::Tests::DomainFormat
20
+ include Spout::Tests::DomainNameUniqueness
17
21
 
18
22
  Turn.config.trace = 1
19
23
  end
@@ -0,0 +1,10 @@
1
+ module Spout
2
+ module Tests
3
+ module DomainNameUniqueness
4
+ def test_domain_name_uniqueness
5
+ files = Dir.glob("domains/**/*.json").collect{|file| file.split('/').last }
6
+ assert_equal [], files.select{ |f| files.count(f) > 1 }.uniq
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Spout
2
+ module Tests
3
+ module VariableNameUniqueness
4
+ def test_variable_name_uniqueness
5
+ files = Dir.glob("variables/**/*.json").collect{|file| file.split('/').last }
6
+ assert_equal [], files.select{ |f| files.count(f) > 1 }.uniq
7
+ end
8
+ end
9
+ end
10
+ end
data/lib/spout/version.rb CHANGED
@@ -3,7 +3,7 @@ module Spout
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
5
  TINY = 0
6
- BUILD = "rc2" # nil, "pre", "rc", "rc2"
6
+ BUILD = "rc3" # nil, "pre", "rc", "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  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: 0.3.0.rc2
4
+ version: 0.3.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -104,7 +104,9 @@ files:
104
104
  - lib/spout/templates/travis.yml
105
105
  - lib/spout/tests/domain_existence_validation.rb
106
106
  - lib/spout/tests/domain_format.rb
107
+ - lib/spout/tests/domain_name_uniqueness.rb
107
108
  - lib/spout/tests/json_validation.rb
109
+ - lib/spout/tests/variable_name_uniqueness.rb
108
110
  - lib/spout/tests/variable_type_validation.rb
109
111
  - lib/spout/tests.rb
110
112
  - lib/spout/version.rb