spout 0.7.0.beta2 → 0.7.0.beta3

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: 3de0f88d079aec8277e7ab748043453fff69155e
4
- data.tar.gz: b171cd8981f8b75f82c0ae80f119f9bd4b78c4e3
3
+ metadata.gz: 39c5c9a4eeab5b1ca4ff5aec2dde015d1bf15f52
4
+ data.tar.gz: db62fec6e3b1cc5b2b419537ec45c2eb9a8d85ce
5
5
  SHA512:
6
- metadata.gz: 0000efe51e39bce8cbcc61490b85c8f9ca706a8b5c7f842ef33a60a8c0da299e2372be330441840bb759af522c046c91d967750f3342e6900338b3c1dcd59c9d
7
- data.tar.gz: 6a8bd5e53598466b29171ffc30102497aa9e3532a102602320247a1f407d1e7f10e667c15c42741ae1f281b90736c8a5288c11c5d4f334a8537d00d39c8b5b58
6
+ metadata.gz: 5943c0cd60831bcbc2ff5b7d9077f34edc70b1019e45816fedcf0147a1c697fa90c1ad932dba124fc84e46c903584d68c7ff54a440431acd4d2ec3b73abc7d4b
7
+ data.tar.gz: efce7795ffda11a683a1b70efc9f1e7238463baa4e30335e6b4d7c2297ce86db7f9879277f1345d594b91159ad33d95502891b4b51e8931b5956f56ec02207fb
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ### Enhancements
4
4
  - Added `spout graphs` command that generates pie charts and histograms of each variable in a dataset
5
+ - The following flags are available:
6
+ - `spout g --type-numeric`
7
+ - `spout g --type-integer`
8
+ - `spout g --type-choices`
9
+ - `spout g --size-lg`
10
+ - `spout g --size-sm`
11
+ - `spout g --type-numeric --size-sm`
12
+ - For specific variables the following can be used:
13
+ - `spout g --id-<variable_id>`
5
14
 
6
15
  ## 0.6.0 (March 7, 2014)
7
16
 
data/README.md CHANGED
@@ -156,7 +156,19 @@ This command will take some time, and requires [PhantomJS](http://phantomjs.org/
156
156
  spout graphs
157
157
  ```
158
158
 
159
- Generated graphs will be placed in: `./graphs/`
159
+ The following flags can be passed to the `spout graphs` command:
160
+
161
+ - `spout g --type-numeric`
162
+ - `spout g --type-integer`
163
+ - `spout g --type-choices`
164
+ - `spout g --size-lg`
165
+ - `spout g --size-sm`
166
+ - `spout g --type-numeric --size-sm`
167
+
168
+ For specific variables the following can be used:
169
+ - `spout g --id-<variable_id>`
170
+
171
+ Generated graphs are placed in: `./graphs/`
160
172
 
161
173
  ### Export to the Hybrid Data Dictionary format from your JSON repository
162
174
 
data/lib/spout/actions.rb CHANGED
@@ -22,7 +22,7 @@ module Spout
22
22
  when 'coverage', '-coverage', '--coverage', 'c', '-c'
23
23
  coverage_report(argv)
24
24
  when 'graphs', '-graphs', '--graphs', 'g', '-g'
25
- generate_graphs(argv)
25
+ generate_graphs(argv.last(argv.size - 1))
26
26
  else
27
27
  help
28
28
  end
@@ -125,8 +125,19 @@ EOT
125
125
  system "bundle exec rake spout:coverage"
126
126
  end
127
127
 
128
- def generate_graphs(argv)
129
- system "bundle exec rake spout:graphs"
128
+ def flag_values(flags, param)
129
+ flags.select{|f| f[0..((param.size + 3) - 1)] == "--#{param}-" and f.length > param.size + 3}.collect{|f| f[(param.size + 3)..-1]}
130
+ end
131
+
132
+ def generate_graphs(flags)
133
+ params = {}
134
+ params['types'] = flag_values(flags, 'type')
135
+ params['variable_ids'] = flag_values(flags, 'id')
136
+ params['sizes'] = flag_values(flags, 'size')
137
+
138
+ params_string = params.collect{|key, values| "#{key}=#{values.join(',')}"}.join(' ')
139
+
140
+ system "bundle exec rake spout:graphs #{params_string}"
130
141
  end
131
142
 
132
143
  private
@@ -7,7 +7,7 @@ module Spout
7
7
  module Commands
8
8
  class Graphs
9
9
 
10
- def initialize
10
+ def initialize(types, variable_ids, sizes)
11
11
 
12
12
  total_index_count = Dir.glob("variables/**/*.json").count
13
13
 
@@ -20,7 +20,7 @@ module Spout
20
20
  Dir.glob("csvs/*.csv").each do |csv_file|
21
21
  puts "Working on: #{csv_file}"
22
22
  t = Time.now
23
- csv_table = CSV.table(csv_file, encoding: 'iso-8859-1').by_col!
23
+ csv_table = CSV.table(csv_file, encoding: 'iso-8859-1').by_col!
24
24
  puts "Loaded #{csv_file} in #{Time.now - t} seconds."
25
25
 
26
26
  total_header_count = csv_table.headers.count
@@ -30,6 +30,8 @@ module Spout
30
30
  json = JSON.parse(File.read(variable_file)) rescue json = nil
31
31
  next unless json
32
32
  next unless ["choices", "numeric", "integer"].include?(json["type"])
33
+ next unless types.size == 0 or types.include?(json['type'])
34
+ next unless variable_ids.size == 0 or variable_ids.include?(json['id'].to_s.downcase)
33
35
 
34
36
  basename = File.basename(variable_file).gsub(/\.json$/, '').downcase
35
37
  col_data = csv_table[header]
@@ -40,14 +42,14 @@ module Spout
40
42
  next unless domain_json
41
43
 
42
44
  create_pie_chart_options_file(col_data, tmp_options_file, domain_json)
43
- when "numeric", "integer"
45
+ when 'numeric', 'integer'
44
46
  create_line_chart_options_file(col_data, tmp_options_file, json["units"])
45
47
  else
46
48
  next
47
49
  end
48
50
 
49
- run_phantom_js("#{basename}-lg.png", 600, tmp_options_file)
50
- run_phantom_js("#{basename}.png", 75, tmp_options_file)
51
+ run_phantom_js("#{basename}-lg.png", 600, tmp_options_file) if sizes.size == 0 or sizes.include?('lg')
52
+ run_phantom_js("#{basename}.png", 75, tmp_options_file) if sizes.size == 0 or sizes.include?('sm')
51
53
  end
52
54
  end
53
55
  end
@@ -125,7 +125,10 @@ namespace :spout do
125
125
  desc 'Match CSV dataset with JSON repository'
126
126
  task :graphs do
127
127
  require 'spout/commands/graphs'
128
- Spout::Commands::Graphs.new()
128
+ types = ENV['types'].to_s.split(',').collect{|t| t.to_s.downcase}
129
+ variable_ids = ENV['variable_ids'].to_s.split(',').collect{|vid| vid.to_s.downcase}
130
+ sizes = ENV['sizes'].to_s.split(',').collect{|s| s.to_s.downcase}
131
+ Spout::Commands::Graphs.new(types, variable_ids, sizes)
129
132
  end
130
133
 
131
134
  end
data/lib/spout/version.rb CHANGED
@@ -3,7 +3,7 @@ module Spout
3
3
  MAJOR = 0
4
4
  MINOR = 7
5
5
  TINY = 0
6
- BUILD = "beta2" # nil, "pre", "rc", "rc2"
6
+ BUILD = "beta3" # 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.7.0.beta2
4
+ version: 0.7.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-10 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake