renuo-cms-rails 0.0.1 → 0.1.0

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: 571fe61d519389bb5d1298f328c098e52fe04190
4
- data.tar.gz: f73eeaf2938755b44ff9c95ad1bb417e46d11e2c
3
+ metadata.gz: 1cf6e98e641d7bf6fcaa1909862c6c76bad61b10
4
+ data.tar.gz: 6b1e0eab22ea12f2cc570a7ee0a13bb6ad58e506
5
5
  SHA512:
6
- metadata.gz: 4cd5e8cde14679f38c7f6360c5930aff249ff5b8c4803a75cafd04b4854c26634b88cb8bb9302284fd08ca1106c8212e73453446a82bf26533fb9cd945ce1fc8
7
- data.tar.gz: 9656b07f7bfc237c3772f341a4ed2373aa5d83da09ec6ca4d2fa5626cda8a923b2bd58b5362d53810e9a268aee44fef32f8f1996f6d9a8788838792ab75b433d
6
+ metadata.gz: d687588afffbfa05caaff48b1ba41beb1da919ddd0a57bae7707600a9f0e42a1afd4ae8619a3dddc3de0f72ff1b876ddf7b308e2163137ccd1cba56e9dc35ead
7
+ data.tar.gz: 7731659391360e60806d0985a7489a71bc00a07609de7bd3b5e7547c72cb4027a40029829153b634793aef3286b4059ac28845c4427fb4ca3b9485f8c724ae38
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.0
4
+ - 2.3.1
5
5
  addons:
6
6
  apt:
7
7
  packages:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## Version 0.1.0
2
+
3
+ * add https:// by default to api_host if no protocol is given
4
+ * better dependencies specs
5
+ * make the content path configurable
6
+ * refactoring
7
+
1
8
  ## Version 0.0.1
2
9
 
