skyfallsin-simple_settings 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/LICENSE +20 -0
- data/README.rdoc +54 -0
- data/Rakefile +47 -0
- data/TODO +4 -0
- data/lib/simple_settings.rb +37 -0
- metadata +59 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 YOUR NAME
|
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.rdoc
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
= Simple Settings
|
2
|
+
|
3
|
+
This gem exposes a Settings object for your Rails/Merb/Ruby apps.
|
4
|
+
Attempts to load up "config/settings.yml" based on RAILS_ROOT or MERB_ROOT.
|
5
|
+
Otherwise, tries to load "settings.yml"
|
6
|
+
You can also assign variables on runtime if you choose to.
|
7
|
+
|
8
|
+
== Example
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'simple_settings'
|
12
|
+
|
13
|
+
# ----------------
|
14
|
+
Settings.drb_server = "mydrb.com"
|
15
|
+
|
16
|
+
puts Settings[:drb_server]
|
17
|
+
#=> "mydrb.com"
|
18
|
+
puts Settings.drb_server
|
19
|
+
#=> "mydrb.com"
|
20
|
+
|
21
|
+
# ----------------
|
22
|
+
Settings.xmpp = {:server => "localhost", :port => 5280}
|
23
|
+
|
24
|
+
puts Settings.xmpp.server
|
25
|
+
#=> "localhost"
|
26
|
+
puts Settings[:xmpp][:port]
|
27
|
+
#=> 5280
|
28
|
+
|
29
|
+
== Example settings.yml
|
30
|
+
my_settings:
|
31
|
+
xmpp:
|
32
|
+
server: localhost
|
33
|
+
port: 5280
|
34
|
+
|
35
|
+
drb_server:
|
36
|
+
server: 'mydrb.com'
|
37
|
+
port: 9090
|
38
|
+
|
39
|
+
development:
|
40
|
+
<< *my_settings
|
41
|
+
|
42
|
+
testing:
|
43
|
+
<< *my_settings
|
44
|
+
|
45
|
+
production:
|
46
|
+
<< *my_settings
|
47
|
+
xmpp:
|
48
|
+
server: 'myxmpp.com'
|
49
|
+
port: 80
|
50
|
+
|
51
|
+
|
52
|
+
== Acknowledgements
|
53
|
+
|
54
|
+
Michael Bleigh, for his awesome Mash gem.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
GEM = "simple_settings"
|
7
|
+
GEM_VERSION = "0.0.1"
|
8
|
+
AUTHOR = "Your Name"
|
9
|
+
EMAIL = "Your Email"
|
10
|
+
HOMEPAGE = "http://example.com"
|
11
|
+
SUMMARY = "A gem that provides..."
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = GEM
|
15
|
+
s.version = GEM_VERSION
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
19
|
+
s.summary = SUMMARY
|
20
|
+
s.description = s.summary
|
21
|
+
s.author = AUTHOR
|
22
|
+
s.email = EMAIL
|
23
|
+
s.homepage = HOMEPAGE
|
24
|
+
|
25
|
+
# Uncomment this to add a dependency
|
26
|
+
# s.add_dependency "foo"
|
27
|
+
|
28
|
+
s.require_path = 'lib'
|
29
|
+
s.autorequire = GEM
|
30
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
34
|
+
pkg.gem_spec = spec
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "install the gem locally"
|
38
|
+
task :install => [:package] do
|
39
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "create a gemspec file"
|
43
|
+
task :make_spec do
|
44
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
45
|
+
file.puts spec.to_ruby
|
46
|
+
end
|
47
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'mash'
|
2
|
+
require 'yaml'
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
class SettingsHandler < Mash
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def load!(name, value)
|
10
|
+
if value.kind_of?(Hash)
|
11
|
+
instance.send("#{name}=", Mash.new(value))
|
12
|
+
else
|
13
|
+
instance.send("#{name}=", value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_from_yaml!(filename, complain=true)
|
18
|
+
if File.exists?(filename)
|
19
|
+
data = YAML.load(File.read(filename))
|
20
|
+
data.each{ |key, val| load!(key, val) } if data
|
21
|
+
else
|
22
|
+
puts "[simple_settings] Could not find settings file -- #{filename}" if complain
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
config_file = if Object.const_defined?(:RAILS_ROOT)
|
29
|
+
File.join(RAILS_ROOT, "config", "settings.yml")
|
30
|
+
elsif Object.const_defined?(:MERB_ROOT)
|
31
|
+
File.join(MERB_ROOT, "config", "settings.yml")
|
32
|
+
else
|
33
|
+
"settings.yml"
|
34
|
+
end
|
35
|
+
|
36
|
+
SettingsHandler.load_from_yaml!(config_file)
|
37
|
+
SimpleSettings = Settings = SettingsHandler.instance
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skyfallsin-simple_settings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pradeep Elankumaran
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-29 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A gem that provides a Settings object for Ruby/Rails/Merb apps
|
17
|
+
email: Your Email
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- LICENSE
|
25
|
+
- TODO
|
26
|
+
files:
|
27
|
+
- LICENSE
|
28
|
+
- README.rdoc
|
29
|
+
- Rakefile
|
30
|
+
- TODO
|
31
|
+
- lib/simple_settings.rb
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://github.com/skyfallsin/simple_settings
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.2.0
|
55
|
+
signing_key:
|
56
|
+
specification_version: 2
|
57
|
+
summary: A gem that provides a Settings object for Ruby/Rails/Merb apps
|
58
|
+
test_files: []
|
59
|
+
|