rc 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +0,0 @@
1
- module RC
2
-
3
- # Currently properties derive from a project's .ruby file.
4
- # This will be expanded upon in future version to allow
5
- # additional customization.
6
- #
7
- # @todo Lookup project root directory.
8
- #
9
- class Properties
10
-
11
- #
12
- #
13
- #
14
- DATA_FILE = '.ruby'
15
-
16
- #
17
- #
18
- #
19
- def initialize
20
- @data = {}
21
-
22
- if file = Dir[DATA_FILE].first
23
- @data.update(YAML.load_file(file))
24
- end
25
- end
26
-
27
- #
28
- #
29
- #
30
- def method_missing(s)
31
- @data[s.to_s]
32
- end
33
-
34
- private
35
-
36
- # @todo Support gemspec as properties source ?
37
- def import_gemspec
38
- file = Dir['{*,,pkg/*}.gemspec'].first
39
- # ...
40
- end
41
-
42
- end
43
-
44
- end
@@ -1,54 +0,0 @@
1
- module RC
2
-
3
- # ToolConfiguration encapsulates configurations for a specific tool.
4
- # It is essentially a subset taken from a project's full set of
5
- # configurations.
6
- #
7
- class ToolConfiguration < Module
8
- include Enumerable
9
-
10
- #
11
- # Initialize new ToolConfiguration.
12
- #
13
- # @param [String,Symbol] Tool name.
14
- #
15
- # @param [Configuraiton] Project configuration instance.
16
- #
17
- def initialize(tool, configuration)
18
- include configuration
19
-
20
- @_tool = tool.to_s
21
- @_list = configuration.select{ |c| c.tool?(tool) }
22
- end
23
-
24
- #
25
- #
26
- #
27
- def tool
28
- @_tool
29
- end
30
-
31
- #
32
- #
33
- #
34
- def [](profile)
35
- @_list.select{ |c| c.profile?(profile) }
36
- end
37
-
38
- #
39
- #
40
- #
41
- def each(&block)
42
- @_list.each(&block)
43
- end
44
-
45
- #
46
- #
47
- #
48
- def size
49
- @_list.size
50
- end
51
-
52
- end
53
-
54
- end
@@ -1,28 +0,0 @@
1
- require 'rake'
2
-
3
- module Rake
4
- RC_FILES = '.config.rb', 'config.rb', 'Config.rb'
5
-
6
- class Application
7
- remove_const(:DEFAULT_RAKEFILES)
8
- DEFAULT_RAKEFILES = [
9
- 'rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb',
10
- ] + RC_FILES
11
- end
12
-
13
- def self.load_rakefile(path)
14
- case File.basename(path)
15
- when *RC_FILES
16
- # do nothing, RC will do it
17
- else
18
- load(path)
19
- end
20
- end
21
- end
22
-
23
- module RC
24
- class Configuration
25
- include Rake::DSL
26
- end
27
- end
28
-
@@ -1,22 +0,0 @@
1
- = RC
2
-
3
- The purpose of RC is to provide unified configuration management across multiple
4
- tools for Ruby. The structure of an RC configuration file is very simple.
5
- It is a ruby script sectioned into named blocks:
6
-
7
- config :rake do
8
- # ... rake tasks ...
9
- end
10
-
11
- config :vclog do
12
- # ... configure vclog ...
13
- end
14
-
15
- Utilization of the these configurations may be handled by the consuming
16
- application, but can be used by any tool if `rc` is loaded via RUBYOPT.
17
-
18
- To work with RC in this specification, we want to avoid the automatic
19
- bootstrap, so we load the `interface` script instead.
20
-
21
- require 'rc/interface'
22
-
@@ -1,14 +0,0 @@
1
- # Config Class
2
-
3
- The Config class encapsulates a single config entry. It has a tool, profile
4
- and procedure.
5
-
6
- config = RC::Config.new('foo', 'bar') do
7
- :baz
8
- end
9
-
10
- config.tool #=> :foo
11
- config.profile #=> :bar
12
- config.to_proc.call #=> :baz
13
-
14
-
@@ -1,65 +0,0 @@
1
- # Configuration
2
-
3
- The Configuration class handle evaluation of a project configuration file.
4
-
5
- rc = RC::Configuration.new
6
-
7
- We can use the `#instance_eval` method to evaluate a configuration for our
8
- demonstration.
9
-
10
- rc.instance_eval(<<-HERE)
11
- config :sample1 do
12
- "block code"
13
- end
14
- HERE
15
-
16
- Evaluation of a configuration file, populate the Confection.config instance.
17
-
18
- sample = rc.configurations.last
19
- sample.tool #=> :sample1
20
- sample.profile #=> nil
21
- sample.class #=> RC::Config
22
-
23
- A profile can be used as a means fo defining multiple configurations
24
- for a single tool. This can be done by setting the second argument to
25
- a Symbol.
26
-
27
- rc.instance_eval(<<-HERE)
28
- config :sample2, :opt1 do
29
- "block code"
30
- end
31
- HERE
32
-
33
- sample = rc.configurations.last
34
- sample.tool #=> :sample2
35
- sample.profile #=> :opt1
36
-
37
- Or it can be done by using a `profile` block.
38
-
39
- rc.instance_eval(<<-HERE)
40
- profile :opt1 do
41
- config :sample2 do
42
- "block code"
43
- end
44
- end
45
- HERE
46
-
47
- sample = rc.configurations.last
48
- sample.tool #=> :sample2
49
- sample.profile #=> :opt1
50
-
51
- RC also support YAML-based configuration, if the last argument is
52
- a multi-line string it will create a block using `YAML.load`.
53
-
54
- rc.instance_eval(<<-HERE)
55
- config :sample3, %{
56
- ---
57
- note: This is the note.
58
- }
59
- HERE
60
-
61
- sample = rc.configurations.last
62
- sample.tool #=> :sample3
63
- sample.profile #=> nil
64
- sample.call.assert == {'note'=>'This is the note.'}
65
-
@@ -1,48 +0,0 @@
1
- # Importing
2
-
3
- ## Configuration Importing
4
-
5
- Configurations can be imported from another project
6
- using the `:from` option.
7
-
8
- rc = RC::Configuration.new
9
-
10
- rc.config :qed, :profile=>'example', :from=>'qed'
11
-
12
- rc.size.assert == 1
13
-
14
- The configuration can also be imported from a different profile.
15
-
16
- rc.config :qed, :coverage, :from=>'qed', :profile=>:simplecov
17
-
18
- rc.size.assert == 2
19
-
20
- Although it will rarely be useful, it may also be imported from another tool.
21
-
22
- rc.config :example, :from=>'qed', :tool=>:sample
23
-
24
- Imported configurations can also be augmented via a block.
25
-
26
- rc = RC::Configuration.new
27
-
28
- rc.config :qed, :from=>'qed', :profile=>:simplecov do
29
- # additional code here
30
- end
31
-
32
- rc.size.assert == 2
33
-
34
- Technically this last form just creates two configurations for the same
35
- tool and profile, but the ultimate effect is the same.
36
-
37
- ## Script Importing
38
-
39
- Library files can be imported directly into configuration blocks via the
40
- `#import` method.
41
-
42
- rc.config :example do
43
- import "fruitbasket/example.rb"
44
- end
45
-
46
- This looks up the file via the `finder` gem and then evals it in the context
47
- of the config block.
48
-
@@ -1,36 +0,0 @@
1
- # Interface
2
-
3
- The main means of workin with RC's API are the RC class methods,
4
- collectively called the Inteface.
5
-
6
- Let's say we have a configuration file `config.rb` containing:
7
-
8
- config :example do
9
- "example config"
10
- end
11
-
12
- config :example, :something do
13
- "example config using profile"
14
- end
15
-
16
- To get the configuration of the current project --relative to the
17
- current working directory, we can use the `configuration` method.
18
-
19
- RC.configuration
20
-
21
- The configuration properties of the current project can be
22
- had via the `properties` method.
23
-
24
- RC.properties
25
-
26
- The profile names can be looked up for any given tool via the `profiles`
27
- method.
28
-
29
- RC.profiles(:example)
30
-
31
- The number of configurations in the current project can be had via
32
- the `size` method. (This is the number of configurations we have
33
- defined in our test fixture.)
34
-
35
- RC.configuration.configurations.size.assert == 2
36
-
@@ -1 +0,0 @@
1
- require 'ae'
@@ -1,8 +0,0 @@
1
- require 'rc/interface'
2
-
3
- When 'configuration file `(((\S+)))` containing' do |slots, text|
4
- RC.clear! #configurations.clear
5
- fname = [slots].flatten.first # temporary transition to new QED
6
- File.open(fname, 'w'){ |f| f << text }
7
- end
8
-
@@ -1,10 +0,0 @@
1
- # Setup the fixtures.
2
-
3
- dir = File.dirname(__FILE__) + '/fixture'
4
- Dir.entries(dir).each do |file|
5
- next if file == '.' or file == '..'
6
- path = File.join(dir, file)
7
- next if File.directory?(path)
8
- FileUtils.install(path, Dir.pwd)
9
- end
10
-
@@ -1,16 +0,0 @@
1
- # exmaple configuration file
2
-
3
- config :example do
4
- "example config"
5
- end
6
-
7
- config :example, :yaml, %{
8
- ---
9
- note: example text config
10
- }
11
-
12
- config :example, :data do |ex|
13
- ex.name = 'Tommy'
14
- ex.age = 42
15
- end
16
-