rc 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,108 @@
1
+ module RC
2
+
3
+ # Project properties make it easy for configurations to utilize
4
+ # information about a project for config settings. Properties
5
+ # are stored in a global variables called `$properties`.
6
+ #
7
+ # $properties.name #=> 'rc'
8
+ #
9
+ # Properties derive from a project's `.index` file and `var/` files.
10
+ # This may expand in the future to include a project's gemspec.
11
+ #
12
+ class Properties
13
+
14
+ #
15
+ # Initialize new Properties instance.
16
+ #
17
+ def initialize(path=nil)
18
+ @root = find_root(path || Dir.pwd)
19
+ @index = load_index
20
+ end
21
+
22
+ #
23
+ # Root directory of project.
24
+ #
25
+ # @return [String] Full path to project's root directory.
26
+ #
27
+ def root
28
+ @root
29
+ end
30
+
31
+ #
32
+ # Route missing method to index lookup and failing that var file lookup.
33
+ #
34
+ def method_missing(s)
35
+ name = s.to_s.downcase
36
+ index(name) || var(name)
37
+ end
38
+
39
+ private
40
+
41
+ #
42
+ #
43
+ #
44
+ def find_root(path)
45
+ pwd = File.expand_path(path)
46
+ home = File.expand_path('~')
47
+
48
+ while pwd != '/' && pwd != home
49
+ return pwd if ROOT_INDICATORS.any?{ |r| File.exist?(File.join(pwd, r)) }
50
+ pwd = File.dirname(pwd)
51
+ end
52
+
53
+ nil
54
+ end
55
+
56
+ #
57
+ #
58
+ #
59
+ def index(name)
60
+ @index[name]
61
+ end
62
+
63
+ #
64
+ #
65
+ #
66
+ def var(name)
67
+ return @var[name] if @var.key?(name)
68
+
69
+ glob = File.join(root, 'var', name)
70
+ file = Dir[glob].first
71
+ if file
72
+ data = File.read(file)
73
+ if data =~ /\A(---|%YAML)/
74
+ data = YAML.load(data)
75
+ end
76
+ @var[name] = data
77
+ else
78
+ nil
79
+ end
80
+ end
81
+
82
+ #
83
+ #
84
+ #
85
+ def load_index
86
+ index = {}
87
+ file = File.join(root, '.index')
88
+ if File.exist?(file)
89
+ begin
90
+ index = YAML.load_file(file)
91
+ rescue SyntaxError => error
92
+ warn error.to_s
93
+ end
94
+ end
95
+ index
96
+ end
97
+
98
+ #
99
+ # @todo Support gemspec as properties source ?
100
+ #
101
+ def load_gemspec
102
+ file = Dir['{*,,pkg/*}.gemspec'].first
103
+ # ...
104
+ end
105
+
106
+ end
107
+
108
+ end
@@ -0,0 +1,10 @@
1
+ module RC
2
+
3
+ #
4
+ # We create a noop method b/c it simplifes implementation.
5
+ # When a file is required this method gets called.
6
+ #
7
+ def self.required(path)
8
+ end
9
+
10
+ end
@@ -0,0 +1,57 @@
1
+ module RC
2
+
3
+ #
4
+ # Configuration setup is used to customize how a tool handles
5
+ # configuration.
6
+ #
7
+ class Setup
8
+
9
+ #
10
+ # Intialize new configuration setup.
11
+ #
12
+ def initialize(command, options={}, &block)
13
+ @command = command.to_s
14
+ #@command = options[:command] || options[:tool] if options.key?(:command) || options.key?(:tool)
15
+
16
+ @profile = options[:profile] if options.key?(:profile)
17
+
18
+ @block = block
19
+ end
20
+
21
+ #
22
+ # Command for which this is the configuration setup.
23
+ #
24
+ attr :command
25
+
26
+ #
27
+ # Specific profile for which this is the configuration is the setup.
28
+ #
29
+ attr :profile
30
+
31
+ #
32
+ #
33
+ #
34
+ def call(config)
35
+ return unless config.command == @command #.to_s if @command
36
+
37
+ case profile
38
+ when true
39
+ return unless RC.profile?
40
+ when nil, false
41
+ else
42
+ return unless config.profile == @profile.to_s #if @profile
43
+ end
44
+
45
+ @block.call(config)
46
+ end
47
+
48
+ #
49
+ #
50
+ #
51
+ def to_proc
52
+ @block
53
+ end
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,31 @@
1
+ require 'rake'
2
+
3
+ court 'rake' do |config|
4
+ Module.new do
5
+ extend Rake::DSL
6
+ module_eval(&config)
7
+ end
8
+ end
9
+
10
+ module Rake
11
+ RC_FILES = '.config.rb', 'config.rb', 'Config.rb'
12
+
13
+ class Application
14
+ remove_const(:DEFAULT_RAKEFILES)
15
+ DEFAULT_RAKEFILES = [
16
+ 'rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb',
17
+ ] + RC_FILES
18
+ end
19
+
20
+ def self.load_rakefile(path)
21
+ case File.basename(path)
22
+ when *RC_FILES
23
+ # do nothing, RC will do it
24
+ else
25
+ load(path)
26
+ end
27
+ end
28
+ end
29
+
30
+ # Must manually configure tweaked libraries.
31
+ RC.configure('rake')
metadata CHANGED
@@ -1,49 +1,146 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Rubyworks
9
8
  - Trans
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-04-30 00:00:00.000000000 Z
12
+ date: 2013-01-08 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- name: courtier
17
- requirement: &20862920 !ruby/object:Gem::Requirement
15
+ name: finder
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
- - - =
19
+ - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
- version: 0.2.0
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *20862920
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
26
30
  - !ruby/object:Gem::Dependency
27
- name: courtier
28
- requirement: &20862420 !ruby/object:Gem::Requirement
31
+ name: detroit
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
34
  requirements:
31
- - - =
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
- version: 0.2.0
37
+ version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
- version_requirements: *20862420
37
- description: Courtier manages an application's configuration via a single multi-tenant
38
- project file.
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: qed
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: ae
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: test
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! 'R.C. is a multi-tenant configuration system for Ruby projects.
95
+
96
+ R.C. can configure almost any Ruby tool or library.'
39
97
  email:
40
98
  - transfire@gmail.com
41
99
  executables: []
42
100
  extensions: []
43
- extra_rdoc_files: []
44
- files: []
45
- homepage: http://github.com/rubyworks/courtier
46
- licenses: []
101
+ extra_rdoc_files:
102
+ - LICENSE.txt
103
+ - HISTORY.md
104
+ - README.md
105
+ files:
106
+ - .index
107
+ - .rubyrc
108
+ - .yardopts
109
+ - demo/00_concept.md
110
+ - demo/01_config.md
111
+ - demo/02_configuration.md
112
+ - demo/03_import.md
113
+ - demo/06_interface.md
114
+ - demo/applique/ae.rb
115
+ - demo/applique/file.rb
116
+ - demo/applique/fixture/.ruby
117
+ - demo/applique/fixture.rb
118
+ - demo/cov.rb
119
+ - lib/c.rb
120
+ - lib/rc/api.rb
121
+ - lib/rc/config.rb
122
+ - lib/rc/config_filter.rb
123
+ - lib/rc/configuration.rb
124
+ - lib/rc/constants.rb
125
+ - lib/rc/core_ext/argv.rb
126
+ - lib/rc/core_ext/hash.rb
127
+ - lib/rc/core_ext/kernel.rb
128
+ - lib/rc/core_ext/string.rb
129
+ - lib/rc/core_ext/symbol.rb
130
+ - lib/rc/core_ext.rb
131
+ - lib/rc/dsl.rb
132
+ - lib/rc/interface.rb
133
+ - lib/rc/properties.rb
134
+ - lib/rc/required.rb
135
+ - lib/rc/setup.rb
136
+ - lib/rc/tweaks/rake.rb
137
+ - lib/rc.rb
138
+ - LICENSE.txt
139
+ - HISTORY.md
140
+ - README.md
141
+ homepage: http://rubyworks.github.com/rc
142
+ licenses:
143
+ - BSD-2-Clause
47
144
  post_install_message:
48
145
  rdoc_options: []
49
146
  require_paths:
@@ -61,10 +158,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
158
  - !ruby/object:Gem::Version
62
159
  version: '0'
63
160
  requirements: []
64
- rubyforge_project: courtier
65
- rubygems_version: 1.8.11
161
+ rubyforge_project:
162
+ rubygems_version: 1.8.23
66
163
  signing_key:
67
164
  specification_version: 3
68
165
  summary: The best way to manage your application's configuration.
69
166
  test_files: []
70
- has_rdoc: