roqua-core-api 0.0.16 → 0.0.17

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: 1d2f0bc90e2d82c735a5ee7de9f41a34dd947f44
4
- data.tar.gz: 846e6fad4b6e51fe581e8aa0dcab3bf00ac6c1ee
3
+ metadata.gz: 50c40344f6697004903f2952c40768b4dd5ce8e2
4
+ data.tar.gz: 31e41c1d5826c1a774c51a800aeb7aed08f1abd9
5
5
  SHA512:
6
- metadata.gz: 13cfe5d94986414a25ac6ed16a193e2ec07dd4a8cb0b17051fb192c4383621d7e7dd4fa46ab517e83fe4d063787f8e2195c3e5177370398e3e878e5faca1fb3c
7
- data.tar.gz: 75657185a13034f25c60d547174de264f8c79c07cc10c5f81491182318439af29b02281dee9ddfc2be4c9fb564d3afdd23ea16415c1d6fca7e0219d3e498a26f
6
+ metadata.gz: 9dba8ce70e38185f9d35800e0f113e931fdc84a8fec4f3c90b96750f2617890fed0230b62b920db1c3c8665ea454508a13fcae9ec3600988f8ad4cb7c62b7df3
7
+ data.tar.gz: 608ee4473cab2d2612057584a938bf23793bbc5f1c2d5da59dd8825e8795d53f24dd0d50e566ede53871e427b60499c9dc8c13875164698865ad3f5b6e948792
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.17 / 2014-03-13
2
+
3
+ * Now getting environment variables using ENV.fetch, so you will get errors if they are missing
4
+
1
5
  ### 0.0.16 / 2014-03-13
2
6
 
3
7
  * Added NoSession and Unauthorized errors, and throwing them when applicable.
data/core_api.gemspec CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |gem|
28
28
  gem.add_development_dependency 'rspec', '~> 3.0.0.beta1'
29
29
  gem.add_development_dependency 'fabrication', '~> 2.9'
30
30
  gem.add_development_dependency 'webmock', '~> 1.17'
31
+ gem.add_development_dependency 'dotenv', '~> 0.10'
31
32
  end
@@ -2,12 +2,12 @@ module Roqua
2
2
  module CoreApi
3
3
  module Sessions
4
4
  class AuthSession
5
- attr_reader :core_host
5
+ attr_reader :core_site
6
6
  attr_reader :default_timeout
7
7
 
8
8
  # timeout for requests in seconds
9
- def initialize(core_host: ENV['CORE_HOST'], timeout: nil)
10
- @core_host = core_host
9
+ def initialize(core_site: ENV.fetch('CORE_SITE'), timeout: nil)
10
+ @core_site = core_site
11
11
  @default_timeout = timeout
12
12
  end
13
13
 
@@ -52,7 +52,7 @@ module Roqua
52
52
  end
53
53
 
54
54
  def full_url_for(path)
55
- core_host + api_base + path + '.json'
55
+ core_site + api_base + path + '.json'
56
56
  end
57
57
 
58
58
  def api_base
@@ -5,7 +5,7 @@ module Roqua
5
5
  attr_reader :username
6
6
  attr_reader :password
7
7
 
8
- def initialize(username: ENV['CORE_KEY'], password: ENV['CORE_SECRET'], **additional_arguments)
8
+ def initialize(username: ENV.fetch('CORE_KEY'), password: ENV.fetch('CORE_SECRET'), **additional_arguments)
9
9
  @username = username
10
10
  @password = password
11
11
  super additional_arguments
@@ -10,7 +10,7 @@ module Roqua
10
10
  end
11
11
 
12
12
  def logout_url(return_to:)
13
- "#{core_host}/session/destroy?token=#{access_token}&redirect_to=#{CGI.escape return_to}"
13
+ "#{core_site}/session/destroy?token=#{access_token}&redirect_to=#{CGI.escape return_to}"
14
14
  end
15
15
 
16
16
  private
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module CoreApi
3
- VERSION = "0.0.16"
3
+ VERSION = "0.0.17"
4
4
  end
5
5
  end
