joseph 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +26 -0
- data/MIT-LICENSE +20 -0
- data/README.md +12 -0
- data/Rakefile +24 -0
- data/example.rb +32 -0
- data/joseph.gemspec +22 -0
- data/lib/joseph/version.rb +3 -0
- data/lib/joseph.rb +32 -0
- data/spec/joseph_spec.rb +32 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
joseph (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rake (0.8.7)
|
11
|
+
rspec (2.1.0)
|
12
|
+
rspec-core (~> 2.1.0)
|
13
|
+
rspec-expectations (~> 2.1.0)
|
14
|
+
rspec-mocks (~> 2.1.0)
|
15
|
+
rspec-core (2.1.0)
|
16
|
+
rspec-expectations (2.1.0)
|
17
|
+
diff-lcs (~> 1.1.2)
|
18
|
+
rspec-mocks (2.1.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
joseph!
|
25
|
+
rake (~> 0.8.7)
|
26
|
+
rspec (~> 2.1.0)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2010 Martin Schuerrer http://schuerrer.org
|
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.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Joseph
|
2
|
+
======
|
3
|
+
|
4
|
+
Yet another take on application configuration.
|
5
|
+
|
6
|
+
Named after [Joseph Finder](http://www.nytimes.com/1987/02/22/magazine/about-men-a-male-secretary.html?pagewanted=all).
|
7
|
+
|
8
|
+
License
|
9
|
+
=======
|
10
|
+
|
11
|
+
MIT License. Copyright 2010 [Martin Schuerrer](http://schuerrer.org).
|
12
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
|
8
|
+
desc "Run all examples"
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.rspec_opts = %w[--color]
|
11
|
+
t.verbose = false
|
12
|
+
end
|
13
|
+
|
14
|
+
desc("Open IRB console")
|
15
|
+
task :console do
|
16
|
+
require 'irb'
|
17
|
+
require 'irb/completion'
|
18
|
+
require 'joseph'
|
19
|
+
ARGV.clear
|
20
|
+
IRB.start
|
21
|
+
end
|
22
|
+
|
23
|
+
task :default => [:spec]
|
24
|
+
|
data/example.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$: << 'lib'
|
2
|
+
require 'joseph'
|
3
|
+
|
4
|
+
module Paypal2K
|
5
|
+
include Joseph
|
6
|
+
end
|
7
|
+
|
8
|
+
Paypal2K.configure do |config|
|
9
|
+
config.username = 'martin@letsannotate.com'
|
10
|
+
config.password = 'secret'
|
11
|
+
end
|
12
|
+
|
13
|
+
puts Paypal2K.username # => 'asd'
|
14
|
+
|
15
|
+
|
16
|
+
class TwitterAuth
|
17
|
+
include Joseph
|
18
|
+
end
|
19
|
+
|
20
|
+
t1 = TwitterAuth.new
|
21
|
+
t1.configure do |config|
|
22
|
+
config.oauth_secret = 'asd'
|
23
|
+
end
|
24
|
+
|
25
|
+
t2 = TwitterAuth.new
|
26
|
+
t2.configure do |config|
|
27
|
+
config.oauth_secret = 'qwe'
|
28
|
+
end
|
29
|
+
|
30
|
+
puts t1.oauth_secret # => 'asd'
|
31
|
+
puts t2.oauth_secret # => 'qwe'
|
32
|
+
|
data/joseph.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "joseph/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "joseph"
|
7
|
+
s.version = Joseph::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Martin Schuerrer"]
|
10
|
+
s.email = ["martin@schuerrer.org"]
|
11
|
+
s.homepage = "http://schuerrer.org"
|
12
|
+
s.summary = %q{Yet another take on application configuration}
|
13
|
+
s.description = %q{Yet another take on application configuration}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,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", ["~> 2.1.0"])
|
21
|
+
s.add_development_dependency("rake", ["~> 0.8.7"])
|
22
|
+
end
|
data/lib/joseph.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Joseph
|
4
|
+
def self.included(base)
|
5
|
+
if base.class == Module
|
6
|
+
base.extend self
|
7
|
+
else
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def config
|
13
|
+
@config ||= OpenStruct.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield config
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](key)
|
21
|
+
config.send key
|
22
|
+
end
|
23
|
+
|
24
|
+
# Lifted from http://github.com/stephencelis/app/blob/master/lib/app.rb#L69-76
|
25
|
+
def method_missing(method, *args, &block)
|
26
|
+
super if (key = method.to_s).end_with?("=")
|
27
|
+
boolean = key.chomp!("?")
|
28
|
+
value = self[key]
|
29
|
+
value = value.call(*args, &block) if value.respond_to?(:call)
|
30
|
+
boolean ? !!value : value
|
31
|
+
end
|
32
|
+
end
|
data/spec/joseph_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'joseph'
|
2
|
+
|
3
|
+
describe Joseph do
|
4
|
+
describe 'adding it to a class' do
|
5
|
+
class A
|
6
|
+
include Joseph
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:a) { A.new }
|
10
|
+
|
11
|
+
it 'includes Joseph' do
|
12
|
+
a.configure do |config|
|
13
|
+
config.hans = 'herbert'
|
14
|
+
end
|
15
|
+
a.hans.should == 'herbert'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'adding it to a module' do
|
20
|
+
module M
|
21
|
+
include Joseph
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'includes Joseph' do
|
25
|
+
M.configure do |config|
|
26
|
+
config.hans = 'herbert'
|
27
|
+
end
|
28
|
+
M.hans.should == 'herbert'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: joseph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Martin Schuerrer
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-10 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
version: 2.1.0
|
32
|
+
type: :development
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 8
|
45
|
+
- 7
|
46
|
+
version: 0.8.7
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
50
|
+
description: Yet another take on application configuration
|
51
|
+
email:
|
52
|
+
- martin@schuerrer.org
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files: []
|
58
|
+
|
59
|
+
files:
|
60
|
+
- .gitignore
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- example.rb
|
67
|
+
- joseph.gemspec
|
68
|
+
- lib/joseph.rb
|
69
|
+
- lib/joseph/version.rb
|
70
|
+
- spec/joseph_spec.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://schuerrer.org
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: -4549066023595521108
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: -4549066023595521108
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.3.7
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Yet another take on application configuration
|
105
|
+
test_files:
|
106
|
+
- spec/joseph_spec.rb
|