sedative 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.3-p0@sedative"
8
+
9
+ #
10
+ # Uncomment the following lines if you want to verify rvm version per project
11
+ #
12
+ # rvmrc_rvm_version="1.10.1" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+ #
18
+
19
+ #
20
+ # Uncomment following line if you want options to be set only for given project.
21
+ #
22
+ # PROJECT_JRUBY_OPTS=( --1.9 )
23
+ #
24
+ # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
25
+ #
26
+ # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
27
+ #
28
+
29
+ #
30
+ # First we attempt to load the desired environment directly from the environment
31
+ # file. This is very fast and efficient compared to running through the entire
32
+ # CLI and selector. If you want feedback on which environment was used then
33
+ # insert the word 'use' after --create as this triggers verbose mode.
34
+ #
35
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
36
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
37
+ then
38
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
39
+
40
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
41
+ then
42
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
43
+ fi
44
+ else
45
+ # If the environment file has not yet been created, use the RVM CLI to select.
46
+ if ! rvm --create "$environment_id"
47
+ then
48
+ echo "Failed to create RVM environment '${environment_id}'."
49
+ return 1
50
+ fi
51
+ fi
52
+
53
+ #
54
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
55
+ # it be automatically loaded. Uncomment the following and adjust the filename if
56
+ # necessary.
57
+ #
58
+ # filename=".gems"
59
+ # if [[ -s "$filename" ]]
60
+ # then
61
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
62
+ # fi
63
+
64
+ # If you use bundler, this might be useful to you:
65
+ # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
66
+ # then
67
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
68
+ # gem install bundler
69
+ # fi
70
+ # if [[ -s Gemfile ]] && command -v bundle
71
+ # then
72
+ # bundle install
73
+ # fi
74
+
75
+ if [[ $- == *i* ]] # check for interactive shells
76
+ then
77
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
78
+ else
79
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
80
+ fi
81
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in setter.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Nathan Borgo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Sedative
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sedative'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sedative
18
+
19
+ And run the generator:
20
+
21
+ $ rails g sedative:install
22
+
23
+ By default, it will create `Settings` and `Switches` variables. You can change this by adding arguments to the generator. For a single variable called `Constants`, do this:
24
+
25
+ $ rails g sedative:install constants
26
+
27
+ ## Usage
28
+
29
+ Open up `config/settings/settings.yml`, or whatever you named your settings variable to, and stick with the pattern. It's really DRY and convenient having all your settings in one file.
30
+
31
+ Beyond convenience, the settings also change based on your environment. I like to keep API information here. You can do something like this:
32
+
33
+ development:
34
+ mailchimp:
35
+ token: [Your development API token]
36
+ secret: [Your development API key]
37
+
38
+ production:
39
+ mailchimp:
40
+ token: [Your production API token]
41
+ secret: [Your production API secret]
42
+
43
+ When you need to connect to the service, using the settings is simple:
44
+
45
+ OAuth2::Client.new Settings.mailchimp.id,
46
+ Settings.mailchimp.secret,
47
+ site: 'https://login.mailchimp.com',
48
+ authorize_url: '/oauth2/authorize',
49
+ token_url: '/oauth2/token'
50
+
51
+ There you go.
52
+
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ module Sedative
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+ argument :settings, type: :array, default: ["constants", "switches"]
6
+
7
+ def generate_install
8
+ settings.each do |setting|
9
+ copy_file "blank.yml", "config/settings/#{setting}.yml"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ development:
2
+ example_key: development value
3
+ nested_key:
4
+ token: 39y34nkjsd
5
+ secret: heriu438u23981ndoiji
6
+
7
+ test:
8
+ example_key: test value
9
+
10
+ staging:
11
+ example_key: staging value
12
+
13
+ production:
14
+ example_key: production value
@@ -0,0 +1,5 @@
1
+ class Railtie < Rails::Railtie
2
+ initializer "sedative.load_settings_into_mock_objects" do
3
+ Sedative.initialize
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Sedative
2
+ VERSION = "0.0.1"
3
+ end
data/lib/sedative.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'sedative/version'
2
+ require 'sedative/railtie'
3
+ require 'hashie'
4
+
5
+ module Sedative
6
+ def self.initialize
7
+ setting_names.each do |name|
8
+ Object.const_set pretty_name(name), hash(name)
9
+ end
10
+ end
11
+
12
+ def self.setting_names
13
+ settings = []
14
+ Dir.glob("config/settings/*.yml").each do |file|
15
+ settings << File.basename(file, ".yml")
16
+ end
17
+ settings
18
+ end
19
+
20
+ def self.hash(file_name)
21
+ Hashie::Mash.new YAML.load_file("#{Rails.root}/config/settings/#{file_name}.yml")[Rails.env]
22
+ end
23
+
24
+ def self.pretty_name(name)
25
+ name.split("_").map(&:capitalize).join.gsub(" ", "")
26
+ end
27
+ end
data/sedative.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/sedative/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Nathan Borgo"]
6
+ gem.email = ["nathan@subtractiv.com"]
7
+ gem.description = %q{Sedative helps you keep track of all your settings. They can be Constants, Switches, or whatever. They're kept in a pseudo-object for convenience. Your settings are read from a yaml file and can be individually loaded for each environment.}
8
+ gem.summary = %q{Sedative makes managing your settings easy.}
9
+ gem.homepage = "http://www.github.com/subtractiv/sedative"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "sedative"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Sedative::VERSION
17
+
18
+ gem.add_dependency 'hashie', '~> 1.0'
19
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sedative
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nathan Borgo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashie
16
+ requirement: &70127697780540 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70127697780540
25
+ description: Sedative helps you keep track of all your settings. They can be Constants,
26
+ Switches, or whatever. They're kept in a pseudo-object for convenience. Your settings
27
+ are read from a yaml file and can be individually loaded for each environment.
28
+ email:
29
+ - nathan@subtractiv.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - .rvmrc
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - lib/generators/sedative/install/install_generator.rb
41
+ - lib/generators/sedative/install/templates/blank.yml
42
+ - lib/sedative.rb
43
+ - lib/sedative/railtie.rb
44
+ - lib/sedative/version.rb
45
+ - sedative.gemspec
46
+ homepage: http://www.github.com/subtractiv/sedative
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.10
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Sedative makes managing your settings easy.
70
+ test_files: []