3
10
  * initial release
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/renuo-cms-rails.svg)](https://badge.fury.io/rb/renuo-cms-rails) [![Build Status](https://secure.travis-ci.org/renuo/renuo-cms-rails.png)](http://travis-ci.org/renuo/renuo-cms-rails)
1
+ [![Gem Version](https://badge.fury.io/rb/renuo-cms-rails.svg)](https://badge.fury.io/rb/renuo-cms-rails) [![Build Status](https://travis-ci.org/renuo/renuo-cms-rails.svg?branch=master)](https://travis-ci.org/renuo/renuo-cms-rails) [![Build Status](https://travis-ci.org/renuo/renuo-cms-rails.svg?branch=develop)](https://travis-ci.org/renuo/renuo-cms-rails)
2
2
 
3
3
  # Renuo CMS Rails
4
4
 
@@ -73,7 +73,7 @@ Of course, you can also use it like this, where the whole block is the default t
73
73
  p = t('.paragraph-2')
74
74
  ```
75
75
 
76
- ## Configuration
76
+ ### Configuration
77
77
 
78
78
  The configuration is optional. If you want to use it, add an initializer file to your Rails app:
79
79
  *config/initializers/renuo_cms_rails.rb* containing the following block:
@@ -86,10 +86,12 @@ RenuoCmsRails.configure do |config|
86
86
  config.api_key = 'custom-api-key'
87
87
  # Default: ENV['RENUO_CMS_PRIVATE_API_KEY']
88
88
  config.private_api_key = 'custom-private-api-key'
89
+ # Default: ->(path) { "#{path}-#{I18n.locale}" }
90
+ config.content_path_generator = ->(path) { "#{I18n.locale}--#{path}" }
89
91
  end
90
92
  ```
91
93
 
92
- ## Authorization
94
+ ### Authorization
93
95
 
94
96
  To implement the authorization, implement a method ```cms_admin?``` in your application helper. Example (with devise):
95
97
 
@@ -114,11 +116,28 @@ end
114
116
  Of course, you can also add an application controller method, and make it a helper_method. See
115
117
  http://api.rubyonrails.org/classes/AbstractController/Helpers/ClassMethods.html#method-i-helper_method for details.
116
118
 
117
- ## Release
119
+ ### CMS Content Path
120
+
121
+ The CMS appends ```-#{I18n.locale}``` to the content path to localize the CMS content. Additionally, dots will be converted to dashes.
122
+
123
+ Example: If you use the path ```article.index.title``` and the I18n.locale ```en```, the CMS content path will be
124
+
125
+ ```
126
+ article-index-title-en
127
+ ```
128
+
129
+ ## Development of renuo-cms-rails
130
+
131
+ ### Contributing
132
+
133
+ See the [CONTRIBUTING](CONTRIBUTING.md) file.
134
+
135
+ ### Release
118
136
 
119
137
  ```sh
120
138
  git flow release start [.....]
121
139
  # adjust version.rb
140
+ # check (and adjust) CHANGELOG.md
122
141
  bundle install
123
142
  git commit -av
124
143
  git flow release finish [.....]
@@ -129,10 +148,6 @@ bundle exec rake release
129
148
  git checkout develop
130
149
  ```
131
150
 
132
- ## Contributing
133
-
134
- See the [CONTRIBUTING](CONTRIBUTING.md) file.
135
-
136
151
  ## Special Thanks
137
152
 
138
153
  Thanks https://github.com/sgruhier/foundation_rails_helper for the gem template.
@@ -1,6 +1,7 @@
1
1
  require 'renuo_cms_rails/version'
2
- require 'renuo_cms_rails/configuration'
2
+ require 'renuo_cms_rails/config'
3
3
  require 'renuo_cms_rails/cms_helper'
4
+
4
5
  ActiveSupport.on_load(:action_view) do
5
6
  include RenuoCmsRails::CmsHelper
6
7
  end
@@ -3,17 +3,18 @@ require 'action_view/helpers'
3
3
  module RenuoCmsRails
4
4
  module CmsHelper
5
5
  def cms(path, default_value = nil, &block)
6
- url_path = "#{path}-#{I18n.locale}"
6
+ content_path = RenuoCmsRails.config.content_path_generator.call(path)
7
7
  default_translation = capture_default_value(path, default_value, &block)
8
- content_tag(:div, default_translation, data: cms_attributes(url_path))
8
+ content_tag(:div, default_translation, data: cms_attributes(content_path))
9
9
  end
10
10
 
11
11
  private
12
12
 
13
13
  # :reek:FeatureEnvy
14
- def cms_attributes(url_path)
15
- config = RenuoCmsRails.configuration
16
- cms_attributes = { content_path: url_path, api_host: config.api_host, api_key: config.api_key }
14
+
15
+ def cms_attributes(content_path)
16
+ config = RenuoCmsRails.config
17
+ cms_attributes = { content_path: content_path, api_host: config.api_host_with_protocol, api_key: config.api_key }
17
18
  cms_attributes[:private_api_key] = config.private_api_key if cms_admin?
18
19
  cms_attributes
19
20
  end
@@ -0,0 +1,39 @@
1
+ module RenuoCmsRails
2
+ class << self
3
+ attr_writer :config
4
+ end
5
+
6
+ def self.config
7
+ @config ||= Config.new
8
+ end
9
+
10
+ def self.reset
11
+ @config = Config.new
12
+ end
13
+
14
+ def self.configure
15
+ yield(config)
16
+ end
17
+
18
+ class Config
19
+ attr_writer :api_host
20
+ attr_reader :api_host
21
+ private :api_host
22
+ attr_accessor :api_key
23
+ attr_accessor :private_api_key
24
+ attr_accessor :content_path_generator
25
+
26
+ def initialize
27
+ self.api_host = ENV['RENUO_CMS_API_HOST']
28
+ self.api_key = ENV['RENUO_CMS_API_KEY']
29
+ self.private_api_key = ENV['RENUO_CMS_PRIVATE_API_KEY']
30
+ self.content_path_generator = ->(path) { "#{path}-#{I18n.locale}" }
31
+ end
32
+
33
+ def api_host_with_protocol
34
+ host = api_host
35
+ return host if host.start_with?('https://', 'http://', '//')
36
+ "https://#{host}"
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module RenuoCmsRails
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
@@ -19,16 +19,16 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
21
 
22
- spec.add_dependency 'railties', '~> 4.1'
23
- spec.add_dependency 'actionpack', '~> 4.1'
24
- spec.add_dependency 'activemodel', '~> 4.1'
25
- spec.add_dependency 'activesupport', '~> 4.1'
26
- spec.add_dependency 'tzinfo', '~> 1.2', '>= 1.2.2'
22
+ spec.add_dependency 'railties', '>= 4.1.0'
23
+ spec.add_dependency 'actionpack', '>= 4.1.0'
24
+ spec.add_dependency 'activemodel', '>= 4.1.0'
25
+ spec.add_dependency 'activesupport', '>= 4.1.0'
26
+ spec.add_dependency 'tzinfo', '>= 1.2.2'
27
27
 
28
- spec.add_development_dependency 'rspec-rails', '~> 3.1', '>= 3.1.0'
29
- spec.add_development_dependency 'mime-types', '~> 2'
30
- spec.add_development_dependency 'capybara', '~> 2.4', '>= 2.4.3'
31
- spec.add_development_dependency 'climate_control', '~> 0', '>= 0.0.3'
32
- spec.add_development_dependency 'rubocop'
33
- spec.add_development_dependency 'reek'
28
+ spec.add_development_dependency 'rspec-rails', '>= 3.4.2'
29
+ spec.add_development_dependency 'mime-types', '>= 2.99.1'
30
+ spec.add_development_dependency 'capybara', '>= 2.7.0'
31
+ spec.add_development_dependency 'climate_control', '>= 0.0.3'
32
+ spec.add_development_dependency 'rubocop', '>= 0.39.0'
33
+ spec.add_development_dependency 'reek', '>= 4.0.1'
34
34
  end
@@ -6,9 +6,10 @@ describe RenuoCmsRails::CmsHelper do
6
6
  include RenuoCmsRailsSpecHelper
7
7
 
8
8
  before(:each) do
9
- RenuoCmsRails.configuration.api_host = 'some.host'
10
- RenuoCmsRails.configuration.api_key = 'apikey'
11
- RenuoCmsRails.configuration.private_api_key = 'pk'
9
+ RenuoCmsRails.reset
10
+ RenuoCmsRails.config.api_host = 'some.host'
11
+ RenuoCmsRails.config.api_key = 'apikey'
12
+ RenuoCmsRails.config.private_api_key = 'pk'
12
13
  end
13
14
 
14
15
  it 'sets the correct attributes for the public view' do
@@ -17,7 +18,7 @@ describe RenuoCmsRails::CmsHelper do
17
18
  node = Capybara.string cms('some.content', 'Some CMS content')
18
19
  expect(node).to have_css('div', text: 'Some CMS content')
19
20
  expect(node).to have_css("div[data-content-path='some.content-en']")
20
- expect(node).to have_css("div[data-api-host='some.host']")
21
+ expect(node).to have_css("div[data-api-host='https://some.host']")
21
22
  expect(node).to have_css("div[data-api-key='apikey']")
22
23
  expect(node).not_to have_css('div[data-private-api-key]')
23
24
  end
@@ -28,7 +29,7 @@ describe RenuoCmsRails::CmsHelper do
28
29
  node = Capybara.string cms('some.content', 'Some CMS content')
29
30
  expect(node).to have_css('div', text: 'Some CMS content')
30
31
  expect(node).to have_css("div[data-content-path='some.content-en']")
31
- expect(node).to have_css("div[data-api-host='some.host']")
32
+ expect(node).to have_css("div[data-api-host='https://some.host']")
32
33
  expect(node).to have_css("div[data-api-key='apikey']")
33
34
  expect(node).to have_css("div[data-private-api-key='pk']")
34
35
  end
@@ -40,7 +41,7 @@ describe RenuoCmsRails::CmsHelper do
40
41
  expect(node).not_to have_css('div', text: 'Some CMS content')
41
42
  expect(node).to have_css('div p', text: 'Block content!')
42
43
  expect(node).to have_css("div[data-content-path='some.content-en']")
43
- expect(node).to have_css("div[data-api-host='some.host']")
44
+ expect(node).to have_css("div[data-api-host='https://some.host']")
44
45
  expect(node).to have_css("div[data-api-key='apikey']")
45
46
  expect(node).not_to have_css('div[data-private-api-key]')
46
47
  end
@@ -52,8 +53,17 @@ describe RenuoCmsRails::CmsHelper do
52
53
  node = Capybara.string cms('some.content')
53
54
  expect(node).to have_css('div', text: 'I18n.t content!')
54
55
  expect(node).to have_css("div[data-content-path='some.content-en']")
55
- expect(node).to have_css("div[data-api-host='some.host']")
56
+ expect(node).to have_css("div[data-api-host='https://some.host']")
56
57
  expect(node).to have_css("div[data-api-key='apikey']")
57
58
  expect(node).not_to have_css('div[data-private-api-key]')
58
59
  end
60
+
61
+ it 'uses the custom content_path_generator config' do
62
+ allow(self).to receive(:cms_admin?).and_return(false)
63
+
64
+ RenuoCmsRails.config.content_path_generator = ->(path) { "#{I18n.locale}--#{path}" }
65
+
66
+ node = Capybara.string cms('some.content', 'Some CMS content')
67
+ expect(node).to have_css("div[data-content-path='en--some.content']")
68
+ end
59
69
  end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe RenuoCmsRails do
4
+ describe RenuoCmsRails::Config do
5
+ [
6
+ [:RENUO_CMS_API_HOST, :api_host, 'https://custom.host', 'https://new.host'],
7
+ [:RENUO_CMS_API_KEY, :api_key, 'custom-api-key', 'new-key'],
8
+ [:RENUO_CMS_PRIVATE_API_KEY, :private_api_key, 'custom-private-api-key', 'new-pk']
9
+ ].each do |env_variable_name, method, default_value, new_value|
10
+ describe "##{method}" do
11
+ it 'is the default value from the ENV variable' do
12
+ ClimateControl.modify env_variable_name => default_value do
13
+ config = RenuoCmsRails::Config.new
14
+ expect(config.send(method)).to eq(default_value)
15
+ end
16
+ end
17
+ end
18
+
19
+ describe "##{method}=" do
20
+ it 'can set value without an env variable' do
21
+ config = RenuoCmsRails::Config.new
22
+ config.send("#{method}=", new_value)
23
+ expect(config.send(method)).to eq(new_value)
24
+ end
25
+
26
+ it 'can set value when an env variable is defined' do
27
+ ClimateControl.modify env_variable_name => default_value do
28
+ config = RenuoCmsRails::Config.new
29
+ config.send("#{method}=", new_value)
30
+ expect(config.send(method)).to eq(new_value)
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "#reset (#{method})" do
36
+ it "resets the #{method}" do
37
+ ClimateControl.modify env_variable_name => default_value do
38
+ RenuoCmsRails.configure do |config|
39
+ config.send("#{method}=", new_value)
40
+ end
41
+
42
+ expect(RenuoCmsRails.config.send(method)).to eq(new_value)
43
+ RenuoCmsRails.reset
44
+ expect(RenuoCmsRails.config.send(method)).to eq(default_value)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe '#api_host_with_protocol' do
51
+ it 'does not change the api host if the protocol is configured' do
52
+ config = RenuoCmsRails::Config.new
53
+ expect(config).to receive(:api_host).and_return('https://some.host', 'http://some.host', '//some.host')
54
+ expect(config.api_host_with_protocol).to eq('https://some.host')
55
+ expect(config.api_host_with_protocol).to eq('http://some.host')
56
+ expect(config.api_host_with_protocol).to eq('//some.host')
57
+ end
58
+
59
+ it 'prepends https if no protocol is configured' do
60
+ config = RenuoCmsRails::Config.new
61
+ expect(config).to receive(:api_host).and_return('some.host', 'other.host')
62
+ expect(config.api_host_with_protocol).to eq('https://some.host')
63
+ expect(config.api_host_with_protocol).to eq('https://other.host')
64
+ end
65
+ end
66
+
67
+ describe '#content_path_generator' do
68
+ it 'the default content path generator does the right thing' do
69
+ config = RenuoCmsRails::Config.new
70
+ expect(config.content_path_generator.call('some.path')).to eq('some.path-en')
71
+ end
72
+ end
73
+
74
+ describe '#content_path_generator=' do
75
+ it 'can set the content_path_generator' do
76
+ config = RenuoCmsRails::Config.new
77
+ config.content_path_generator = ->(x) { "en-#{x}" }
78
+ expect(config.content_path_generator.call('abc')).to eq('en-abc')
79
+ end
80
+ end
81
+ end
82
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,3 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
2
2
  require 'renuo-cms-rails'
3
3
  require 'capybara'
4
4
  require 'climate_control'
5
-
6
- # turning off deprecations
7
- ActiveSupport::Deprecation.silenced = true
8
- I18n.enforce_available_locales = false
metadata CHANGED
@@ -1,78 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cms-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Elmer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.1'
33
+ version: 4.1.0
34
34
  type: :runtime
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: '4.1'
40
+ version: 4.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activemodel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.1'
47
+ version: 4.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '4.1'
54
+ version: 4.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '4.1'
61
+ version: 4.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '4.1'
68
+ version: 4.1.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tzinfo
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.2'
76
73
  - - ">="
77
74
  - !ruby/object:Gem::Version
78
75
  version: 1.2.2
@@ -80,9 +77,6 @@ dependencies:
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '1.2'
86
80
  - - ">="
87
81
  - !ruby/object:Gem::Version
88
82
  version: 1.2.2
@@ -90,63 +84,48 @@ dependencies:
90
84
  name: rspec-rails
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '3.1'
96
87
  - - ">="
97
88
  - !ruby/object:Gem::Version
98
- version: 3.1.0
89
+ version: 3.4.2
99
90
  type: :development
100
91
  prerelease: false
101
92
  version_requirements: !ruby/object:Gem::Requirement
102
93
  requirements:
103
- - - "~>"
104
- - !ruby/object:Gem::Version
105
- version: '3.1'
106
94
  - - ">="
107
95
  - !ruby/object:Gem::Version
108
- version: 3.1.0
96
+ version: 3.4.2
109
97
  - !ruby/object:Gem::Dependency
110
98
  name: mime-types
111
99
  requirement: !ruby/object:Gem::Requirement
112
100
  requirements:
113
- - - "~>"
101
+ - - ">="
114
102
  - !ruby/object:Gem::Version
115
- version: '2'
103
+ version: 2.99.1
116
104
  type: :development
117
105
  prerelease: false
118
106
  version_requirements: !ruby/object:Gem::Requirement
119
107
  requirements:
120
- - - "~>"
108
+ - - ">="
121
109
  - !ruby/object:Gem::Version
122
- version: '2'
110
+ version: 2.99.1
123
111
  - !ruby/object:Gem::Dependency
124
112
  name: capybara
125
113
  requirement: !ruby/object:Gem::Requirement
126
114
  requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '2.4'
130
115
  - - ">="
131
116
  - !ruby/object:Gem::Version
132
- version: 2.4.3
117
+ version: 2.7.0
133
118
  type: :development
134
119
  prerelease: false
135
120
  version_requirements: !ruby/object:Gem::Requirement
136
121
  requirements:
137
- - - "~>"
138
- - !ruby/object:Gem::Version
139
- version: '2.4'
140
122
  - - ">="
141
123
  - !ruby/object:Gem::Version
142
- version: 2.4.3
124
+ version: 2.7.0
143
125
  - !ruby/object:Gem::Dependency
144
126
  name: climate_control
145
127
  requirement: !ruby/object:Gem::Requirement
146
128
  requirements:
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
129
  - - ">="
151
130
  - !ruby/object:Gem::Version
152
131
  version: 0.0.3
@@ -154,9 +133,6 @@ dependencies:
154
133
  prerelease: false
155
134
  version_requirements: !ruby/object:Gem::Requirement
156
135
  requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
136
  - - ">="
161
137
  - !ruby/object:Gem::Version
162
138
  version: 0.0.3
@@ -166,28 +142,28 @@ dependencies:
166
142
  requirements:
167
143
  - - ">="
168
144
  - !ruby/object:Gem::Version
169
- version: '0'
145
+ version: 0.39.0
170
146
  type: :development
171
147
  prerelease: false
172
148
  version_requirements: !ruby/object:Gem::Requirement
173
149
  requirements:
174
150
  - - ">="
175
151
  - !ruby/object:Gem::Version
176
- version: '0'
152
+ version: 0.39.0
177
153
  - !ruby/object:Gem::Dependency
178
154
  name: reek
179
155
  requirement: !ruby/object:Gem::Requirement
180
156
  requirements:
181
157
  - - ">="
182
158
  - !ruby/object:Gem::Version
183
- version: '0'
159
+ version: 4.0.1
184
160
  type: :development
185
161
  prerelease: false
186
162
  version_requirements: !ruby/object:Gem::Requirement
187
163
  requirements:
188
164
  - - ">="
189
165
  - !ruby/object:Gem::Version
190
- version: '0'
166
+ version: 4.0.1
191
167
  description: The Renuo CLI automates some commonly used workflows by providing a command
192
168
  line interface.
193
169
  email:
@@ -211,11 +187,11 @@ files:
211
187
  - lib/railtie.rb
212
188
  - lib/renuo-cms-rails.rb
213
189
  - lib/renuo_cms_rails/cms_helper.rb
214
- - lib/renuo_cms_rails/configuration.rb
190
+ - lib/renuo_cms_rails/config.rb
215
191
  - lib/renuo_cms_rails/version.rb
216
192
  - renuo_cms_rails.gemspec
217
193
  - spec/renuo_cms_rails/cms_helper_spec.rb
218
- - spec/renuo_cms_rails/configuration_spec.rb
194
+ - spec/renuo_cms_rails/config_spec.rb
219
195
  - spec/spec_helper.rb
220
196
  - spec/support/mock_rails.rb
221
197
  homepage: https://github.com/renuo/renuo-cms-rails
@@ -244,6 +220,6 @@ specification_version: 4
244
220
  summary: Rails helpers for the renuo-cms
245
221
  test_files:
246
222
  - spec/renuo_cms_rails/cms_helper_spec.rb
247
- - spec/renuo_cms_rails/configuration_spec.rb
223
+ - spec/renuo_cms_rails/config_spec.rb
248
224
  - spec/spec_helper.rb
249
225
  - spec/support/mock_rails.rb
@@ -1,29 +0,0 @@
1
- module RenuoCmsRails
2
- class << self
3
- attr_writer :configuration
4
- end
5
-
6
- def self.configuration
7
- @configuration ||= Configuration.new
8
- end
9
-
10
- def self.reset
11
- @configuration = Configuration.new
12
- end
13
-
14
- def self.configure
15
- yield(configuration)
16
- end
17
-
18
- class Configuration
19
- attr_accessor :api_host
20
- attr_accessor :api_key
21
- attr_accessor :private_api_key
22
-
23
- def initialize
24
- self.api_host = ENV['RENUO_CMS_API_HOST']
25
- self.api_key = ENV['RENUO_CMS_API_KEY']
26
- self.private_api_key = ENV['RENUO_CMS_PRIVATE_API_KEY']
27
- end
28
- end
29
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RenuoCmsRails do
4
- describe RenuoCmsRails::Configuration do
5
- [
6
- [:RENUO_CMS_API_HOST, :api_host, 'custom.host', 'new.host'],
7
- [:RENUO_CMS_API_KEY, :api_key, 'custom-api-key', 'new-key'],
8
- [:RENUO_CMS_PRIVATE_API_KEY, :private_api_key, 'custom-private-api-key', 'new-pk']
9
- ].each do |env_variable_name, method, default_value, new_value|
10
- describe "##{method}" do
11
- it 'is the default value from the ENV variable' do
12
- ClimateControl.modify env_variable_name => default_value do
13
- config = RenuoCmsRails::Configuration.new
14
- expect(config.send(method)).to eq(default_value)
15
- end
16
- end
17
- end
18
-
19
- describe "##{method}=" do
20
- it 'can set value without an env variable' do
21
- config = RenuoCmsRails::Configuration.new
22
- config.send("#{method}=", new_value)
23
- expect(config.send(method)).to eq(new_value)
24
- end
25
-
26
- it 'can set value when an env variable is defined' do
27
- ClimateControl.modify env_variable_name => default_value do
28
- config = RenuoCmsRails::Configuration.new
29
- config.send("#{method}=", new_value)
30
- expect(config.send(method)).to eq(new_value)
31
- end
32
- end
33
- end
34
-
35
- describe "#reset (#{method})" do
36
- it "resets the #{method}" do
37
- ClimateControl.modify env_variable_name => default_value do
38
- RenuoCmsRails.configure do |config|
39
- config.send("#{method}=", new_value)
40
- end
41
-
42
- expect(RenuoCmsRails.configuration.send(method)).to eq(new_value)
43
- RenuoCmsRails.reset
44
- expect(RenuoCmsRails.configuration.send(method)).to eq(default_value)
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end