amee 3.2.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +1 -24
- data/Gemfile +7 -8
- data/Gemfile.lock +33 -14
- data/README.txt +33 -15
- data/Rakefile +15 -29
- data/VERSION +1 -1
- data/amee.gemspec +21 -24
- data/lib/amee.rb +11 -0
- data/lib/amee/connection.rb +1 -1
- data/lib/amee/logger.rb +10 -5
- data/lib/amee/rails.rb +12 -16
- data/lib/amee/v3.rb +2 -0
- data/lib/amee/v3/collection.rb +4 -6
- data/lib/amee/v3/connection.rb +0 -5
- data/lib/amee/v3/item_definition.rb +12 -19
- data/lib/amee/v3/item_value_definition.rb +6 -7
- data/lib/amee/v3/item_value_definition_list.rb +3 -3
- data/lib/amee/v3/return_value_definition.rb +4 -4
- data/spec/amee_spec.rb +1 -1
- data/spec/cache_spec.rb +1 -1
- data/spec/connection_spec.rb +1 -1
- data/spec/data_category_spec.rb +4 -4
- data/spec/data_item_spec.rb +5 -5
- data/spec/data_item_value_history_spec.rb +1 -1
- data/spec/data_item_value_spec.rb +1 -1
- data/spec/data_object_spec.rb +1 -1
- data/spec/drill_down_spec.rb +1 -1
- data/spec/fixtures/itemdef.xml +1 -6
- data/spec/fixtures/itemdef_441BF4BEA15B.xml +12 -20
- data/spec/item_definition_spec.rb +7 -7
- data/spec/item_value_definition_spec.rb +9 -9
- data/spec/logger_spec.rb +1 -1
- data/spec/object_spec.rb +1 -1
- data/spec/parse_helper_spec.rb +1 -1
- data/spec/profile_category_spec.rb +19 -19
- data/spec/profile_item_spec.rb +16 -16
- data/spec/profile_item_value_spec.rb +1 -1
- data/spec/profile_object_spec.rb +1 -1
- data/spec/profile_spec.rb +1 -1
- data/spec/rails_spec.rb +1 -6
- data/spec/spec_helper.rb +3 -4
- data/spec/user_spec.rb +7 -7
- data/spec/v3/connection_spec.rb +11 -11
- data/spec/v3/item_definition_spec.rb +13 -15
- data/spec/v3/item_value_definition_spec.rb +6 -6
- data/spec/v3/return_value_definition_spec.rb +10 -9
- metadata +87 -79
- data/init.rb +0 -4
- data/lib/amee/config.rb +0 -37
- data/lib/amee/core-extensions/hash.rb +0 -43
- data/rails/init.rb +0 -18
- data/spec/fixtures/rails_config.yml +0 -13
- data/spec/spec_amee_config.rb +0 -46
data/init.rb
DELETED
data/lib/amee/config.rb
DELETED
@@ -1,37 +0,0 @@
|
|
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
|
-
|
@@ -1,43 +0,0 @@
|
|
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/rails/init.rb
DELETED
@@ -1,18 +0,0 @@
|
|
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
|
-
require 'amee'
|
5
|
-
require 'amee/config'
|
6
|
-
require 'amee/core-extensions/hash'
|
7
|
-
require 'amee/rails'
|
8
|
-
|
9
|
-
# Load config/amee.yml
|
10
|
-
amee_config = "#{Rails.root}/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
|
15
|
-
end
|
16
|
-
|
17
|
-
# Add AMEE extensions into ActiveRecord::Base
|
18
|
-
ActiveRecord::Base.class_eval { include AMEE::Rails } if Object.const_defined?("ActiveRecord")
|
data/spec/spec_amee_config.rb
DELETED
@@ -1,46 +0,0 @@
|
|
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
|