moneypools-rake_helpers 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +62 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/rake_helpers/build_info.rb +44 -0
- data/lib/rake_helpers/tasks/build_info_task.rb +24 -0
- metadata +13 -19
- data/History.txt +0 -4
- data/rake_helpers.gemspec +0 -47
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/rake_helpers_spec.rb +0 -11
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -10
- data/tasks/rspec.rake +0 -21
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Description
|
2
|
+
This gem provides some helpers we've found useful for managing rake tasks. This includes interacting with "sprouts":http://projectsprouts.org/.
|
3
|
+
|
4
|
+
# Config Usage
|
5
|
+
|
6
|
+
Example config file (rake_config.yml):
|
7
|
+
|
8
|
+
app:
|
9
|
+
app_name: CoolNuggets
|
10
|
+
|
11
|
+
Example RakeFile:
|
12
|
+
|
13
|
+
require 'rake_helpers/config'
|
14
|
+
# Load up any settings that are manually configured
|
15
|
+
MP::Config.global_settings_file = 'rake_config.yml' if File.exist?('rake_config.yml')
|
16
|
+
|
17
|
+
class AppConfig < MP::Config
|
18
|
+
def application_file_path
|
19
|
+
File.join(code_path, app_file)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
AppConfig.configure do |config|
|
24
|
+
# Make it so you can just type app_config to get at a AppConfig object
|
25
|
+
config.expose_as_method
|
26
|
+
|
27
|
+
# add 2 vars, 1 with a default, 1 without
|
28
|
+
config.add(:code_path)
|
29
|
+
config.add(:app_file, :default => 'main.rb')
|
30
|
+
config.add(:app_name, :default => 'not yet set')
|
31
|
+
end
|
32
|
+
|
33
|
+
# override code_path with a setter
|
34
|
+
test_config.code_path = 'spec'
|
35
|
+
|
36
|
+
# override app_file through the environment, you generally would
|
37
|
+
# do this by setting it as an environment variable before you run rake:
|
38
|
+
# APP_FILE='startup.rb' rake do_something
|
39
|
+
ENV['APP_FILE'] = 'startup.rb'
|
40
|
+
|
41
|
+
# Assuming the above rake_config.yml was used, test_config.app_name would
|
42
|
+
# now return the value set in that file
|
43
|
+
test_config.app_name # 'CoolNuggets'
|
44
|
+
|
45
|
+
# Usage for flex projects
|
46
|
+
This also includes a default config useful for flex projects as MP::FlexConfig. This exposes a couple helpful properties such as flex_sdk_path which is determined by the normal config rules (those defined above) or if it hasn't been explicitly set it will try to determine it from the location of your mxmlc command.
|
47
|
+
|
48
|
+
Example FlexConfig usage:
|
49
|
+
# build.rake
|
50
|
+
require 'rake_helpers/config'
|
51
|
+
class FlexConfig < MP::FlexConfig
|
52
|
+
end
|
53
|
+
|
54
|
+
FlexConfig.configure do |config|
|
55
|
+
config.expose_as_method
|
56
|
+
end
|
57
|
+
|
58
|
+
# Now to get at the flex sdk path you'd do:
|
59
|
+
# This will return either the environment variable FLEX_SDK, your set flex_sdk_path or
|
60
|
+
# the path just above mxmlc (determined by which mxmlc)
|
61
|
+
flex_config.flex_sdk_path
|
62
|
+
|
data/Rakefile
CHANGED
@@ -4,8 +4,8 @@ require 'rake'
|
|
4
4
|
begin
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "
|
8
|
-
gem.summary = %Q{Some
|
7
|
+
gem.name = "moneypools-rake_helpers"
|
8
|
+
gem.summary = %Q{Some rake extras}
|
9
9
|
gem.email = "support@mymoneypools.com"
|
10
10
|
gem.homepage = "http://github.com/moneypools/rake_helpers"
|
11
11
|
gem.authors = ["moneypools"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class BuildInfo
|
2
|
+
def revision
|
3
|
+
@revision ||= query_revision('HEAD')
|
4
|
+
end
|
5
|
+
|
6
|
+
def date
|
7
|
+
Time.now
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_action_script
|
11
|
+
<<-EOF
|
12
|
+
public const id:String = "#{revision}"
|
13
|
+
public const date:Date = new Date(#{js_date_number})
|
14
|
+
EOF
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
# date.to_i is in seconds, javascript dates are constructed from ms (so * 1000)
|
19
|
+
def js_date_number
|
20
|
+
date.to_i * 1000
|
21
|
+
end
|
22
|
+
|
23
|
+
# Stolen mostly from Capistrano::Deploy::SCM::Git
|
24
|
+
def query_revision(revision)
|
25
|
+
repository = '.'
|
26
|
+
|
27
|
+
raise ArgumentError, "Deploying remote branches is no longer supported. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{revision.gsub('origin/', '')}' rather than '#{revision}')." if revision =~ /^origin\//
|
28
|
+
return revision if revision =~ /^[0-9a-f]{40}$/
|
29
|
+
# command = scm('ls-remote', repository, revision)
|
30
|
+
# result = yield(command)
|
31
|
+
result = `git ls-remote #{repository} #{revision}`
|
32
|
+
revdata = result.split(/[\t\n]/)
|
33
|
+
newrev = nil
|
34
|
+
revdata.each_slice(2) do |refs|
|
35
|
+
rev, ref = *refs
|
36
|
+
if ref.sub(/refs\/.*?\//, '').strip == revision
|
37
|
+
newrev = rev
|
38
|
+
break
|
39
|
+
end
|
40
|
+
end
|
41
|
+
raise "Unable to resolve revision for '#{revision}' on repository '#{repository}'." unless newrev =~ /^[0-9a-f]{40}$/
|
42
|
+
return newrev
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake_helpers/build_info'
|
3
|
+
|
4
|
+
class BuildInfoTask < Rake::Task
|
5
|
+
attr_accessor :file
|
6
|
+
|
7
|
+
def self.define_task(args, &block)
|
8
|
+
t = super
|
9
|
+
if(t.is_a?(BuildInfoTask))
|
10
|
+
yield t if block_given?
|
11
|
+
end
|
12
|
+
return t
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def execute(*args)
|
17
|
+
build_info = BuildInfo.new
|
18
|
+
File.open(file, 'w') { |f| f.write(build_info.to_action_script) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def build_info_task(*args, &block)
|
23
|
+
BuildInfoTask.define_task(*args, &block)
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneypools-rake_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moneypools
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-23 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -19,27 +19,22 @@ executables: []
|
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.md
|
24
24
|
files:
|
25
25
|
- .gitignore
|
26
|
-
-
|
26
|
+
- README.md
|
27
27
|
- Rakefile
|
28
28
|
- VERSION
|
29
29
|
- lib/rake_helpers.rb
|
30
|
+
- lib/rake_helpers/build_info.rb
|
30
31
|
- lib/rake_helpers/config.rb
|
31
32
|
- lib/rake_helpers/erb_helper.rb
|
32
|
-
- rake_helpers.
|
33
|
-
|
34
|
-
- script/destroy
|
35
|
-
- script/generate
|
36
|
-
- spec/rake_helpers_spec.rb
|
37
|
-
- spec/spec.opts
|
38
|
-
- spec/spec_helper.rb
|
39
|
-
- tasks/rspec.rake
|
40
|
-
has_rdoc: false
|
33
|
+
- lib/rake_helpers/tasks/build_info_task.rb
|
34
|
+
has_rdoc: true
|
41
35
|
homepage: http://github.com/moneypools/rake_helpers
|
42
|
-
licenses:
|
36
|
+
licenses: []
|
37
|
+
|
43
38
|
post_install_message:
|
44
39
|
rdoc_options:
|
45
40
|
- --charset=UTF-8
|
@@ -63,7 +58,6 @@ rubyforge_project:
|
|
63
58
|
rubygems_version: 1.3.5
|
64
59
|
signing_key:
|
65
60
|
specification_version: 3
|
66
|
-
summary: Some
|
67
|
-
test_files:
|
68
|
-
|
69
|
-
- spec/spec_helper.rb
|
61
|
+
summary: Some rake extras
|
62
|
+
test_files: []
|
63
|
+
|
data/History.txt
DELETED
data/rake_helpers.gemspec
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{rake_helpers}
|
5
|
-
s.version = "0.0.7"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["moneypools"]
|
9
|
-
s.date = %q{2009-08-18}
|
10
|
-
s.email = %q{support@mymoneypools.com}
|
11
|
-
s.files = [
|
12
|
-
".gitignore",
|
13
|
-
"History.txt",
|
14
|
-
"Rakefile",
|
15
|
-
"VERSION",
|
16
|
-
"lib/rake_helpers.rb",
|
17
|
-
"lib/rake_helpers/config.rb",
|
18
|
-
"lib/rake_helpers/erb_helper.rb",
|
19
|
-
"rake_helpers.gemspec",
|
20
|
-
"script/console",
|
21
|
-
"script/destroy",
|
22
|
-
"script/generate",
|
23
|
-
"spec/rake_helpers_spec.rb",
|
24
|
-
"spec/spec.opts",
|
25
|
-
"spec/spec_helper.rb",
|
26
|
-
"tasks/rspec.rake"
|
27
|
-
]
|
28
|
-
s.homepage = %q{http://github.com/moneypools/rake_helpers}
|
29
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
30
|
-
s.require_paths = ["lib"]
|
31
|
-
s.rubygems_version = %q{1.3.4}
|
32
|
-
s.summary = %q{Some extensions to sprout}
|
33
|
-
s.test_files = [
|
34
|
-
"spec/rake_helpers_spec.rb",
|
35
|
-
"spec/spec_helper.rb"
|
36
|
-
]
|
37
|
-
|
38
|
-
if s.respond_to? :specification_version then
|
39
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
|
-
s.specification_version = 3
|
41
|
-
|
42
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
43
|
-
else
|
44
|
-
end
|
45
|
-
else
|
46
|
-
end
|
47
|
-
end
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/rake_helpers.rb'}"
|
9
|
-
puts "Loading rake_helpers gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/rake_helpers_spec.rb
DELETED
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|
data/spec/spec_helper.rb
DELETED
data/tasks/rspec.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|