app_config 2.1.1 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -3
- data/lib/app_config/storage/config_data.rb +1 -0
- data/lib/app_config/storage/mongo.rb +13 -13
- data/lib/app_config/version.rb +1 -1
- data/spec/app_config/storage/mongo_spec.rb +0 -1
- data/spec/spec_helper.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35fd2897702d6f84752be6616c399de404e77e2d
|
4
|
+
data.tar.gz: 65d8a105d4b606ea1edc931b839360ea04fd6216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb77e2f64fd7379620af5cc23fa8d72a7c9d7cf401a86f40514d124243879aeee9446224673cd4bc6b270e3af2b9d368ae9b628ed5f398cc4d71d0fd722acc2e
|
7
|
+
data.tar.gz: e24fa2a2197fbfbb8c413a1ec3e46139d812797368876a8d4ab42aee5cc0c69b8f6eaf37b13b65aa5ca59888b428f1d4f658684572569520adc765271e1a7c34
|
data/.travis.yml
CHANGED
@@ -4,6 +4,12 @@ rvm:
|
|
4
4
|
- 1.9.3
|
5
5
|
- 2.0.0
|
6
6
|
|
7
|
+
before_script:
|
8
|
+
# Setup test Postgres database.
|
9
|
+
- psql -c 'create database app_config_test;' -U postgres
|
10
|
+
- psql -d app_config_test -U postgres -c 'CREATE TABLE app_config (id bigserial primary key, admin_email character varying(255), api_name character varying(255), api_key character varying(255));'
|
11
|
+
- psql -d app_config_test -U postgres -c "INSERT INTO app_config (admin_email, api_name, api_key) VALUES ('admin@example.com', 'Supr Webz 2.0', 'SUPERAWESOMESERVICE')"
|
12
|
+
|
7
13
|
env:
|
8
14
|
# Ignore warnings when running specs.
|
9
15
|
- RUBYOPT="-W0"
|
@@ -14,3 +20,4 @@ branches:
|
|
14
20
|
|
15
21
|
services:
|
16
22
|
- mongodb
|
23
|
+
- postgres
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# AppConfig [![Build Status](https://travis-ci.org/Oshuma/app_config.png?branch=master)](https://travis-ci.org/Oshuma/app_config) [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=3N885MZB7QCY6&lc=US&item_name=Dale%20Campbell&item_number=app_config¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)
|
2
2
|
|
3
3
|
An easy to use, customizable library to easily store and retrieve application
|
4
|
-
|
4
|
+
configuration; basically anything in 'key/value' pairs.
|
5
5
|
|
6
6
|
AppConfig requires at least Ruby 1.9.
|
7
7
|
|
@@ -22,8 +22,9 @@ end
|
|
22
22
|
AppConfig.admin_email # => 'admin@example.com'
|
23
23
|
```
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
AppConfig also supports many different 'storage types', such as YAML and MongoDB,
|
26
|
+
allowing you to tailor AppConfig to many different use cases. For example,
|
27
|
+
storing your configuration in the same database as your development/production environment.
|
27
28
|
|
28
29
|
|
29
30
|
## YAML
|
@@ -30,9 +30,9 @@ module AppConfig
|
|
30
30
|
# Saves the data back to Mongo. Returns `true`/`false`.
|
31
31
|
def save!
|
32
32
|
if @_id
|
33
|
-
retval = collection.update({ '_id' => @_id}, @data.
|
33
|
+
retval = collection.update({ '_id' => @_id}, @data.to_hash)
|
34
34
|
else
|
35
|
-
retval = collection.save(@data.
|
35
|
+
retval = collection.save(@data.to_hash)
|
36
36
|
end
|
37
37
|
|
38
38
|
!!retval
|
@@ -40,11 +40,6 @@ module AppConfig
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
def setup_connection!
|
44
|
-
@connection = ::Mongo::Connection.new(@options[:host], @options[:port].to_i)
|
45
|
-
authenticate_connection! if @options[:username] && @options[:password]
|
46
|
-
end
|
47
|
-
|
48
43
|
def authenticate_connection!
|
49
44
|
database.authenticate(@options[:username], @options[:password])
|
50
45
|
end
|
@@ -53,6 +48,14 @@ module AppConfig
|
|
53
48
|
@connection && @connection.connected?
|
54
49
|
end
|
55
50
|
|
51
|
+
def collection
|
52
|
+
@collection ||= database.collection(@options[:collection])
|
53
|
+
end
|
54
|
+
|
55
|
+
def database
|
56
|
+
@database ||= @connection.db(@options[:database])
|
57
|
+
end
|
58
|
+
|
56
59
|
def fetch_data!
|
57
60
|
raise 'Not connected to MongoDB' unless connected?
|
58
61
|
|
@@ -60,12 +63,9 @@ module AppConfig
|
|
60
63
|
@_id = @data._id
|
61
64
|
end
|
62
65
|
|
63
|
-
def
|
64
|
-
@
|
65
|
-
|
66
|
-
|
67
|
-
def collection
|
68
|
-
@collection ||= database.collection(@options[:collection])
|
66
|
+
def setup_connection!
|
67
|
+
@connection = ::Mongo::Connection.new(@options[:host], @options[:port].to_i)
|
68
|
+
authenticate_connection! if @options[:username] && @options[:password]
|
69
69
|
end
|
70
70
|
|
71
71
|
end # Mongo
|
data/lib/app_config/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -33,6 +33,10 @@ RSpec.configure do |config|
|
|
33
33
|
begin
|
34
34
|
load_mongo_test_config(mongo) if load_test_data
|
35
35
|
config_for({mongo: mongo}.merge(opts))
|
36
|
+
|
37
|
+
collection = AppConfig.class_variable_get(:@@storage)
|
38
|
+
.send(:collection)
|
39
|
+
.drop
|
36
40
|
rescue Mongo::ConnectionFailure
|
37
41
|
pending "***** Mongo specs require a running MongoDB server *****"
|
38
42
|
end
|