@@ -12,8 +12,8 @@ Rails.application.config.middleware.use OmniAuth::Builder do
12
12
  client_options: {site: 'http://core.dev'}
13
13
  else
14
14
  provider :doorkeeper,
15
- ENV['CORE_OAUTH_CLIENT_ID'],
16
- ENV['CORE_OAUTH_CLIENT_SECRET'],
17
- client_options: {site: ENV['CORE_OAUTH_URL']}
15
+ ENV.fetch('CORE_OAUTH_CLIENT_ID'),
16
+ ENV.fetch('CORE_OAUTH_CLIENT_SECRET'),
17
+ client_options: {site: ENV.fetch('CORE_OAUTH_URL')}
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  Fabricator(:auth_session, from: Roqua::CoreApi::Sessions::AuthSession) do
2
- initialize_with { Roqua::CoreApi::Sessions::AuthSession.new core_host: 'http://core.dev' }
2
+ initialize_with { Roqua::CoreApi::Sessions::AuthSession.new core_site: 'http://core.dev' }
3
3
  end
@@ -2,6 +2,6 @@ Fabricator(:basic_auth_session, from: Roqua::CoreApi::Sessions::BasicAuthSession
2
2
  initialize_with do
3
3
  Roqua::CoreApi::Sessions::BasicAuthSession.new username: 'some_username',
4
4
  password: 'some_password',
5
- core_host: 'http://core.dev'
5
+ core_site: 'http://core.dev'
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  Fabricator(:oauth_session, from: Roqua::CoreApi::Sessions::OAuthSession) do
2
2
  initialize_with do
3
- Roqua::CoreApi::Sessions::OAuthSession.new access_token: 'some_access_token', core_host: 'http://core.dev'
3
+ Roqua::CoreApi::Sessions::OAuthSession.new access_token: 'some_access_token', core_site: 'http://core.dev'
4
4
  end
5
5
  end
@@ -6,17 +6,17 @@ describe AuthSession do
6
6
  let(:response) { double('response', code: 201, parsed_response: 'some_response') }
7
7
 
8
8
  describe '#initialize' do
9
- it 'sets the core_host instance attribute' do
10
- session = AuthSession.new core_host: 'some_core_host'
11
- expect(session.core_host).to eq('some_core_host')
9
+ it 'sets the core_site instance attribute' do
10
+ session = AuthSession.new core_site: 'some_core_site'
11
+ expect(session.core_site).to eq('some_core_site')
12
12
  end
13
13
 
14
- it 'defaults the core_host to the CORE_HOST env variable' do
15
- orginal_env_core_host = ENV['CORE_HOST']
16
- ENV['CORE_HOST'] = 'some_env_core_host'
14
+ it 'defaults the core_site to the CORE_SITE env variable' do
15
+ original_env_core_site = ENV['CORE_SITE']
16
+ ENV['CORE_SITE'] = 'some_env_core_site'
17
17
  session = AuthSession.new
18
- ENV['CORE_HOST'] = orginal_env_core_host
19
- expect(session.core_host).to eq('some_env_core_host')
18
+ ENV['CORE_SITE'] = original_env_core_site
19
+ expect(session.core_site).to eq('some_env_core_site')
20
20
  end
21
21
 
22
22
  it 'sets the default timeout' do
@@ -8,10 +8,10 @@ describe BasicAuthSession do
8
8
  end
9
9
 
10
10
  it 'defaults the username to the CORE_KEY env variable' do
11
- orginal_env_core_key = ENV['CORE_KEY']
11
+ original_env_core_key = ENV['CORE_KEY']
12
12
  ENV['CORE_KEY'] = 'some_env_core_key'
13
13
  session = Roqua::CoreApi.basic_auth_session
14
- ENV['CORE_KEY'] = orginal_env_core_key
14
+ ENV['CORE_KEY'] = original_env_core_key
15
15
  expect(session.username).to eq('some_env_core_key')
16
16
  end
17
17
 
@@ -21,24 +21,24 @@ describe BasicAuthSession do
21
21
  end
22
22
 
23
23
  it 'defaults the password to the CORE_SECRET env variable' do
24
- orginal_env_core_secret = ENV['CORE_SECRET']
24
+ original_env_core_secret = ENV['CORE_SECRET']
25
25
  ENV['CORE_SECRET'] = 'some_env_core_secret'
26
26
  session = Roqua::CoreApi.basic_auth_session
27
- ENV['CORE_SECRET'] = orginal_env_core_secret
27
+ ENV['CORE_SECRET'] = original_env_core_secret
28
28
  expect(session.password).to eq('some_env_core_secret')
29
29
  end
30
30
 
31
- it 'allows to override the core_host variable' do
32
- session = Roqua::CoreApi.basic_auth_session core_host: 'some_core_host'
33
- expect(session.core_host).to eq('some_core_host')
31
+ it 'allows to override the core_site variable' do
32
+ session = Roqua::CoreApi.basic_auth_session core_site: 'some_core_site'
33
+ expect(session.core_site).to eq('some_core_site')
34
34
  end
35
35
 
36
- it 'defaults the AuthSession core_host CORE_HOST env variable default value' do
37
- orginal_env_core_host = ENV['CORE_HOST']
38
- ENV['CORE_HOST'] = 'some_env_core_host'
36
+ it 'defaults the AuthSession core_site CORE_SITE env variable default value' do
37
+ orginal_env_core_site = ENV['CORE_SITE']
38
+ ENV['CORE_SITE'] = 'some_env_core_site'
39
39
  session = Roqua::CoreApi.basic_auth_session
40
- ENV['CORE_HOST'] = orginal_env_core_host
41
- expect(session.core_host).to eq('some_env_core_host')
40
+ ENV['CORE_SITE'] = orginal_env_core_site
41
+ expect(session.core_site).to eq('some_env_core_site')
42
42
  end
43
43
  end
44
44
 
@@ -10,17 +10,17 @@ describe OAuthSession do
10
10
  expect(session.access_token).to eq('some_access_token')
11
11
  end
12
12
 
13
- it 'allows to override the core_host variable' do
14
- session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_host: 'some_core_host'
15
- expect(session.core_host).to eq('some_core_host')
13
+ it 'allows to override the core_site variable' do
14
+ session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_site: 'some_core_site'
15
+ expect(session.core_site).to eq('some_core_site')
16
16
  end
17
17
 
18
- it 'defaults the AuthSession core_host CORE_HOST env variable default value' do
19
- orginal_env_core_host = ENV['CORE_HOST']
20
- ENV['CORE_HOST'] = 'some_env_core_host'
18
+ it 'defaults the AuthSession core_site CORE_SITE env variable default value' do
19
+ original_env_core_site = ENV['CORE_SITE']
20
+ ENV['CORE_SITE'] = 'some_env_core_site'
21
21
  session = Roqua::CoreApi.oauth_session access_token: 'some_access_token'
22
- ENV['CORE_HOST'] = orginal_env_core_host
23
- expect(session.core_host).to eq('some_env_core_host')
22
+ ENV['CORE_SITE'] = original_env_core_site
23
+ expect(session.core_site).to eq('some_env_core_site')
24
24
  end
25
25
  end
26
26
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require 'rspec'
2
2
  require 'fabrication'
3
+
4
+ require 'dotenv'
5
+ Dotenv.load(File.expand_path("../../.env", File.dirname(__FILE__)))
6
+
3
7
  require 'roqua-core-api'
4
8
  include Roqua::CoreApi
5
9
  include Roqua::CoreApi::Sessions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '1.17'
153
+ - !ruby/object:Gem::Dependency
154
+ name: dotenv
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.10'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.10'
153
167
  description: Provides authenticated access to Core
154
168
  email: marten@veldthuis.com
155
169
  executables: []
@@ -220,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
234
  version: '0'
221
235
  requirements: []
222
236
  rubyforge_project:
223
- rubygems_version: 2.2.0
237
+ rubygems_version: 2.2.1
224
238
  signing_key:
225
239
  specification_version: 4
226
240
  summary: API wrapper gem around Core's API