contentful_bootstrap 3.3.0 → 3.4.0

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: d4714e403b05588c84e46a5f5e66af2224eb566d
4
- data.tar.gz: a2ef00692e18a5f7251c88b3ffdba02be6a6f39e
3
+ metadata.gz: 4672f655b4d3a32b439e75feec5b7d5fddbcfb5e
4
+ data.tar.gz: 75bcb4e3054e0a5cbc1abe6a2e7c0083f7a718fe
5
5
  SHA512:
6
- metadata.gz: 79e35a1d6e63c0bc61b9e8e3eb0ad0cf8a4222c8ebaf2a010d3cf75f728304d8384b24f1ac129415d254bcfc8d5ea0e3045d243612b1dba64538be9a0dbc84dc
7
- data.tar.gz: 03aa80d7fa3ac65ed38a27515eed71605715605de6ecf5a191d04ce9fc0e0277b8fbb6a114113029e093cad3faddf9c696515c39758d21119819d7caae2841c0
6
+ metadata.gz: c54a6ad2254d281a207b7764a419313b69b4caf1eff76cd03fb01bc01b757b8f537f73d538122345ccae69ae5b89f782748a22509278881d2122403b19e62140
7
+ data.tar.gz: 230b8f6a1b6413ce6888bad8a0252435bbc3602a183d31e4aaef66bab51894ceaab68943b4492352bfb3517c4ed984c2d873b8e15056afb844bc2789918e723d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v3.4.0
6
+ ### Added
7
+ * Add `-v` and `--version` flags to output current version
8
+ * Add possibility to define `CONTENTFUL_ORGANIZATION_ID` in your `.contentfulrc` file [#44](https://github.com/contentful/contentful-bootstrap.rb/issues/44)
9
+
5
10
  ## v3.3.0
6
11
  ### Added
7
12
  * Adds possibility to change `contentType` for Assets [#39](https://github.com/contentful/contentful-bootstrap.rb/issues/39)
@@ -75,6 +75,10 @@ global = OptionParser.new do |opts|
75
75
  Available commands are:
76
76
  \t#{subcommands.keys.sort.join("\n\t")}
77
77
  HELP
78
+ opts.on_tail("-v", "--version", "Show Version") do
79
+ puts "Contentful Bootstrap: #{Contentful::Bootstrap::VERSION}"
80
+ exit(0)
81
+ end
78
82
  end
79
83
 
80
84
  global.order!
@@ -85,7 +89,7 @@ space = ARGV.shift unless is_help
85
89
 
86
90
  options[:access_token] = ARGV.shift if command == "generate_json" && !is_help
87
91
 
88
- if subcommands.has_key? command
92
+ if subcommands.key? command
89
93
  subcommands[command].order!
90
94
 
91
95
  unless STDIN.tty? && STDOUT.tty?
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.6"
21
- spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rspec"
21
+ spec.add_development_dependency 'rake', '< 11.0'
22
+ spec.add_development_dependency 'public_suffix', '< 1.5'
23
+ spec.add_development_dependency 'rspec', '~> 3'
23
24
  spec.add_development_dependency "vcr", '~> 2.9'
24
25
  spec.add_development_dependency "webmock", '~> 1.24'
25
26
  spec.add_development_dependency "rr"
@@ -45,12 +45,18 @@ module Contentful
45
45
  def fetch_space
46
46
  new_space = nil
47
47
  begin
48
- new_space = Contentful::Management::Space.create(name: @space)
48
+ options = {
49
+ name: @space
50
+ }
51
+ options[:organization_id] = @token.read_organization_id unless @token.read_organization_id.nil?
52
+ new_space = Contentful::Management::Space.create(options)
49
53
  rescue Contentful::Management::NotFound
50
54
  puts 'Your account has multiple organizations:'
51
55
  puts organizations.join("\n")
52
56
  print 'Please insert the Organization ID you\'d want to create the spaces for: '
53
57
  organization_id = gets.chomp
58
+ @token.write_organization_id(organization_id)
59
+ puts 'Your Organization ID has been stored as the default organization.'
54
60
  new_space = Contentful::Management::Space.create(
55
61
  name: @space,
56
62
  organization_id: organization_id
@@ -8,6 +8,7 @@ module Contentful
8
8
  DEFAULT_PATH = '.contentfulrc'.freeze
9
9
  MANAGEMENT_TOKEN = 'CONTENTFUL_MANAGEMENT_ACCESS_TOKEN'.freeze
10
10
  DELIVERY_TOKEN = 'CONTENTFUL_DELIVERY_ACCESS_TOKEN'.freeze
11
+ ORGANIZATION_ID = 'CONTENTFUL_ORGANIZATION_ID'.freeze
11
12
  SPACE_ID = 'SPACE_ID'.freeze
12
13
 
13
14
  attr_reader :config_path
@@ -32,12 +33,20 @@ module Contentful
32
33
  raise 'Token not found'
33
34
  end
34
35
 
36
+ def read_organization_id
37
+ config_file[config_section].fetch(ORGANIZATION_ID, nil)
38
+ end
39
+
35
40
  def write(value, section = nil, key = MANAGEMENT_TOKEN)
36
41
  file = config_file
37
42
  file[section || config_section][key] = value
38
43
  file.save
39
44
  end
40
45
 
46
+ def write_organization_id(organization_id)
47
+ write(organization_id, nil, ORGANIZATION_ID)
48
+ end
49
+
41
50
  def write_access_token(space_name, token)
42
51
  write(token, space_name, DELIVERY_TOKEN)
43
52
  end
@@ -1,6 +1,6 @@
1
1
  module Contentful
2
2
  module Bootstrap
3
- VERSION = '3.3.0'
3
+ VERSION = '3.4.0'
4
4
 
5
5
  def self.major_version
6
6
  VERSION.split('.').first.to_i
@@ -5,6 +5,7 @@ describe Contentful::Bootstrap::Token do
5
5
  let(:no_token_path) { File.expand_path(File.join('spec', 'fixtures', 'ini_fixtures', 'no_token.ini')) }
6
6
  let(:sections_path) { File.expand_path(File.join('spec', 'fixtures', 'ini_fixtures', 'sections.ini')) }
7
7
  let(:no_global_path) { File.expand_path(File.join('spec', 'fixtures', 'ini_fixtures', 'no_global.ini')) }
8
+ let(:with_org_id) { File.expand_path(File.join('spec', 'fixtures', 'ini_fixtures', 'orgid.ini')) }
8
9
  subject { Contentful::Bootstrap::Token.new(path) }
9
10
 
10
11
  describe 'attributes' do
@@ -76,6 +77,16 @@ describe Contentful::Bootstrap::Token do
76
77
  end
77
78
  end
78
79
 
80
+ describe '#read_organization_id' do
81
+ it 'nil if default org id is not set' do
82
+ expect(subject.read_organization_id).to be_nil
83
+ end
84
+
85
+ it 'returns value of org id is set' do
86
+ expect(subject.class.new(with_org_id).read_organization_id).to eq 'my_org'
87
+ end
88
+ end
89
+
79
90
  describe 'write methods' do
80
91
  before do
81
92
  @file = subject.config_file
@@ -99,6 +110,11 @@ describe Contentful::Bootstrap::Token do
99
110
  expect(@file['some_space']['SPACE_ID']).to eq 'asd'
100
111
  end
101
112
 
113
+ it '#write_organization_id' do
114
+ subject.write_organization_id('foo')
115
+ expect(@file['global']['CONTENTFUL_ORGANIZATION_ID']).to eq 'foo'
116
+ end
117
+
102
118
  describe '#write' do
103
119
  it 'writes management tokens when only value is sent' do
104
120
  expect(@file['global']['CONTENTFUL_MANAGEMENT_ACCESS_TOKEN']).to eq 'foobar'
@@ -0,0 +1,3 @@
1
+ [global]
2
+ CONTENTFUL_MANAGEMENT_ACCESS_TOKEN = foobar
3
+ CONTENTFUL_ORGANIZATION_ID = my_org
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Litvak Bruno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,30 +28,44 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '11.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "<"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '11.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: public_suffix
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "<"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: '3'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: '3'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: vcr
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -261,6 +275,7 @@ files:
261
275
  - spec/fixtures/ini_fixtures/contentfulrc.ini
262
276
  - spec/fixtures/ini_fixtures/no_global.ini
263
277
  - spec/fixtures/ini_fixtures/no_token.ini
278
+ - spec/fixtures/ini_fixtures/orgid.ini
264
279
  - spec/fixtures/ini_fixtures/sections.ini
265
280
  - spec/fixtures/json_fixtures/asset_no_transform.json
266
281
  - spec/fixtures/json_fixtures/display_field.json
@@ -333,6 +348,7 @@ test_files:
333
348
  - spec/fixtures/ini_fixtures/contentfulrc.ini
334
349
  - spec/fixtures/ini_fixtures/no_global.ini
335
350
  - spec/fixtures/ini_fixtures/no_token.ini
351
+ - spec/fixtures/ini_fixtures/orgid.ini
336
352
  - spec/fixtures/ini_fixtures/sections.ini
337
353
  - spec/fixtures/json_fixtures/asset_no_transform.json
338
354
  - spec/fixtures/json_fixtures/display_field.json