mingle 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/lib/mingle.rb +10 -0
- data/lib/mingle/configuration.rb +16 -0
- data/lib/mingle/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/lib/mingle/configuration_spec.rb +40 -0
- metadata +4 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6c43c57e98668764982152775a0399842385cf1b
         | 
| 4 | 
            +
              data.tar.gz: 858097239c271b938ffef39e5d8bd32edc0a7582
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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
         | 
    
        data/lib/mingle/version.rb
    CHANGED
    
    
    
        data/spec/dummy/db/test.sqlite3
    CHANGED
    
    | 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. | 
| 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
         |