buildar 0.2.0.1 → 0.3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/rakefile.rb +89 -77
  3. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.1
1
+ 0.3.0.1
@@ -6,107 +6,119 @@ Rake::TestTask.new :test do |t|
6
6
  t.pattern = 'test/*.rb'
7
7
  end
8
8
 
9
- PROJECT_ROOT = File.dirname(__FILE__)
10
- PROJECT_NAME = File.split(PROJECT_ROOT).last
11
- VERSION_FILE = File.join(PROJECT_ROOT, 'VERSION')
12
- MANIFEST_FILE = File.join(PROJECT_ROOT, 'MANIFEST.txt')
13
- USE_GIT = true
14
- GIT_COMMIT_VERSION = true # commit version bump automatically
15
- PUBLISH = {
16
- rubygems: true, # publish .gem to http://rubygems.org/
17
- }
9
+ module Buildar
10
+ ##############################################
11
+ # Project-specific settings. Edit as needed.
12
+ #
13
+ #
14
+ PROJECT_ROOT = File.dirname(__FILE__)
15
+ PROJECT_NAME = File.split(PROJECT_ROOT).last
16
+ VERSION_FILE = File.join(PROJECT_ROOT, 'VERSION')
17
+ MANIFEST_FILE = File.join(PROJECT_ROOT, 'MANIFEST.txt')
18
+
19
+ USE_GIT = true
20
+ GIT_COMMIT_VERSION = true # commit version bump automatically
21
+ PUBLISH = {
22
+ rubygems: true, # publish .gem to http://rubygems.org/
23
+ }
24
+
25
+ def self.gemspec
26
+ Gem::Specification.new do |s|
27
+ # Static assignments
28
+ s.name = PROJECT_NAME
29
+ s.summary = "FIX"
30
+ s.description = "FIX"
31
+ s.authors = ["FIX"]
32
+ s.email = "FIX@FIX.COM"
33
+ s.homepage = "http://FIX.COM/"
34
+ s.licenses = ['FIX']
35
+
36
+ # Dynamic assignments
37
+ s.files = manifest
38
+ s.version = version
39
+ s.date = Time.now.strftime("%Y-%m-%d")
40
+
41
+ # s.add_runtime_dependency "rest-client", ["~> 1"]
42
+ # s.add_runtime_dependency "json", ["~> 1"]
43
+ s.add_development_dependency "minitest", [">= 0"]
44
+ s.add_development_dependency "rake", [">= 0"]
45
+ end
46
+ end
47
+ #
48
+ #
49
+ # End project-specific settings.
50
+ ################################
51
+
52
+ def self.version
53
+ File.read(VERSION_FILE).chomp
54
+ end
55
+
56
+ def self.manifest
57
+ File.readlines(MANIFEST_FILE).map { |line| line.chomp }
58
+ end
59
+
60
+ def self.write_version new_version
61
+ File.open(VERSION_FILE, 'w') { |f| f.write(new_version) }
62
+ end
63
+
64
+ # e.g. bump(:minor, '1.2.3') #=> '1.3.0'
65
+ # only works for integers delimited by periods (dots)
66
+ #
67
+ def self.bump(position, version)
68
+ pos = [:major, :minor, :patch, :build].index(position) || position
69
+ places = version.split('.')
70
+ raise "bad position: #{pos} (for version #{version})" unless places[pos]
71
+ places.map.with_index { |place, i|
72
+ if i < pos
73
+ place
74
+ elsif i == pos
75
+ place.to_i + 1
76
+ else
77
+ 0
78
+ end
79
+ }.join('.')
80
+ end
81
+ end
18
82
 
19
- def version
20
- File.read(VERSION_FILE).chomp
83
+ task :version do
84
+ puts "#{Buildar::PROJECT_NAME} #{Buildar.version}"
21
85
  end
22
86
 
23
87
  task :message do
24
88
  unless ENV['message']
25
89
  puts "Enter a one-line message:"
26
- print " > "
90
+ print "> "
27
91
  ENV['message'] = $stdin.gets.chomp
28
92
  end
29
93
  end
30
94
 
31
- task :version do
32
- puts "#{PROJECT_NAME} #{version}"
33
- end
34
-
35
95
  task :tag => [:test] do
36
- if USE_GIT
37
- tagname = "v#{version}"
96
+ if Buildar::USE_GIT
38
97
  message = ENV['message'] || "auto-tagged #{tagname} by Rake"
39
- sh "git tag -a #{tagname} -m '#{message}'"
98
+ sh "git tag -a 'v#{Buildar.version}' -m '#{message}'"
40
99
  sh "git push origin --tags"
