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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 318df4378067f6ec5f0e70c42ab7af32ee235acf
4
- data.tar.gz: 931193b4ba2fa09e79c0fd0772598cbde0deba45
3
+ metadata.gz: 35fd2897702d6f84752be6616c399de404e77e2d
4
+ data.tar.gz: 65d8a105d4b606ea1edc931b839360ea04fd6216
5
5
  SHA512:
6
- metadata.gz: ef84fdbb0dfa7c9deab6351d0a54eaa7f60c2c0758d49fd17c78ab5d6070762a17e6e93204a4c46ff1b79f1813623df549f5d594dd46d3c36aca1086a1794461
7
- data.tar.gz: 7376e88e227b05ea545515109edff9426ab5d6f92702d1f799e04211bc66b5607f9be917c11587c8595653d29195799082fe7a0b63c86e135441e0bc8d64a58f
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_config (2.1.0)
4
+ app_config (2.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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&currency_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
- (or library) configuration, API keys or basically anything in 'key/value' pairs.
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
- You may also specify the storage method along with options specific to that storage method.
26
- Check the [wiki](https://github.com/Oshuma/app_config/wiki) for more usage examples.
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
@@ -11,6 +11,7 @@ module AppConfig
11
11
  def to_hash
12
12
  marshal_dump
13
13
  end
14
+ alias_method :to_h, :to_hash
14
15
 
15
16
  end
16
17
  end
@@ -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.to_h)
33
+ retval = collection.update({ '_id' => @_id}, @data.to_hash)
34
34
  else
35
- retval = collection.save(@data.to_h)
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 database
64
- @database ||= @connection.db(@options[:database])
65
- end
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
@@ -1,3 +1,3 @@
1
1
  module AppConfig
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.3'
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- # TODO: Drop the Mongo test db before running specs.
4
3
  describe AppConfig::Storage::Mongo do
5
4
 
6
5
  before(:all) do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Campbell