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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d643c76641c2871f0f18ea635ffe868546443721
4
- data.tar.gz: 073a323ecb28931576a27d1a7f352718920a3e83
3
+ metadata.gz: 846b92985179bad132fce666ba44a2cf700acb10
4
+ data.tar.gz: 1565a3189a175799df17c4146cec815939f7bb13
5
5
  SHA512:
6
- metadata.gz: 6b612e2ff7c36f3a666aa6ce0e15740c6051a6af936a3f117ccef0b87d056e6e1c242c5cae54571b880f0bbc7b573b7cfeb117f1691f2dbb984a26dd8f333d5a
7
- data.tar.gz: 74af9041c9d0b69815a33588b819cfaf44ed323cff190224fd68bf94ad57fbd101f7d709ce8c887bfdf288da8ac287fc74a7806a1567c38f2086609e91e8d281
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
- columns = rows.shift.map do |column|
28
- column.downcase.strip.gsub(/\s/, '_')
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 !columns
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: columns, single_use: @single_use },
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module RainforestCli
3
- VERSION = '1.12.0'
3
+ VERSION = '1.12.1'
4
4
  end
@@ -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.0
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-06 00:00:00.000000000 Z
12
+ date: 2017-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty