-
Notifications
You must be signed in to change notification settings - Fork 104
/
datashift_spree.thor
50 lines (36 loc) · 1.45 KB
/
datashift_spree.thor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright:: (c) Autotelik Media Ltd 2011
# Author :: Tom Statter
# Date :: Aug 2010
#
# License:: MIT - Free, OpenSource
#
# Details:: General tools related to DataShiftSpree Gem : specification, build, deploy
#
#
module Datashift
class SpreeTasks < Thor
desc 'build', 'Build gem '
method_option :version, :required => true, :aliases => '-v', :desc => "YAML config containing static definitions"
method_option :push, :aliases => '-p', :desc => "Push most recent gem to rubygems"
method_option :install, :aliases => '-i', :desc => "Run gem install on the built gems"
def build()
$:.unshift '.' # 1.9.3 quite strict, '.' must be in load path for relative paths to work from here
gemspec = 'datashift_spree.gemspec'
# Bump the VERSION file
system("echo #{options[:version]} > VERSION ") if(options[:version])
puts "Will build gem #{gemspec}"
system("gem build #{gemspec}")
glob = options[:version] ? "datashift_spree-#{options[:version]}.gem" : "datashift_spree-*.gem"
files = Dir[glob].sort_by { |f|File.mtime(f) }
files.reject! { |f| (File.file?(f) ? false : true) }
recent = files.reverse[0]
if(options[:install] && recent)
puts recent
system("gem install --no-ri --no-rdoc #{recent}")
end
if(options[:push] && recent)
system("gem push #{recent}")
end
end
end
end