mingle 0.2.0 → 0.3.0

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: fcce2c5dda956651978f29315020ec7655ab9ab1
4
- data.tar.gz: 57b36c7a7e56f207a4ede2e22be2a941bcc42fce
3
+ metadata.gz: 6c43c57e98668764982152775a0399842385cf1b
4
+ data.tar.gz: 858097239c271b938ffef39e5d8bd32edc0a7582
5
5
  SHA512:
6
- metadata.gz: e7c9c646d2847131d0d1e57d2950c186cc858685c3ae641688e5d2b7e0b136fa47fe8d0d2735259eb00405f619e8b56b00cc94f4bdba07d3e1ec60869458fadc
7
- data.tar.gz: 2fb68c67d1b536c57a18a447f0a220362ae5d231a6b831c85f44b7ea32ba002293994de18148858d4c036d6e2746978c78fb4075df7bf8c5500f06ed12552d97
6
+ metadata.gz: 9224cbced5d10027be8818cc74d44a2e8977212101e76ab38b229e19beb47cbb1804e2ae94ff5abbdae4e30fed96b046808a353b7a0550a62b62286d10739571
7
+ data.tar.gz: eff301fb665c8dd5dbf95dc14082f6fd84314cb7055e2d24b266178454c4586f84115e3184b81c762aa324d53a499e53c0e4aa6d976b759e7a2f69c467e01814
data/lib/mingle.rb CHANGED
@@ -1,8 +1,18 @@
1
1
  require 'mingle/engine'
2
+ require 'mingle/configuration'
2
3
 
3
4
  require 'twitter'
4
5
  require 'fb_graph'
5
6
  require 'instagram'
6
7
 
7
8
  module Mingle
9
+ class << self
10
+ def configure
11
+ yield config
12
+ end
13
+
14
+ def config
15
+ @config ||= Mingle::Configuration.new
16
+ end
17
+ end
8
18
  end
@@ -0,0 +1,16 @@
1
+ module Mingle
2
+ class Configuration
3
+ configs = [
4
+ :facebook_access_token, :twitter_api_key, :twitter_api_secret,
5
+ :twitter_access_token, :twitter_access_token_secret, :instagram_client_id
6
+ ]
7
+
8
+ attr_accessor *configs
9
+
10
+ configs.each do |config|
11
+ define_method config do
12
+ instance_variable_get("@#{config}") || ENV[config.upcase.to_s]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Mingle
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
Binary file
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mingle::Configuration do
4
+ {
5
+ facebook_access_token: 'FACEBOOK_ACCESS_TOKEN',
6
+ twitter_api_key: 'TWITTER_API_KEY',
7
+ twitter_api_secret: 'TWITTER_API_SECRET',
8
+ twitter_access_token: 'TWITTER_ACCESS_TOKEN',
9
+ twitter_access_token_secret: 'TWITTER_ACCESS_TOKEN_SECRET',
10
+ instagram_client_id: 'INSTAGRAM_CLIENT_ID'
11
+ }.each do |key, value|
12
+ before { ENV[value] = 'some-environment-secret' }
13
+
14
+ it "responds to #{key}=" do
15
+ expect(subject).to respond_to "#{key}=".to_sym
16
+ end
17
+
18
+ it "responds to #{key}" do
19
+ expect(subject).to respond_to key
20
+ end
21
+
22
+ describe '##{key}' do
23
+ context 'when it is not configured through Mingle.configure' do
24
+ it "fetches the configuration from the #{value} environment variable" do
25
+ expect(subject.send(key)).to eq 'some-environment-secret'
26
+ end
27
+ end
28
+
29
+ context 'when it has been configured through Mingle' do
30
+ before do
31
+ subject.send "#{key}=", 'some-configured-secret'
32
+ end
33
+
34
+ it 'fetches the configuration from the configuration' do
35
+ expect(subject.send(key)).to eq 'some-configured-secret'
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Gorset
@@ -193,6 +193,7 @@ files:
193
193
  - db/migrate/20140224155358_drop_mingle_feed_items.rb
194
194
  - db/migrate/20140305093743_add_user_name_to_mingle_instagram_photos.rb
195
195
  - lib/mingle.rb
196
+ - lib/mingle/configuration.rb
196
197
  - lib/mingle/engine.rb
197
198
  - lib/mingle/version.rb
198
199
  - lib/tasks/mingle_tasks.rake
@@ -243,6 +244,7 @@ files:
243
244
  - spec/jobs/mingle/facebook/fetch_spec.rb
244
245
  - spec/jobs/mingle/instagram/fetch_spec.rb
245
246
  - spec/jobs/mingle/twitter/fetch_spec.rb
247
+ - spec/lib/mingle/configuration_spec.rb
246
248
  - spec/models/mingle/facebook/post_spec.rb
247
249
  - spec/models/mingle/facebook_spec.rb
248
250
  - spec/models/mingle/hashtag_spec.rb
@@ -325,6 +327,7 @@ test_files:
325
327
  - spec/jobs/mingle/facebook/fetch_spec.rb
326
328
  - spec/jobs/mingle/instagram/fetch_spec.rb
327
329
  - spec/jobs/mingle/twitter/fetch_spec.rb
330
+ - spec/lib/mingle/configuration_spec.rb
328
331
  - spec/models/mingle/facebook/post_spec.rb
329
332
  - spec/models/mingle/facebook_spec.rb
330
333
  - spec/models/mingle/hashtag_spec.rb