idkfa 0.0.2

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+
3
+ environment_id="ruby-1.9.2-p136@idkfa"
4
+
5
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
6
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
7
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
8
+ else
9
+ # If the environment file has not yet been created, use the RVM CLI to select.
10
+ rvm --create "$environment_id"
11
+ fi
12
+
13
+ # Ensure that Bundler is installed, install it if it is not.
14
+ if ! command -v bundle ; then
15
+ printf "The rubygem 'bundler' is not installed, installing it now.\n"
16
+ gem install bundler
17
+ fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in idkfa.gemspec
4
+ gemspec
data/README ADDED
File without changes
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ Dir['gem_tasks/**/*.rake'].each {|rake| load rake }
5
+
6
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc 'Run RSpec'
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.verbose = true
6
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "idkfa/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "idkfa"
7
+ s.version = Idkfa::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Bradley Grzesiak", "Jaymes Waters", "Nick Karpenske"]
10
+ s.email = %w(brad@bendyworks.com jaymes@bendyworks.com nick@bendyworks.com)
11
+ s.homepage = "https://github.com/bendyworks/idkfa"
12
+ s.summary = %q{Simple credentials}
13
+ s.description = %q{Use this gem to store your site credentials in a secure way}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_development_dependency('rspec')
21
+ end
@@ -0,0 +1 @@
1
+ require 'idkfa/base'
@@ -0,0 +1,24 @@
1
+ require 'yaml'
2
+
3
+ module Idkfa
4
+
5
+ class << self
6
+
7
+ def load_keys env = :production, opts = {}
8
+ raise "You must provide :credentials => 'file.yml'" if opts[:credentials].nil?
9
+
10
+ yaml = load_yaml opts[:credentials]
11
+
12
+ yaml[env.to_s].each_pair do |key, value|
13
+ ENV[key.upcase] = value.to_s
14
+ end
15
+ end
16
+
17
+ def load_yaml filename
18
+ YAML.load_file(filename)
19
+ end
20
+ private :load_yaml
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ module Idkfa
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,4 @@
1
+ staging:
2
+ key: staging-key
3
+ production:
4
+ key: prod
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Idkfa do
4
+ let(:config) { {"staging" => {"key" => 'staging-key'}, "production" => {"key" => 'prod'}} }
5
+
6
+ before do
7
+ ENV.delete('KEY')
8
+ end
9
+
10
+ describe '.load_keys' do
11
+ before { subject.stub(:load_yaml => config) }
12
+
13
+ context 'provided staging environment' do
14
+ it "sets ENV[KEY]" do
15
+ Idkfa.load_keys :staging, :credentials => '/foo.txt'
16
+ ENV['KEY'].should == 'staging-key'
17
+ end
18
+ end
19
+
20
+ context 'without credentials' do
21
+ shared_examples_for :raises_without_credentials_path do
22
+ it 'raises' do
23
+ lambda do
24
+ run
25
+ end.should raise_error("You must provide :credentials => 'file.yml'")
26
+ end
27
+ end
28
+
29
+ context 'with environment' do
30
+ def run; Idkfa.load_keys(:development); end
31
+ it_should_behave_like :raises_without_credentials_path
32
+ end
33
+
34
+ context 'without environment' do
35
+ def run; Idkfa.load_keys; end
36
+ it_should_behave_like :raises_without_credentials_path
37
+ end
38
+
39
+ end
40
+ end
41
+
42
+ describe '.load_yaml' do
43
+
44
+ context 'a valid credentials path' do
45
+ it 'returns the parsed file' do
46
+ Idkfa.send(:load_yaml, File.expand_path('../fixtures/dummy.yml', __FILE__)).should == config
47
+ end
48
+ end
49
+
50
+ context 'with invalid credentials path' do
51
+ it 'raises Errno::ENOENT' do
52
+ lambda do
53
+ Idkfa.send(:load_yaml, File.expand_path('../fixtures/non_existent_yaml.yml', __FILE__))
54
+ end.should raise_error(Errno::ENOENT)
55
+ end
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../../lib/idkfa', __FILE__)
2
+
3
+ # Requires supporting ruby files with custom matchers and macros, etc,
4
+ # in spec/support/ and its subdirectories.
5
+ Dir[File.expand_path("../spec/support/**/*.rb", __FILE__)].each {|f| require f}
6
+
7
+ RSpec.configure do |config|
8
+ # == Mock Framework
9
+ #
10
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
11
+ #
12
+ # config.mock_with :mocha
13
+ # config.mock_with :flexmock
14
+ # config.mock_with :rr
15
+ config.mock_with :rspec
16
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: idkfa
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - Bradley Grzesiak
9
+ - Jaymes Waters
10
+ - Nick Karpenske
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2011-04-04 00:00:00 -05:00
16
+ default_executable:
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: rspec
20
+ prerelease: false
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: "0"
27
+ type: :development
28
+ version_requirements: *id001
29
+ description: Use this gem to store your site credentials in a secure way
30
+ email:
31
+ - brad@bendyworks.com
32
+ - jaymes@bendyworks.com
33
+ - nick@bendyworks.com
34
+ executables: []
35
+
36
+ extensions: []
37
+
38
+ extra_rdoc_files: []
39
+
40
+ files:
41
+ - .gitignore
42
+ - .rvmrc
43
+ - Gemfile
44
+ - README
45
+ - Rakefile
46
+ - gem_tasks/rspec.rake
47
+ - idkfa.gemspec
48
+ - lib/idkfa.rb
49
+ - lib/idkfa/base.rb
50
+ - lib/idkfa/version.rb
51
+ - spec/fixtures/dummy.yml
52
+ - spec/idkfa_spec.rb
53
+ - spec/spec_helper.rb
54
+ has_rdoc: true
55
+ homepage: https://github.com/bendyworks/idkfa
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ requirements: []
76
+
77
+ rubyforge_project:
78
+ rubygems_version: 1.5.2
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Simple credentials
82
+ test_files:
83
+ - spec/fixtures/dummy.yml
84
+ - spec/idkfa_spec.rb
85
+ - spec/spec_helper.rb