amee 3.0.1 → 3.1.1
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.
- data/CHANGELOG.txt +5 -0
- data/VERSION +1 -1
- data/amee.gemspec +6 -2
- data/lib/amee/config.rb +37 -0
- data/lib/amee/core-extensions/hash.rb +43 -0
- data/lib/amee/rails.rb +9 -9
- data/rails/init.rb +7 -4
- data/spec/fixtures/rails_config.yml +13 -0
- data/spec/spec_amee_config.rb +46 -0
- metadata +8 -4
data/CHANGELOG.txt
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
|
+
== 3.1.0
|
4
|
+
* Back-ported the update in amee-ruby 4.1.0 to add an option to set connection
|
5
|
+
details using environment variables, for instance in Heroku deployments, to
|
6
|
+
create a Rails 2.3 compatible version of the gem with this feature.
|
7
|
+
|
3
8
|
== 3.0.0
|
4
9
|
* Add some pre-release functionality for AMEEconnect v3 in order to support
|
5
10
|
AMEEappkit gems.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.1
|
data/amee.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{amee}
|
8
|
-
s.version = "3.
|
8
|
+
s.version = "3.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["James Smith", "James Hetherington", "Andrew Hill", "Andrew Berkeley"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-10-03}
|
13
13
|
s.default_executable = %q{ameesh}
|
14
14
|
s.email = %q{james@floppy.org.uk}
|
15
15
|
s.executables = ["ameesh"]
|
@@ -39,7 +39,9 @@ Gem::Specification.new do |s|
|
|
39
39
|
"init.rb",
|
40
40
|
"lib/amee.rb",
|
41
41
|
"lib/amee/collection.rb",
|
42
|
+
"lib/amee/config.rb",
|
42
43
|
"lib/amee/connection.rb",
|
44
|
+
"lib/amee/core-extensions/hash.rb",
|
43
45
|
"lib/amee/data_category.rb",
|
44
46
|
"lib/amee/data_item.rb",
|
45
47
|
"lib/amee/data_item_value.rb",
|
@@ -99,6 +101,7 @@ Gem::Specification.new do |s|
|
|
99
101
|
"spec/fixtures/ivdlist.xml",
|
100
102
|
"spec/fixtures/ivdlist_BD88D30D1214.xml",
|
101
103
|
"spec/fixtures/parse_test.xml",
|
104
|
+
"spec/fixtures/rails_config.yml",
|
102
105
|
"spec/fixtures/return_value_definition.xml",
|
103
106
|
"spec/fixtures/return_value_definition_list.xml",
|
104
107
|
"spec/fixtures/v0_data_transport_transport_drill_transportType_Car1.xml",
|
@@ -114,6 +117,7 @@ Gem::Specification.new do |s|
|
|
114
117
|
"spec/profile_spec.rb",
|
115
118
|
"spec/rails_spec.rb",
|
116
119
|
"spec/spec.opts",
|
120
|
+
"spec/spec_amee_config.rb",
|
117
121
|
"spec/spec_helper.rb",
|
118
122
|
"spec/user_spec.rb",
|
119
123
|
"spec/v3/connection_spec.rb",
|
data/lib/amee/config.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Copyright (C) 2008-2011 AMEE UK Ltd. - http://www.amee.com
|
2
|
+
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
|
3
|
+
|
4
|
+
module AMEE
|
5
|
+
|
6
|
+
class Config
|
7
|
+
|
8
|
+
|
9
|
+
# Tries to load defaults from a yaml file, then if there are environment variables
|
10
|
+
# present (i.e. if we're using a service like heroku for determine them, or we want to
|
11
|
+
# manually override them), uses those values instead
|
12
|
+
def self.setup(amee_config_file = nil, environment = 'test')
|
13
|
+
|
14
|
+
if amee_config_file
|
15
|
+
# first try loading the yaml file
|
16
|
+
yaml_config = YAML.load_file(amee_config_file)
|
17
|
+
config = yaml_config[environment]
|
18
|
+
|
19
|
+
# make config[:username] possible instead of just config['username']
|
20
|
+
config.recursive_symbolize_keys!
|
21
|
+
else
|
22
|
+
config = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
# then either override, or load in config deets from heroku
|
26
|
+
config[:username] = ENV['AMEE_USERNAME'] if ENV['AMEE_USERNAME']
|
27
|
+
config[:server] = ENV['AMEE_SERVER'] if ENV['AMEE_SERVER']
|
28
|
+
config[:password] = ENV['AMEE_PASSWORD'] if ENV['AMEE_PASSWORD']
|
29
|
+
|
30
|
+
return config
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (C) 2011 AMEE UK Ltd. - http://www.amee.com
|
2
|
+
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
|
3
|
+
|
4
|
+
# :title: Class: Hash
|
5
|
+
|
6
|
+
class Hash
|
7
|
+
|
8
|
+
# Return a new instance of <i>Hash</i> which represents the same data as
|
9
|
+
# <tt>self</tt> but with all keys - including those of sub-hashes - symbolized
|
10
|
+
#
|
11
|
+
def recursive_symbolize_keys
|
12
|
+
new_hash = {}
|
13
|
+
self.each_pair do |k,v|
|
14
|
+
new_hash[k.to_sym] = value_or_symbolize_value(v)
|
15
|
+
end
|
16
|
+
new_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
# Modify <tt>self</tt> in place, transforming all keys - including those of
|
20
|
+
# sub-hashes - in to symbols
|
21
|
+
#
|
22
|
+
def recursive_symbolize_keys!
|
23
|
+
self.each_pair do |k,v|
|
24
|
+
value = delete(k)
|
25
|
+
self[k.to_sym] = value_or_symbolize_value(value)
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Symbolize any hash key or sub-hash key containing within <tt>value</tt>.
|
33
|
+
def value_or_symbolize_value(value)
|
34
|
+
if value.is_a? Hash
|
35
|
+
return value.recursive_symbolize_keys
|
36
|
+
elsif value.is_a? Array
|
37
|
+
return value.map { |elem| value_or_symbolize_value(elem) }
|
38
|
+
else
|
39
|
+
return value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/lib/amee/rails.rb
CHANGED
@@ -12,23 +12,23 @@ module AMEE
|
|
12
12
|
def self.global(options = {})
|
13
13
|
unless @connection
|
14
14
|
$AMEE_CONFIG ||= {} # Make default values nil
|
15
|
-
if $AMEE_CONFIG[
|
15
|
+
if $AMEE_CONFIG[:ssl] == false
|
16
16
|
options.merge! :ssl => false
|
17
17
|
end
|
18
|
-
if $AMEE_CONFIG[
|
19
|
-
options.merge! :retries => $AMEE_CONFIG[
|
18
|
+
if $AMEE_CONFIG[:retries]
|
19
|
+
options.merge! :retries => $AMEE_CONFIG[:retries].to_i
|
20
20
|
end
|
21
|
-
if $AMEE_CONFIG[
|
22
|
-
options.merge! :timeout => $AMEE_CONFIG[
|
21
|
+
if $AMEE_CONFIG[:timeout]
|
22
|
+
options.merge! :timeout => $AMEE_CONFIG[:timeout].to_i
|
23
23
|
end
|
24
|
-
if $AMEE_CONFIG[
|
24
|
+
if $AMEE_CONFIG[:cache] == 'rails'
|
25
25
|
# Pass in the rails cache store
|
26
26
|
options[:cache_store] = ActionController::Base.cache_store
|
27
27
|
else
|
28
|
-
options[:cache] ||= $AMEE_CONFIG[
|
28
|
+
options[:cache] ||= $AMEE_CONFIG[:cache] if $AMEE_CONFIG[:cache].present?
|
29
29
|
end
|
30
|
-
options[:enable_debug] ||= $AMEE_CONFIG[
|
31
|
-
@connection = self.connect($AMEE_CONFIG[
|
30
|
+
options[:enable_debug] ||= $AMEE_CONFIG[:debug] if $AMEE_CONFIG[:debug].present?
|
31
|
+
@connection = self.connect($AMEE_CONFIG[:server], $AMEE_CONFIG[:username], $AMEE_CONFIG[:password], options)
|
32
32
|
# Also store as $amee for backwards compatibility, though this is now deprecated
|
33
33
|
$amee = @connection
|
34
34
|
end
|
data/rails/init.rb
CHANGED
@@ -2,13 +2,16 @@
|
|
2
2
|
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
|
3
3
|
|
4
4
|
require 'amee'
|
5
|
+
require 'amee/config'
|
6
|
+
require 'amee/core-extensions/hash'
|
5
7
|
require 'amee/rails'
|
6
8
|
|
7
9
|
# Load config/amee.yml
|
8
|
-
amee_config = "
|
9
|
-
if File.exist?
|
10
|
-
|
11
|
-
|
10
|
+
amee_config = "config/amee.yml"
|
11
|
+
if File.exist? amee_config
|
12
|
+
$AMEE_CONFIG = AMEE::Config.setup(amee_config, Rails.env)
|
13
|
+
else
|
14
|
+
$AMEE_CONFIG = AMEE::Config.setup
|
12
15
|
end
|
13
16
|
|
14
17
|
# Add AMEE extensions into ActiveRecord::Base
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright (C) 2008-2011 AMEE UK Ltd. - http://www.amee.com
|
2
|
+
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
|
3
|
+
require 'spec_helper.rb'
|
4
|
+
|
5
|
+
describe AMEE::Config do
|
6
|
+
|
7
|
+
# make sure environment variables are clear for each test
|
8
|
+
before(:each) do
|
9
|
+
ENV['AMEE_SERVER'] = nil
|
10
|
+
ENV['AMEE_USERNAME'] = nil
|
11
|
+
ENV['AMEE_PASSWORD'] = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
context "loading config details from the environment"
|
15
|
+
|
16
|
+
it "should let us use ENV variables so we can use heroku" do
|
17
|
+
# fake the ENV variables setting
|
18
|
+
ENV['AMEE_SERVER'] = "stage.amee.com"
|
19
|
+
ENV['AMEE_USERNAME'] = "joe_shmoe"
|
20
|
+
ENV['AMEE_PASSWORD'] = "top_sekrit123"
|
21
|
+
|
22
|
+
amee_config = AMEE::Config.setup()
|
23
|
+
|
24
|
+
amee_config[:username].should eq "joe_shmoe"
|
25
|
+
amee_config[:server].should eq "stage.amee.com"
|
26
|
+
amee_config[:password].should eq "top_sekrit123"
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context "loading config details from a yaml file" do
|
31
|
+
|
32
|
+
it "so we don't rely on heroku ALL the time" do
|
33
|
+
|
34
|
+
config_path = File.dirname(__FILE__)+'/fixtures/rails_config.yml'
|
35
|
+
|
36
|
+
amee_config = AMEE::Config.setup(config_path, 'test')
|
37
|
+
|
38
|
+
amee_config[:username].should eq "joe_shmoe"
|
39
|
+
amee_config[:server].should eq "stage.amee.com"
|
40
|
+
amee_config[:password].should eq "top_sekrit123"
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 1
|
10
|
+
version: 3.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Smith
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-
|
21
|
+
date: 2011-10-03 00:00:00 +01:00
|
22
22
|
default_executable: ameesh
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -221,7 +221,9 @@ files:
|
|
221
221
|
- init.rb
|
222
222
|
- lib/amee.rb
|
223
223
|
- lib/amee/collection.rb
|
224
|
+
- lib/amee/config.rb
|
224
225
|
- lib/amee/connection.rb
|
226
|
+
- lib/amee/core-extensions/hash.rb
|
225
227
|
- lib/amee/data_category.rb
|
226
228
|
- lib/amee/data_item.rb
|
227
229
|
- lib/amee/data_item_value.rb
|
@@ -281,6 +283,7 @@ files:
|
|
281
283
|
- spec/fixtures/ivdlist.xml
|
282
284
|
- spec/fixtures/ivdlist_BD88D30D1214.xml
|
283
285
|
- spec/fixtures/parse_test.xml
|
286
|
+
- spec/fixtures/rails_config.yml
|
284
287
|
- spec/fixtures/return_value_definition.xml
|
285
288
|
- spec/fixtures/return_value_definition_list.xml
|
286
289
|
- spec/fixtures/v0_data_transport_transport_drill_transportType_Car1.xml
|
@@ -296,6 +299,7 @@ files:
|
|
296
299
|
- spec/profile_spec.rb
|
297
300
|
- spec/rails_spec.rb
|
298
301
|
- spec/spec.opts
|
302
|
+
- spec/spec_amee_config.rb
|
299
303
|
- spec/spec_helper.rb
|
300
304
|
- spec/user_spec.rb
|
301
305
|
- spec/v3/connection_spec.rb
|