41
100
  end
42
101
  end
43
102
 
44
- def manifest
45
- File.readlines(MANIFEST_FILE).map { |line| line.chomp }
46
- end
47
-
48
103
  task :manifest do
49
- puts manifest.join("\n")
104
+ puts Buildar.manifest.join("\n")
50
105
  end
51
106
 
52
107
  task :build => [:test, :bump_build] do
53
- spec = Gem::Specification.new do |s|
54
- # Static assignments
55
- s.name = PROJECT_NAME
56
- s.summary = "FIX"
57
- s.description = "FIX"
58
- s.authors = ["FIX"]
59
- s.email = "FIX@FIX.COM"
60
- s.homepage = "http://FIX.COM/"
61
- s.licenses = ['FIX']
62
-
63
- # Dynamic assignments
64
- s.files = manifest
65
- s.version = version
66
- s.date = Time.now.strftime("%Y-%m-%d")
67
-
68
- # s.add_runtime_dependency "rest-client", ["~> 1"]
69
- # s.add_runtime_dependency "json", ["~> 1"]
70
- s.add_development_dependency "minitest", [">= 0"]
71
- s.add_development_dependency "rake", [">= 0"]
72
- end
73
-
74
108
  # we're definining the task at runtime, rather than requiretime
75
109
  # so that the gemspec will reflect any version bumping since requiretime
76
110
  #
77
- Gem::PackageTask.new(spec).define
111
+ Gem::PackageTask.new(Buildar.gemspec).define
78
112
  Rake::Task["package"].invoke
79
113
  end
80
114
 
81
- # e.g. bump(:minor, '1.2.3') #=> '1.3.0'
82
- # only works for integers delimited by periods (dots)
83
- #
84
- def bump(position, version)
85
- pos = [:major, :minor, :patch, :build].index(position) || position
86
- places = version.split('.')
87
- raise "bad position: #{pos} (for version #{version})" unless places[pos]
88
- places.map.with_index { |place, i|
89
- if i < pos
90
- place
91
- elsif i == pos
92
- place.to_i + 1
93
- else
94
- 0
95
- end
96
- }.join('.')
97
- end
98
-
99
- def write_version new_version
100
- File.open(VERSION_FILE, 'w') { |f| f.write(new_version) }
101
- end
102
-
103
115
  [:major, :minor, :patch, :build].each { |v|
104
116
  task "bump_#{v}" do
105
- old_version = version
106
- new_version = bump(v, old_version)
117
+ old_version = Buildar.version
118
+ new_version = Buildar.bump(v, old_version)
107
119
  puts "bumping #{old_version} to #{new_version}"
108
- write_version new_version
109
- if USE_GIT and GIT_COMMIT_VERSION
120
+ Buildar.write_version new_version
121
+ if Buildar::USE_GIT and Buildar::GIT_COMMIT_VERSION
110
122
  sh "git add VERSION"
111
123
  sh "git commit -m 'rake bump_#{v} to #{new_version}'"
112
124
  end
@@ -115,7 +127,7 @@ end
115
127
  task :bump => [:bump_patch]
116
128
 
117
129
  task :verify_publish_credentials do
118
- if PUBLISH[:rubygems]
130
+ if Buildar::PUBLISH[:rubygems]
119
131
  creds = '~/.gem/credentials'
120
132
  fp = File.expand_path(creds)
121
133
  raise "#{creds} does not exist" unless File.exists?(fp)
@@ -124,9 +136,9 @@ task :verify_publish_credentials do
124
136
  end
125
137
 
126
138
  task :publish => [:verify_publish_credentials] do
127
- if PUBLISH[:rubygems]
128
- fragment = "-#{version}.gem"
129
- pkg_dir = File.join(PROJECT_ROOT, 'pkg')
139
+ if Buildar::PUBLISH[:rubygems]
140
+ fragment = "-#{Buildar.version}.gem"
141
+ pkg_dir = File.join(Buildar::PROJECT_ROOT, 'pkg')
130
142
  Dir.chdir(pkg_dir) {
131
143
  candidates = Dir.glob "*#{fragment}"
132
144
  case candidates.length
@@ -143,7 +155,7 @@ end
143
155
 
144
156
  task :gitpush do
145
157
  # may prompt
146
- sh "git push origin" if USE_GIT
158
+ sh "git push origin" if Buildar::USE_GIT
147
159
  # this kills the automation
148
160
  # use key-based auth?
149
161
  # consider a timeout?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.1
4
+ version: 0.3.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: