spout 0.7.0.beta2 → 0.7.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +13 -1
- data/lib/spout/actions.rb +14 -3
- data/lib/spout/commands/graphs.rb +7 -5
- data/lib/spout/tasks/engine.rake +4 -1
- data/lib/spout/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39c5c9a4eeab5b1ca4ff5aec2dde015d1bf15f52
|
4
|
+
data.tar.gz: db62fec6e3b1cc5b2b419537ec45c2eb9a8d85ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
129
|
-
|
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,
|
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
|
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
|
data/lib/spout/tasks/engine.rake
CHANGED
@@ -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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|