moneypools-rake_helpers 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/History.txt +4 -0
- data/Manifest.txt +10 -0
- data/README.rdoc +48 -0
- data/Rakefile +24 -0
- data/lib/rake_helpers.rb +9 -0
- data/lib/rake_helpers/config.rb +126 -0
- data/lib/rake_helpers/erb_helper.rb +12 -0
- data/spec/rake_helpers_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- metadata +84 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= rake_helpers
|
2
|
+
|
3
|
+
* http://github.com/#{github_username}/#{project_name}
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2009 FIXME full name
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/rake_helpers'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'rake_helpers' do
|
14
|
+
self.developer 'moneypools', 'support@mymoneypools.com'
|
15
|
+
self.rubyforge_name = self.name # TODO this is default value
|
16
|
+
self.extra_deps = [['activesupport','>= 2.0.2']]
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'newgem/tasks'
|
20
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
21
|
+
|
22
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
23
|
+
# remove_task :default
|
24
|
+
# task :default => [:spec, :features]
|
data/lib/rake_helpers.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module MP
|
4
|
+
class Config
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
class OptionNotGivenError < RuntimeError; end
|
8
|
+
|
9
|
+
class Option
|
10
|
+
attr_reader :attribute, :name, :message, :default
|
11
|
+
|
12
|
+
def initialize(attribute, options, &block)
|
13
|
+
@attribute = attribute
|
14
|
+
|
15
|
+
@overrides = ENV
|
16
|
+
@default = options[:default]
|
17
|
+
@name = options.fetch(:name, attribute).to_s
|
18
|
+
@message = options.fetch(:message, "Must specify #{attribute} with #{name}=")
|
19
|
+
@required = options.fetch(:required, true)
|
20
|
+
|
21
|
+
@parser = block
|
22
|
+
|
23
|
+
@attribute, @name, @message = attribute, name, message
|
24
|
+
end
|
25
|
+
|
26
|
+
def default
|
27
|
+
@default.is_a?(Proc) ? @default.call : @default
|
28
|
+
end
|
29
|
+
|
30
|
+
def write(value)
|
31
|
+
@value = value
|
32
|
+
end
|
33
|
+
|
34
|
+
def fetch(local_default)
|
35
|
+
value = fetch_from(@overrides) || @value || local_default || default
|
36
|
+
@parser ? @parser.call(value) : value
|
37
|
+
end
|
38
|
+
|
39
|
+
def read(*args)
|
40
|
+
required = args.empty? ? @required : args.first
|
41
|
+
value = fetch(nil)
|
42
|
+
|
43
|
+
raise OptionNotGivenError.new(message) if value.nil? && required
|
44
|
+
|
45
|
+
value
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def name_variants
|
50
|
+
key = name.to_s
|
51
|
+
|
52
|
+
# for ENV vars we need the upcase, in general we want to allow case-insensitive access for simplicity
|
53
|
+
[key, key.upcase, key.downcase]
|
54
|
+
end
|
55
|
+
|
56
|
+
def fetch_from(hash)
|
57
|
+
# lookup each variant of the key
|
58
|
+
all_possible_values = hash.values_at(*name_variants)
|
59
|
+
# grab the first non-nil value out of the possible values
|
60
|
+
all_possible_values.compact.first
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.configure
|
65
|
+
yield instance
|
66
|
+
end
|
67
|
+
|
68
|
+
def initialize
|
69
|
+
@attributes = {}
|
70
|
+
end
|
71
|
+
|
72
|
+
def add(attribute, options={}, &block)
|
73
|
+
option = Option.new(attribute, options, &block)
|
74
|
+
|
75
|
+
@attributes[option.name] = option
|
76
|
+
|
77
|
+
self.class.class_eval do
|
78
|
+
define_method("#{option.attribute}=") do |value|
|
79
|
+
write(option.name, value)
|
80
|
+
end
|
81
|
+
|
82
|
+
define_method(option.attribute) do |*args|
|
83
|
+
read(option.name)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def write(attribute, value)
|
89
|
+
@attributes[attribute].write(value)
|
90
|
+
end
|
91
|
+
|
92
|
+
def fetch(attribute, default=nil)
|
93
|
+
@attributes[attribute].fetch(default)
|
94
|
+
end
|
95
|
+
|
96
|
+
def read(attribute, *args)
|
97
|
+
@attributes[attribute].read(*args)
|
98
|
+
end
|
99
|
+
|
100
|
+
def [](key)
|
101
|
+
fetch(key)
|
102
|
+
end
|
103
|
+
|
104
|
+
def expose_as_method
|
105
|
+
method_name = self.class.name.underscore
|
106
|
+
config_class = self
|
107
|
+
Object.class_eval do
|
108
|
+
define_method(method_name) do
|
109
|
+
config_class
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# def merge(more_overrides)
|
115
|
+
# self.class.new(@overrides.to_hash.merge(more_overrides))
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# def reverse_merge(more_overrides)
|
119
|
+
# self.class.new(@overrides.to_hash.reverse_merge(more_overrides))
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# def to_hash
|
123
|
+
# @overrides.to_hash
|
124
|
+
# end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
class ErbHelper
|
4
|
+
def self.write(template_name, target, binding)
|
5
|
+
puts "Writing #{template_name} to #{target}"
|
6
|
+
File.open(target, 'w') do |file|
|
7
|
+
test_suite = ERB.new(File.read(template_name), nil, "%>").result(binding)
|
8
|
+
|
9
|
+
file.puts(test_suite)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moneypools-rake_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- moneypools
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-09 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.2
|
34
|
+
version:
|
35
|
+
description: FIX (describe your package)
|
36
|
+
email:
|
37
|
+
- support@mymoneypools.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
files:
|
46
|
+
- History.txt
|
47
|
+
- Manifest.txt
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- lib/rake_helpers.rb
|
51
|
+
- lib/rake_helpers/erb_helper.rb
|
52
|
+
- lib/rake_helpers/config.rb
|
53
|
+
- spec/rake_helpers_spec.rb
|
54
|
+
- spec/spec.opts
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
has_rdoc: false
|
57
|
+
homepage: http://github.com/#{github_username}/#{project_name}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --main
|
61
|
+
- README.rdoc
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project: rake_helpers
|
79
|
+
rubygems_version: 1.2.0
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: FIX (describe your package)
|
83
|
+
test_files: []
|
84
|
+
|