rainforest-cli 1.12.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/rainforest_cli/csv_importer.rb +11 -5
- data/lib/rainforest_cli/version.rb +1 -1
- data/spec/rainforest_cli/csv_importer_spec.rb +8 -0
- 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: 846b92985179bad132fce666ba44a2cf700acb10
|
4
|
+
data.tar.gz: 1565a3189a175799df17c4146cec815939f7bb13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 327eb266af0cc546b77aba045e965258bdf5ed022152d2713349c66eb18a3727e1ed6c8b47d3f710139d0fac6e2c0ca1f54141c6d53bc0f56550a65b3e57d4f1
|
7
|
+
data.tar.gz: d3a6f4f8806d4ef16ae925083fd81887ede699d51d34ff30841a4af42479369dfba173d89df10adab14f21a2b5260c9fbff2936bbd83f837ad99a48aeb8220e6
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# Rainforest CLI Changelog
|
2
2
|
|
3
|
+
## 1.12.1 - 7th February 2017
|
4
|
+
- Check columns returned from API before uploading rows when creating generators.
|
5
|
+
(458fdf5bf3ba28588dfb48d1253192ba477ac7ae, @epaulet)
|
6
|
+
|
3
7
|
## 1.12.0 - 6th February 2017
|
4
8
|
- Add category column to list of sites when using the `sites` command.
|
9
|
+
(11c24c3484a587b7305dcf279872fa5e5be02b5a, @epaulet)
|
5
10
|
|
6
11
|
## 1.11.0 - 4th November 2016
|
7
12
|
- Add `--single-use` flag for CSV uploads. (17a19694a788365beb59e634bd7286c86528484b, @epaulet)
|
@@ -24,10 +24,10 @@ module RainforestCli
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Create the generator
|
27
|
-
|
28
|
-
|
27
|
+
column_names = rows.shift.map do |col_name|
|
28
|
+
col_name.downcase.strip.gsub(/\s/, '_')
|
29
29
|
end
|
30
|
-
raise 'Invalid schema in CSV. You must include headers in first row.' if !
|
30
|
+
raise 'Invalid schema in CSV. You must include headers in first row.' if !column_names
|
31
31
|
|
32
32
|
if @overwrite_variable
|
33
33
|
puts 'Checking for existing tabular variables.'
|
@@ -44,13 +44,13 @@ module RainforestCli
|
|
44
44
|
puts 'Creating new tabular variable'
|
45
45
|
response = http_client.post(
|
46
46
|
'/generators',
|
47
|
-
{ name: @generator_name, description: @generator_name, columns:
|
47
|
+
{ name: @generator_name, description: @generator_name, columns: column_names, single_use: @single_use },
|
48
48
|
{ retries_on_failures: true }
|
49
49
|
)
|
50
50
|
raise "Error creating tabular variable: #{response['error']}" if response['error']
|
51
51
|
puts "\t[OK]"
|
52
52
|
|
53
|
-
columns = response['columns']
|
53
|
+
columns = sort_columns(column_names, response['columns'])
|
54
54
|
generator_id = response['id']
|
55
55
|
data = rows.map { |row| row_data(columns, row) }
|
56
56
|
|
@@ -71,6 +71,12 @@ module RainforestCli
|
|
71
71
|
puts 'Upload complete.'
|
72
72
|
end
|
73
73
|
|
74
|
+
def sort_columns(ordered_column_names, columns)
|
75
|
+
ordered_column_names.map do |col_name|
|
76
|
+
columns.find { |col| col['name'] == col_name }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
74
80
|
private
|
75
81
|
|
76
82
|
def http_client
|
@@ -69,6 +69,14 @@ describe RainforestCli::CSVImporter do
|
|
69
69
|
|
70
70
|
it_behaves_like 'it properly uploads variables'
|
71
71
|
|
72
|
+
context 'the API returns the columns in a variable order' do
|
73
|
+
before do
|
74
|
+
success_response['columns'] = success_response['columns'].reverse
|
75
|
+
end
|
76
|
+
|
77
|
+
it_behaves_like 'it properly uploads variables'
|
78
|
+
end
|
79
|
+
|
72
80
|
context 'tabular variable with given name already exists' do
|
73
81
|
let(:existing_generators) do
|
74
82
|
[
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainforest-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-02-
|
12
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|