confu 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ .bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in confu.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rspec-rails', '2.0.0.beta.22'
8
+ gem 'ruby-debug'
9
+ end
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ confu (0.0.1)
5
+ rails (~> 3.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.0)
12
+ actionpack (= 3.0.0)
13
+ mail (~> 2.2.5)
14
+ actionpack (3.0.0)
15
+ activemodel (= 3.0.0)
16
+ activesupport (= 3.0.0)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4.1)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.12)
22
+ rack-test (~> 0.5.4)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.0)
25
+ activesupport (= 3.0.0)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4.1)
28
+ activerecord (3.0.0)
29
+ activemodel (= 3.0.0)
30
+ activesupport (= 3.0.0)
31
+ arel (~> 1.0.0)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.0)
34
+ activemodel (= 3.0.0)
35
+ activesupport (= 3.0.0)
36
+ activesupport (3.0.0)
37
+ arel (1.0.1)
38
+ activesupport (~> 3.0.0)
39
+ builder (2.1.2)
40
+ columnize (0.3.1)
41
+ diff-lcs (1.1.2)
42
+ erubis (2.6.6)
43
+ abstract (>= 1.0.0)
44
+ i18n (0.4.1)
45
+ linecache (0.43)
46
+ mail (2.2.6.1)
47
+ activesupport (>= 2.3.6)
48
+ mime-types
49
+ treetop (>= 1.4.5)
50
+ mime-types (1.16)
51
+ polyglot (0.3.1)
52
+ rack (1.2.1)
53
+ rack-mount (0.6.13)
54
+ rack (>= 1.0.0)
55
+ rack-test (0.5.6)
56
+ rack (>= 1.0)
57
+ rails (3.0.0)
58
+ actionmailer (= 3.0.0)
59
+ actionpack (= 3.0.0)
60
+ activerecord (= 3.0.0)
61
+ activeresource (= 3.0.0)
62
+ activesupport (= 3.0.0)
63
+ bundler (~> 1.0.0)
64
+ railties (= 3.0.0)
65
+ railties (3.0.0)
66
+ actionpack (= 3.0.0)
67
+ activesupport (= 3.0.0)
68
+ rake (>= 0.8.4)
69
+ thor (~> 0.14.0)
70
+ rake (0.8.7)
71
+ rspec (2.0.0.beta.22)
72
+ rspec-core (= 2.0.0.beta.22)
73
+ rspec-expectations (= 2.0.0.beta.22)
74
+ rspec-mocks (= 2.0.0.beta.22)
75
+ rspec-core (2.0.0.beta.22)
76
+ rspec-expectations (2.0.0.beta.22)
77
+ diff-lcs (>= 1.1.2)
78
+ rspec-mocks (2.0.0.beta.22)
79
+ rspec-core (= 2.0.0.beta.22)
80
+ rspec-expectations (= 2.0.0.beta.22)
81
+ rspec-rails (2.0.0.beta.22)
82
+ rspec (= 2.0.0.beta.22)
83
+ ruby-debug (0.10.3)
84
+ columnize (>= 0.1)
85
+ ruby-debug-base (~> 0.10.3.0)
86
+ ruby-debug-base (0.10.3)
87
+ linecache (>= 0.3)
88
+ thor (0.14.3)
89
+ treetop (1.4.8)
90
+ polyglot (>= 0.3.1)
91
+ tzinfo (0.3.23)
92
+
93
+ PLATFORMS
94
+ ruby
95
+
96
+ DEPENDENCIES
97
+ bundler (>= 1.0.0)
98
+ confu!
99
+ rails (~> 3.0.0)
100
+ rspec-rails (= 2.0.0.beta.22)
101
+ ruby-debug
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,47 @@
1
+ Confu
2
+ =====
3
+
4
+ Confu is a micro-mini (think wicked weasel sized) utility I extracted from a couple of projects. Influenced by
5
+ http://github.com/cjbottaro/app_config/tree/master
6
+ and
7
+ http://github.com/railsmonk/configuration-file-plugin/tree/master
8
+
9
+ The main thing I wanted to change is that files are separated not by environment, but by concern. Each file can use merging (described below) to avoid repeating, and accidentally miss adding new stuff (which I constantly do). And you can also use ignore + yml.sample approach for sensitive config.
10
+
11
+ Installation
12
+ ============
13
+
14
+ Add it in your Gemfile
15
+
16
+ gem 'confu'
17
+
18
+ From your project's RAILS_ROOT, run:
19
+
20
+ rails generate confu:install
21
+
22
+ This will create sample config/site/app.yml file.
23
+ Then you put multiple yml files in the site folder. Each config file will result in {file_name}Config constant defined, loading the current environment's section values.
24
+
25
+ So if you have site.yml, containing
26
+
27
+ development:
28
+ home_page_entries: 3
29
+ production:
30
+ home_page_entries: 5
31
+
32
+ You will have SiteConfig defined, and SiteConfig.home_page_entries returning 3 and 5 in development and production, respectively.
33
+
34
+ YAML has some neat DRY stuff, actually - check this out:
35
+ http://www.yaml.org/refcard.html
36
+
37
+
38
+ One thing that comes in handy is merging keys from mapping - like this.
39
+
40
+ development: &default
41
+ home_page_entries: 3
42
+ admin_entries: 4
43
+ production:
44
+ <<: *default
45
+ home_page_entries: 5
46
+
47
+ Copyright (c) 2009 Petyo Ivanov, released under the MIT license
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/confu/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "confu"
6
+ s.version = Confu::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Petyo Ivanov", "Krasimir Angelov"]
9
+ s.email = ["krasio@codingspree.net"]
10
+ s.homepage = "http://rubygems.org/gems/confu"
11
+ s.summary = "Yet another *fu - this time for rails configuration made easier"
12
+ s.description = "Yet another *fu - this time for rails configuration made easier"
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "confu"
16
+
17
+ s.add_dependency "rails", "~> 3.0.0"
18
+ s.add_development_dependency "bundler", ">= 1.0.0"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
22
+ s.require_path = 'lib'
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'confu/confu_railtie.rb' if defined?(Rails)
2
+
3
+ module Confu
4
+ class Config
5
+ def initialize(content)
6
+ @content = content.symbolize_keys
7
+ end
8
+
9
+ def method_missing(id)
10
+ @content.keys.include?(id) ? @content[id] : super
11
+ end
12
+ end
13
+
14
+ def self.load_config_files(path)
15
+ Dir[File.join(path, '*yml')].each do |file|
16
+ name = File.basename(file, '.yml').camelize + 'Config'
17
+ yml = YAML.load_file(file)[::Rails.env]
18
+ Object.const_set(name, Config.new(yml))
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Confu
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ config.before_configuration do
5
+ Confu.load_config_files(File.join(::Rails.root, 'config', 'site'))
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Confu
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ module Confu
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates example config/site/app.yml"
7
+
8
+ def copy_config
9
+ template "app.yml", "config/site/app.yml"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ development: &default
2
+ foo: bar
3
+
4
+ test:
5
+ <<: *default
6
+
7
+ production:
8
+ <<: *default
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe Confu do
4
+ let(:config) { Confu::Config.new(:foo => "bar") }
5
+
6
+ it "should respond to given content" do
7
+ config.foo.should == "bar"
8
+ end
9
+
10
+ it "should throw error if not defined" do
11
+ expect {config.bar}.to raise_error NoMethodError
12
+ end
13
+
14
+ it "should parse files"
15
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require 'active_support/core_ext/hash/keys'
6
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'confu.rb')
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: confu
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Petyo Ivanov
14
+ - Krasimir Angelov
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-10-12 00:00:00 +02:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rails
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 7
31
+ segments:
32
+ - 3
33
+ - 0
34
+ - 0
35
+ version: 3.0.0
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 23
47
+ segments:
48
+ - 1
49
+ - 0
50
+ - 0
51
+ version: 1.0.0
52
+ type: :development
53
+ version_requirements: *id002
54
+ description: Yet another *fu - this time for rails configuration made easier
55
+ email:
56
+ - krasio@codingspree.net
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files: []
62
+
63
+ files:
64
+ - .gitignore
65
+ - .rspec
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - MIT-LICENSE
69
+ - README
70
+ - Rakefile
71
+ - confu.gemspec
72
+ - lib/confu.rb
73
+ - lib/confu/confu_railtie.rb
74
+ - lib/confu/version.rb
75
+ - lib/generators/confu/install_generator.rb
76
+ - lib/generators/templates/app.yml
77
+ - spec/confu_spec.rb
78
+ - spec/spec_helper.rb
79
+ has_rdoc: true
80
+ homepage: http://rubygems.org/gems/confu
81
+ licenses: []
82
+
83
+ post_install_message:
84
+ rdoc_options: []
85
+
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 23
103
+ segments:
104
+ - 1
105
+ - 3
106
+ - 6
107
+ version: 1.3.6
108
+ requirements: []
109
+
110
+ rubyforge_project: confu
111
+ rubygems_version: 1.3.7
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Yet another *fu - this time for rails configuration made easier
115
+ test_files: []
116
+