falkorlib 0.2.15 → 0.3.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -2
- data/README.md +7 -3
- data/falkorlib.gemspec +2 -1
- data/lib/falkorlib.rb +15 -3
- data/lib/falkorlib/common.rb +141 -44
- data/lib/falkorlib/config.rb +16 -6
- data/lib/falkorlib/git/base.rb +7 -3
- data/lib/falkorlib/git/flow.rb +16 -4
- data/lib/falkorlib/loader.rb +2 -1
- data/lib/falkorlib/puppet.rb +17 -0
- data/lib/falkorlib/puppet/base.rb +30 -0
- data/lib/falkorlib/puppet/modules.rb +132 -0
- data/lib/falkorlib/puppet_tasks.rb +24 -0
- data/lib/falkorlib/tasks.rb +12 -6
- data/lib/falkorlib/tasks/gitflow.rake +46 -44
- data/lib/falkorlib/tasks/puppet.rb +24 -0
- data/lib/falkorlib/tasks/puppet_modules.rake +35 -0
- data/lib/falkorlib/tasks/rspec.rake +1 -1
- data/lib/falkorlib/version.rb +2 -1
- data/lib/falkorlib/versioning.rb +16 -1
- data/spec/falkorlib/git_spec.rb +6 -1
- data/spec/falkorlib/gitflow_spec.rb +8 -3
- data/spec/falkorlib/puppet_modules_spec.rb +51 -0
- metadata +38 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f29a576f48785a231d70a51920d2313915e135aa
|
4
|
+
data.tar.gz: ec1536f6f49fe5e96ccbd888f4f30aa77db49756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f4c56f5feedd8a4bd4ff135654ff9e846267946b06f396920045f1bf27d20b09f21325c9ebb2b4acefcb505742bba13f2fc56a0339b4427eb6123e2120c5dcd
|
7
|
+
data.tar.gz: 096f0cd26cf79b78ffbdda9fbb9ced24a6ad566055a510a833769d602cf5ad7824459b59d5b8447966325dc313d962da10fb7ffe4ab7f5b74e5729451720a488
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
falkorlib (0.
|
4
|
+
falkorlib (0.3.0)
|
5
5
|
awesome_print (~> 1.2)
|
6
6
|
configatron (~> 3.2)
|
7
7
|
git_remote_branch (~> 0)
|
8
|
+
json (~> 1.8)
|
9
|
+
license-generator
|
8
10
|
minigit (~> 0)
|
9
11
|
rake (~> 10.1, >= 10.1.0)
|
10
12
|
term-ansicolor (~> 1.3)
|
@@ -41,6 +43,8 @@ GEM
|
|
41
43
|
json (1.8.1)
|
42
44
|
launchy (2.4.2)
|
43
45
|
addressable (~> 2.3)
|
46
|
+
license-generator (0.4.1)
|
47
|
+
thor
|
44
48
|
method_source (0.8.2)
|
45
49
|
minigit (0.0.4)
|
46
50
|
multi_json (1.10.1)
|
@@ -73,7 +77,8 @@ GEM
|
|
73
77
|
slop (3.5.0)
|
74
78
|
term-ansicolor (1.3.0)
|
75
79
|
tins (~> 1.0)
|
76
|
-
|
80
|
+
thor (0.19.1)
|
81
|
+
tins (1.3.2)
|
77
82
|
travis (1.6.14)
|
78
83
|
addressable (~> 2.3)
|
79
84
|
backports
|
data/README.md
CHANGED
@@ -70,11 +70,14 @@ This library features two aspects
|
|
70
70
|
c.debug = true
|
71
71
|
end
|
72
72
|
|
73
|
+
You can also place a special file `.falkorlib.yaml` to customize the
|
74
|
+
FalkorLib settings
|
73
75
|
|
74
76
|
* `FalkorLib::Git`: all [git](http://git-scm.com/) operations
|
75
77
|
* `FalkorLib::GitFlow`: all [git-flow](http://nvie.com/posts/a-successful-git-branching-model/) operations
|
76
78
|
* `FalkorLib::Version`: for the [semantic versioning](http://semver.org/)
|
77
79
|
management of your project.
|
80
|
+
* `FalkorLib::Puppet`: for all [puppet](http://puppetlabs.com) operations
|
78
81
|
|
79
82
|
* Some [rake](https://github.com/jimweirich/rake) tasks to facilitate common operations.
|
80
83
|
In general you can simply embedded my tasks by adding the following header in your `Rakefile`:
|
@@ -152,6 +155,9 @@ _Note_: you probably want to
|
|
152
155
|
[take a look at that script content](https://github.com/Falkor/falkorlib/blob/devel/binscripts/bootstrap.sh)
|
153
156
|
before running the above command.
|
154
157
|
|
158
|
+
Alternatively, assuming you have installed the `falkorlib` gem, you can create a
|
159
|
+
minimal `Rakefile` (containing `require 'falkorlib'`) and run `rake bootstrap:rvm`.
|
160
|
+
|
155
161
|
You can now complete your `Rakefile` depending on the tasks you wish to see.
|
156
162
|
Below is a detailed overview of the implemented rake tasks in `FalkorLib`.
|
157
163
|
|
@@ -221,10 +227,8 @@ $> rake -T
|
|
221
227
|
rake falkorlib:conf # Print the current configuration of FalkorLib
|
222
228
|
rake git:feature:finish # Finalize the feature operation
|
223
229
|
rake git:feature:start[name] # Start a new feature operation on the repository using the git-flow framework
|
224
|
-
rake git:fetch # Fetch the latest changes on remotes
|
225
230
|
rake git:flow:init # Initialize your local clone of the repository for the git-flow management
|
226
|
-
rake
|
227
|
-
rake git:up # Update your local copy of the repository from GIT server
|
231
|
+
rake setup # Setup the repository
|
228
232
|
rake version:bump:major # Prepare the major release of the repository
|
229
233
|
rake version:bump:minor # Prepare the minor release of the repository
|
230
234
|
rake version:bump:patch # Prepare the patch release of the repository
|
data/falkorlib.gemspec
CHANGED
@@ -130,7 +130,8 @@ Gem::Specification.new do |s|
|
|
130
130
|
s.add_runtime_dependency("term-ansicolor", "~> 1.3")
|
131
131
|
s.add_runtime_dependency("configatron", "~> 3.2")
|
132
132
|
s.add_runtime_dependency("awesome_print", "~> 1.2")
|
133
|
-
|
133
|
+
s.add_runtime_dependency("json", "~> 1.8")
|
134
|
+
s.add_runtime_dependency("license-generator")
|
134
135
|
|
135
136
|
#
|
136
137
|
# One call to add_dependency('gem_name', 'gem version requirement') for each
|
data/lib/falkorlib.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Sam 2014-08-23 23:18 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# _____ _ _ _ _ _
|
6
6
|
# | ___|_ _| | | _____ _ __| | (_) |__
|
@@ -29,11 +29,23 @@ end
|
|
29
29
|
require 'yaml'
|
30
30
|
|
31
31
|
# Sebastien Varrette aka Falkor's Common library to share Ruby code
|
32
|
-
# and `{rake,cap}` tasks
|
32
|
+
# and `{rake,cap}` tasks
|
33
33
|
module FalkorLib
|
34
34
|
|
35
|
+
# Return the root directory of the gem
|
36
|
+
def self.root
|
37
|
+
File.expand_path '../..', __FILE__
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.lib
|
41
|
+
File.join root, 'lib'
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.templates
|
45
|
+
File.join root, 'templates'
|
46
|
+
end
|
47
|
+
|
35
48
|
end # module FalkorLib
|
36
49
|
|
37
50
|
require "falkorlib/version"
|
38
51
|
require "falkorlib/loader"
|
39
|
-
|
data/lib/falkorlib/common.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Lun 2014-08-25 23:43 svarrette>
|
4
4
|
################################################################################
|
5
5
|
|
6
6
|
require "falkorlib"
|
7
7
|
require 'open3'
|
8
|
+
require 'erb' # required for module generation
|
8
9
|
|
9
10
|
|
10
11
|
module FalkorLib #:nodoc:
|
@@ -165,57 +166,71 @@ module FalkorLib #:nodoc:
|
|
165
166
|
exit_status
|
166
167
|
end
|
167
168
|
|
168
|
-
## List items from a glob pattern
|
169
|
-
|
169
|
+
## List items from a glob pattern to ask for a unique choice
|
170
|
+
# Supported options:
|
171
|
+
# :only_files [boolean]: list only files in the glob
|
172
|
+
# :only_dirs [boolean]: list only directories in the glob
|
173
|
+
# :pattern_include [array of strings]: pattern(s) to include for listing
|
174
|
+
# :pattern_exclude [array of strings]: pattern(s) to exclude for listing
|
170
175
|
def list_items(glob_pattern, options = {})
|
171
176
|
list = { 0 => 'Exit' }
|
172
177
|
index = 1
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
178
|
+
raw_list = { }
|
179
|
+
|
180
|
+
Dir["#{glob_pattern}"].each do |elem|
|
181
|
+
#puts "=> element '#{elem}' - dir = #{File.directory?(elem)}; file = #{File.file?(elem)}"
|
182
|
+
next if (! options[:only_files].nil?) && options[:only_files] && File.directory?(elem)
|
183
|
+
next if (! options[:only_dirs].nil?) && options[:only_dirs] && File.file?(elem)
|
184
|
+
entry = File.basename(elem)
|
185
|
+
unless options[:pattern_include].nil?
|
186
|
+
select_entry = false
|
187
|
+
options[:pattern_include].each do |pattern|
|
188
|
+
#puts "considering pattern '#{pattern}' on entry '#{entry}'"
|
189
|
+
select_entry |= entry =~ /#{pattern}/
|
190
|
+
end
|
191
|
+
next unless select_entry
|
192
|
+
end
|
193
|
+
unless options[:pattern_exclude].nil?
|
194
|
+
select_entry = false
|
195
|
+
options[:pattern_exclude].each do |pattern|
|
196
|
+
#puts "considering pattern '#{pattern}' on entry '#{entry}'"
|
197
|
+
select_entry |= entry =~ /#{pattern}/
|
198
|
+
end
|
199
|
+
next if select_entry
|
200
|
+
end
|
201
|
+
#puts "selected entry = '#{entry}'"
|
202
|
+
list[index] = entry
|
203
|
+
raw_list[index] = elem
|
204
|
+
index += 1
|
200
205
|
end
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
206
|
+
text = options[:text].nil? ? "select the index" : options[:text]
|
207
|
+
default_idx = options[:default].nil? ? 0 : options[:default]
|
208
|
+
raise SystemExit.new('Empty list') if index == 1
|
209
|
+
# puts list.to_yaml
|
210
|
+
# answer = ask("=> #{text}", "#{default_idx}")
|
211
|
+
# raise SystemExit.new('exiting selection') if answer == '0'
|
212
|
+
# raise RangeError.new('Undefined index') if Integer(answer) >= list.length
|
213
|
+
# raw_list[Integer(answer)]
|
214
|
+
select_from(list, text, default_idx, raw_list)
|
210
215
|
end
|
211
216
|
|
212
217
|
## Display a indexed list to select an i
|
213
218
|
def select_from(list, text = 'Select the index', default_idx = 0, raw_list = list)
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
+
error "list and raw_list differs in size" if list.size != raw_list.size
|
220
|
+
l = list
|
221
|
+
raw_l = raw_list
|
222
|
+
if list.kind_of?(Array)
|
223
|
+
l = raw_l = { 0 => 'Exit' }
|
224
|
+
list.each_with_index do |e, idx|
|
225
|
+
l[idx+1] = e
|
226
|
+
raw_l[idx+1] = raw_list[idx]
|
227
|
+
end
|
228
|
+
end
|
229
|
+
puts l.to_yaml
|
230
|
+
answer = ask("=> #{text}", "#{default_idx}")
|
231
|
+
raise SystemExit.new('exiting selection') if answer == '0'
|
232
|
+
raise RangeError.new('Undefined index') if Integer(answer) >= l.length
|
233
|
+
raw_l[Integer(answer)]
|
219
234
|
end # select_from
|
220
235
|
|
221
236
|
|
@@ -237,6 +252,88 @@ module FalkorLib #:nodoc:
|
|
237
252
|
end
|
238
253
|
end
|
239
254
|
|
255
|
+
#################################
|
256
|
+
### [ERB] template generation ###
|
257
|
+
#################################
|
258
|
+
|
259
|
+
# Bootstrap the destination directory `rootdir` using the template
|
260
|
+
# directory `templatedir`. the hash table `config` hosts the elements to
|
261
|
+
# feed ERB files which **should** have the extension .erb.
|
262
|
+
# The initialization is performed as follows:
|
263
|
+
# * a rsync process is initiated to duplicate the directory structure
|
264
|
+
# and the symlinks, and exclude .erb files
|
265
|
+
# * each erb files (thus with extension .erb) is interpreted, the
|
266
|
+
# corresponding file is generated without the .erb extension
|
267
|
+
# Supported options:
|
268
|
+
# :erb_exclude [array of strings]: pattern(s) to exclude from erb file
|
269
|
+
# interpretation and thus to copy 'as is'
|
270
|
+
def init_from_template(templatedir, rootdir, config = {}, options = {})
|
271
|
+
error "Unable to find the template directory" unless File.directory?(templatedir)
|
272
|
+
warning "about to initialize/update the directory #{rootdir}"
|
273
|
+
really_continue?
|
274
|
+
run %{ mkdir -p #{rootdir} } unless File.directory?( rootdir )
|
275
|
+
run %{ rsync --exclude '*.erb' -avzu #{templatedir}/ #{rootdir}/ }
|
276
|
+
Dir["#{templatedir}/**/*.erb"].each do |erbfile|
|
277
|
+
relative_outdir = Pathname.new( File.realpath( File.dirname(erbfile) )).relative_path_from Pathname.new(templatedir)
|
278
|
+
filename = File.basename(erbfile, '.erb')
|
279
|
+
outdir = File.realpath( File.join(rootdir, relative_outdir.to_s) )
|
280
|
+
outfile = File.join(outdir, filename)
|
281
|
+
unless options[:erb_exclude].nil?
|
282
|
+
exclude_entry = false
|
283
|
+
options[:erb_exclude].each do |pattern|
|
284
|
+
exclude_entry |= erbfile =~ /#{pattern}/
|
285
|
+
end
|
286
|
+
if exclude_entry
|
287
|
+
info "copying non-interpreted ERB file"
|
288
|
+
# copy this file since it has been probably excluded from teh rsync process
|
289
|
+
run %{ cp #{erbfile} #{outdir}/ }
|
290
|
+
next
|
291
|
+
end
|
292
|
+
end
|
293
|
+
# Let's go
|
294
|
+
info "updating '#{relative_outdir.to_s}/#{filename}'"
|
295
|
+
puts " using ERB template '#{erbfile}'"
|
296
|
+
template = File.read("#{erbfile}")
|
297
|
+
output = ERB.new(template, nil, '<>')
|
298
|
+
if File.exists?( outfile )
|
299
|
+
warn "the file '#{outfile}' already exists and will be overwritten."
|
300
|
+
error "TODO: watch the diff ;)"
|
301
|
+
else
|
302
|
+
watch = ask( cyan(" ==> Do you want to see the generated file before commiting the writing (y|N)"), 'No')
|
303
|
+
puts output.result(binding) if watch =~ /y.*/i
|
304
|
+
end
|
305
|
+
proceed = ask( cyan(" ==> proceed with the writing (Y|n)"), 'Yes')
|
306
|
+
next if proceed =~ /n.*/i
|
307
|
+
info("=> writing #{outfile}")
|
308
|
+
File.open("#{outfile}", "w+") do |f|
|
309
|
+
f.puts output.result(binding)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
### RVM init
|
315
|
+
def init_rvm(rootdir = Dir.pwd, gemset = '')
|
316
|
+
rvm_files = {
|
317
|
+
:version => File.join(rootdir, '.ruby-version'),
|
318
|
+
:gemset => File.join(rootdir, '.ruby-gemset')
|
319
|
+
}
|
320
|
+
unless File.exists?( "#{rvm_files[:version]}")
|
321
|
+
v = select_from(FalkorLib.config[:rvm][:rubies],
|
322
|
+
"Select RVM ruby to configure for this directory",
|
323
|
+
3)
|
324
|
+
File.open( rvm_files[:version], 'w') do |f|
|
325
|
+
f.puts v
|
326
|
+
end
|
327
|
+
end
|
328
|
+
unless File.exists?( "#{rvm_files[:gemset]}")
|
329
|
+
g = gemset.empty? ? ask("Enter RVM gemset name for this directory", File.basename(rootdir)) : gemset
|
330
|
+
File.open( rvm_files[:gemset], 'w') do |f|
|
331
|
+
f.puts g
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
end
|
336
|
+
|
240
337
|
|
241
338
|
end
|
242
339
|
end
|
data/lib/falkorlib/config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Lun 2014-08-25 22:29 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# FalkorLib Configuration
|
6
6
|
#
|
@@ -40,8 +40,12 @@ module FalkorLib #:nodoc:
|
|
40
40
|
module Config #:nodoc:
|
41
41
|
# Defaults global settings
|
42
42
|
DEFAULTS = {
|
43
|
-
:debug
|
44
|
-
:root
|
43
|
+
:debug => false,
|
44
|
+
:root => Dir.pwd,
|
45
|
+
:custom_cfg => '.falkorlib.yaml',
|
46
|
+
:rvm => {
|
47
|
+
:rubies => [ '1.9.3', '2.0.0', '2.1.0']
|
48
|
+
}
|
45
49
|
}
|
46
50
|
|
47
51
|
module_function
|
@@ -50,11 +54,17 @@ module FalkorLib #:nodoc:
|
|
50
54
|
# The hash is built depending on the loaded files.
|
51
55
|
def default
|
52
56
|
res = FalkorLib::Config::DEFAULTS
|
53
|
-
|
54
|
-
res[:git]
|
55
|
-
res[:gitflow]
|
57
|
+
$LOADED_FEATURES.each do |path|
|
58
|
+
res[:git] = FalkorLib::Config::Git::DEFAULTS if path.include?('lib/falkorlib/git.rb')
|
59
|
+
res[:gitflow] = FalkorLib::Config::GitFlow::DEFAULTS if path.include?('lib/falkorlib/git.rb')
|
56
60
|
res[:versioning] = FalkorLib::Config::Versioning::DEFAULTS if path.include?('lib/falkorlib/versioning.rb')
|
61
|
+
res[:puppet] = FalkorLib::Config::Puppet::DEFAULTS if path.include?('lib/falkorlib/puppet.rb')
|
57
62
|
end
|
63
|
+
# Check the potential local customizations
|
64
|
+
custom_cfg = File.join( res[:root], res[:custom_cfg])
|
65
|
+
if File.exists?( custom_cfg )
|
66
|
+
res.merge!( load_config( custom_cfg ) )
|
67
|
+
end
|
58
68
|
res
|
59
69
|
end
|
60
70
|
|
data/lib/falkorlib/git/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Mar 2014-08-26 11:54 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Interface for the main Git operations
|
6
6
|
#
|
@@ -100,6 +100,7 @@ module FalkorLib #:nodoc:
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
exit_status = 1
|
103
|
+
#info "Initialize "
|
103
104
|
Dir.chdir( path ) do
|
104
105
|
execute "git init" unless FalkorLib.config.debug
|
105
106
|
exit_status = $?.to_i
|
@@ -209,8 +210,6 @@ module FalkorLib #:nodoc:
|
|
209
210
|
g.capturing.ls_files.split
|
210
211
|
end
|
211
212
|
|
212
|
-
|
213
|
-
|
214
213
|
## Add a file/whatever to Git and commit it
|
215
214
|
def add(path, msg = "")
|
216
215
|
exit_status = 0
|
@@ -251,6 +250,11 @@ module FalkorLib #:nodoc:
|
|
251
250
|
g.capturing.remote.split()
|
252
251
|
end
|
253
252
|
|
253
|
+
## remotes?(path = Dir.pw)
|
254
|
+
def remotes?(path = Dir.pwd)
|
255
|
+
return ! remotes(path).empty?
|
256
|
+
end
|
257
|
+
|
254
258
|
## Initialize git subtrees from the configuration
|
255
259
|
def submodule_init(path = Dir.pwd)
|
256
260
|
exit_status = 1
|
data/lib/falkorlib/git/flow.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Mar 2014-08-26 11:57 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Management of Git Flow operations
|
6
6
|
|
@@ -49,9 +49,11 @@ module FalkorLib
|
|
49
49
|
unless FalkorLib::Git.has_commits?( git_root_dir)
|
50
50
|
warn "Not yet any commit detected in this repository."
|
51
51
|
readme = 'README.md'
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
unless File.exists?( readme )
|
53
|
+
answer = ask(cyan("=> initialize a commit with a #{readme} file (Y|n)?"), 'Yes')
|
54
|
+
exit 0 if answer =~ /n.*/i
|
55
|
+
FileUtils.touch(readme)
|
56
|
+
end
|
55
57
|
FalkorLib::Git.add(readme, "Initiate the repository with a '#{readme}' file")
|
56
58
|
end
|
57
59
|
branches = FalkorLib::Git.list_branch(path)
|
@@ -104,6 +106,16 @@ module FalkorLib
|
|
104
106
|
exit_status
|
105
107
|
end
|
106
108
|
|
109
|
+
## Check if git-flow is initialized
|
110
|
+
def init?(path = Dir.pwd)
|
111
|
+
res = FalkorLib::Git.init?(path)
|
112
|
+
Dir.chdir(path) do
|
113
|
+
gf_check = `git config --get-regexp 'gitflow*'`
|
114
|
+
res &= ! gf_check.empty?
|
115
|
+
end
|
116
|
+
res
|
117
|
+
end # init?(path = Dir.pwd)
|
118
|
+
|
107
119
|
|
108
120
|
## generic function to run any of the gitflow commands
|
109
121
|
def command(name, type = 'feature', action = 'start', path = Dir.pwd, optional_args = '')
|
data/lib/falkorlib/loader.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Lun 2014-08-25 21:04 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Place the component you wish to see loaded
|
6
6
|
|
@@ -8,4 +8,5 @@ require "falkorlib/config"
|
|
8
8
|
require "falkorlib/common"
|
9
9
|
require "falkorlib/git"
|
10
10
|
require "falkorlib/versioning"
|
11
|
+
require "falkorlib/puppet"
|
11
12
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# Time-stamp: <Lun 2014-08-25 21:35 svarrette>
|
4
|
+
################################################################################
|
5
|
+
# Management of [Puppet](http://puppetlabs.com/) operations
|
6
|
+
|
7
|
+
require "falkorlib"
|
8
|
+
|
9
|
+
module FalkorLib #:nodoc:
|
10
|
+
|
11
|
+
end # module FalkorLib
|
12
|
+
|
13
|
+
require "falkorlib/puppet/base"
|
14
|
+
require "falkorlib/puppet/modules"
|
15
|
+
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# Time-stamp: <Lun 2014-08-25 21:34 svarrette>
|
4
|
+
################################################################################
|
5
|
+
# Interface for the main Puppet operations
|
6
|
+
#
|
7
|
+
|
8
|
+
require "falkorlib"
|
9
|
+
require "falkorlib/common"
|
10
|
+
|
11
|
+
|
12
|
+
include FalkorLib::Common
|
13
|
+
|
14
|
+
module FalkorLib #:nodoc:
|
15
|
+
module Config
|
16
|
+
module Puppet
|
17
|
+
# Puppet defaults for FalkorLib
|
18
|
+
DEFAULTS = {
|
19
|
+
:modulesdir => File.join(Dir.pwd, 'modules')
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Puppet #:nodoc
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# Time-stamp: <Mar 2014-08-26 14:17 svarrette>
|
4
|
+
################################################################################
|
5
|
+
# Interface for the main Puppet Module operations
|
6
|
+
#
|
7
|
+
|
8
|
+
require "falkorlib"
|
9
|
+
require "falkorlib/common"
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
|
13
|
+
include FalkorLib::Common
|
14
|
+
|
15
|
+
module FalkorLib #:nodoc:
|
16
|
+
module Config
|
17
|
+
module Puppet
|
18
|
+
module Modules
|
19
|
+
DEFAULTS = {
|
20
|
+
:metadata => {
|
21
|
+
:name => '',
|
22
|
+
:version => '0.0.1',
|
23
|
+
:author => "#{ENV['GIT_AUTHOR_NAME']}",
|
24
|
+
:mail => "#{ENV['GIT_AUTHOR_EMAIL']}",
|
25
|
+
:summary => "rtfm",
|
26
|
+
:description => '',
|
27
|
+
:license => 'GPLv3',
|
28
|
+
:source => '',
|
29
|
+
:project_page => '',
|
30
|
+
:issue_url => '',
|
31
|
+
:dependencies => [],
|
32
|
+
:operatingsystem_support => [],
|
33
|
+
:tags => []
|
34
|
+
},
|
35
|
+
:licenses => [
|
36
|
+
"Apache-2.0",
|
37
|
+
"BSD",
|
38
|
+
"GPL-2.0",
|
39
|
+
"GPL-3.0",
|
40
|
+
"LGPL-2.1",
|
41
|
+
"LGPL-3.0",
|
42
|
+
"MIT",
|
43
|
+
"Mozilla-2.0"
|
44
|
+
]
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Puppet actions
|
51
|
+
module Puppet
|
52
|
+
# Management of Puppet Modules operations
|
53
|
+
module Modules
|
54
|
+
module_function
|
55
|
+
|
56
|
+
## Initialize a new Puppet Module named `name` in `rootdir`.
|
57
|
+
# Supported options:
|
58
|
+
# * :no_iteraction [boolean]
|
59
|
+
def init(rootdir = Dir.pwd, name = '', options = {})
|
60
|
+
config = {}
|
61
|
+
login = `whoami`.chomp
|
62
|
+
config[:name] = name unless name.empty?
|
63
|
+
FalkorLib::Config::Puppet::Modules::DEFAULTS[:metadata].each do |k,v|
|
64
|
+
next if v.kind_of?(Array) or k == :license
|
65
|
+
next if k == :name and ! name.empty?
|
66
|
+
default_answer = case k
|
67
|
+
when :project_page
|
68
|
+
config[:source].nil? ? v : config[:source]
|
69
|
+
when :name
|
70
|
+
File.basename(rootdir).gsub(/^puppet-/, '')
|
71
|
+
when :issue_url
|
72
|
+
config[:project_page].nil? ? v : "#{config[:project_page]}/issues"
|
73
|
+
when :description
|
74
|
+
config[:summary].nil? ? v : "#{config[:summary]}"
|
75
|
+
when :source
|
76
|
+
v.empty? ? "https://github.com/#{`whoami`.chomp}/#{config[:name]}" : v
|
77
|
+
else
|
78
|
+
v
|
79
|
+
end
|
80
|
+
config[k.to_sym] = ask( "\t" + sprintf("%-20s", "Module #{k}"), default_answer)
|
81
|
+
end
|
82
|
+
name = config[:name].gsub(/.*-/, '')
|
83
|
+
tags = ask("\tKeywords (comma-separated list of tags)", name)
|
84
|
+
config[:tags] = tags.split(',')
|
85
|
+
license = select_from(FalkorLib::Config::Puppet::Modules::DEFAULTS[:licenses],
|
86
|
+
'Select the license index for the Puppet module:',
|
87
|
+
1)
|
88
|
+
config[:license] = license.downcase unless license.empty?
|
89
|
+
puts "\t" + sprintf("%-20s", "Module License:") + config[:license]
|
90
|
+
|
91
|
+
#ap config
|
92
|
+
# Bootstrap the directory
|
93
|
+
templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
|
94
|
+
init_from_template(templatedir, rootdir, config, {
|
95
|
+
:erb_exclude => [ 'templates\/[^\/]*\.erb$' ]
|
96
|
+
})
|
97
|
+
# Rename the files / element templatename
|
98
|
+
Dir["#{rootdir}/**/*"].each do |e|
|
99
|
+
next unless e =~ /templatename/
|
100
|
+
info "renaming #{e}"
|
101
|
+
newname = e.gsub(/templatename/, "#{name}")
|
102
|
+
run %{ mv #{e} #{newname} }
|
103
|
+
end
|
104
|
+
|
105
|
+
info "Generating the License file"
|
106
|
+
Dir.chdir(rootdir) do
|
107
|
+
run %{licgen #{config[:license]} #{config[:author]}}
|
108
|
+
end
|
109
|
+
info "Initialize RVM"
|
110
|
+
init_rvm(rootdir)
|
111
|
+
unless FalkorLib::GitFlow.init?(rootdir)
|
112
|
+
warn "Git [Flow] is not initialized in #{rootdir}."
|
113
|
+
a = ask("Proceed to git-flow initialization (Y|n)", 'Yes')
|
114
|
+
FalkorLib::GitFlow.init(rootdir) unless a =~ /n.*/i
|
115
|
+
end
|
116
|
+
|
117
|
+
# Propose to commit the key files
|
118
|
+
if FalkorLib::Git.init?(rootdir)
|
119
|
+
if FalkorLib::GitFlow.init?(rootdir)
|
120
|
+
info "=> preparing git-flow feature for the newly created module '#{config[:name]}'"
|
121
|
+
FalkorLib::GitFlow.start('feature', "init_#{name}", rootdir)
|
122
|
+
end
|
123
|
+
[ 'metadata.json', 'LICENSE', '.gitignore', 'Gemfile', 'Rakefile'].each do |f|
|
124
|
+
FalkorLib::Git.add(File.join(rootdir, f))
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end # init
|
128
|
+
|
129
|
+
|
130
|
+
end # module FalkorLib::Puppet::Modules
|
131
|
+
end # module FalkorLib::Puppet
|
132
|
+
end # module FalkorLib
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# Time-stamp: <Lun 2014-08-25 21:46 svarrette>
|
4
|
+
################################################################################
|
5
|
+
#
|
6
|
+
# FalkorLib rake tasks to pilot Puppet operations
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'falkorlib'
|
11
|
+
require 'falkorlib/tasks'
|
12
|
+
|
13
|
+
module FalkorLib #:nodoc:
|
14
|
+
class PuppetTasks
|
15
|
+
include Rake::DSL if defined? Rake::DSL
|
16
|
+
|
17
|
+
# Install the puppet tasks for Rake
|
18
|
+
def install_tasks
|
19
|
+
load 'falkorlib/tasks/puppet_modules.rake'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
FalkorLib::PuppetTasks.new.install_tasks
|
data/lib/falkorlib/tasks.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Lun 2014-08-25 23:25 svarrette>
|
4
4
|
################################################################################
|
5
5
|
#
|
6
6
|
# Default FalkorLib rake tasks
|
@@ -17,7 +17,7 @@ FalkorLib.config.debug = ARGV.include?('DEBUG')
|
|
17
17
|
#.....................
|
18
18
|
namespace :falkorlib do
|
19
19
|
########### falkorlib:conf ###########
|
20
|
-
|
20
|
+
desc "Print the current configuration of FalkorLib"
|
21
21
|
task :conf do
|
22
22
|
puts FalkorLib.config.to_yaml
|
23
23
|
end
|
@@ -37,12 +37,18 @@ namespace :bootstrap do
|
|
37
37
|
task :rvm do
|
38
38
|
info "Boostrap RVM for this repository -- see https://rvm.io"
|
39
39
|
error "RVM is not installed -- see https://rvm.io/rvm/install for instructions" unless command?('rvm')
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
init_rvm(Dir.pwd)
|
41
|
+
# ['version', 'gemset'].each do |t|
|
42
|
+
# error "unable to find the .ruby-#{t} file" unless File.exists?(".ruby-#{t}")
|
43
|
+
# end
|
43
44
|
info "=> initialize RVM -- see http://rvm.io"
|
44
45
|
run %{ rvm install `cat .ruby-version` }
|
45
|
-
|
46
|
+
rvm_current = `rvm current`
|
47
|
+
if rvm_current.empty? or rvm_current != "`cat .ruby-version`@`cat .ruby-gemset`"
|
48
|
+
warn "You need to manually force the reloading of the RVM configuration."
|
49
|
+
warn "To do that, simply run \n\t\tcd .. && cd -"
|
50
|
+
error "manual RVM reloading required"
|
51
|
+
end
|
46
52
|
#rvmenv = %x( rvm env --path -- `cat .ruby-version`@`cat .ruby-gemset`)
|
47
53
|
# info "=> Force reloading RVM configuration within $PWD"
|
48
54
|
# run %{
|
@@ -1,6 +1,6 @@
|
|
1
1
|
################################################################################
|
2
2
|
# gitflow.rake - Special tasks for the management of Git [Flow] operations
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Sam 2014-08-23 15:19 svarrette>
|
4
4
|
#
|
5
5
|
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
6
6
|
# http://varrette.gforge.uni.lu
|
@@ -16,9 +16,9 @@ namespace :git do
|
|
16
16
|
include FalkorLib::Common
|
17
17
|
git_root_dir = FalkorLib::Git.rootdir
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
########### git:init ###########
|
20
|
+
#desc "Initialize Git repository"
|
21
|
+
task :init => [ 'git:flow:init' ]
|
22
22
|
|
23
23
|
#.....................
|
24
24
|
namespace :flow do
|
@@ -26,7 +26,7 @@ namespace :git do
|
|
26
26
|
########### git:flow:init ###########
|
27
27
|
desc "Initialize your local clone of the repository for the git-flow management"
|
28
28
|
task :init do |t|
|
29
|
-
|
29
|
+
info t.comment
|
30
30
|
FalkorLib::GitFlow.init(git_root_dir)
|
31
31
|
end # task init
|
32
32
|
|
@@ -45,7 +45,7 @@ namespace :git do
|
|
45
45
|
Rake::Task['git:up'].invoke unless FalkorLib::Git.remotes.empty?
|
46
46
|
info "=> prepare new 'feature' using git flow"
|
47
47
|
o = FalkorLib::GitFlow.start('feature', name)
|
48
|
-
|
48
|
+
error "Git flow feature operation failed" unless o == 0
|
49
49
|
# Now you should be in the new branch
|
50
50
|
end
|
51
51
|
|
@@ -61,7 +61,7 @@ namespace :git do
|
|
61
61
|
info t.comment
|
62
62
|
o = FalkorLib::GitFlow.finish('feature', name)
|
63
63
|
error "Git flow feature operation failed" unless o == 0
|
64
|
-
|
64
|
+
unless FalkorLib::Git.remotes.empty?
|
65
65
|
info "=> about to update remote tracked branches"
|
66
66
|
really_continue?
|
67
67
|
Rake::Task['git:push'].invoke
|
@@ -103,22 +103,22 @@ namespace :version do
|
|
103
103
|
Rake::Task['git:up'].invoke unless FalkorLib::Git.remotes.empty?
|
104
104
|
info "=> prepare release using git flow"
|
105
105
|
o = FalkorLib::GitFlow.start('release', release_version)
|
106
|
-
|
106
|
+
error "Git flow release process failed" unless o == 0
|
107
107
|
# Now you should be in the new branch
|
108
108
|
current_branch = FalkorLib::Git.branch?
|
109
109
|
expected_branch = FalkorLib.config[:gitflow][:prefix][:release] + release_version
|
110
110
|
if (current_branch == expected_branch)
|
111
111
|
FalkorLib::Versioning.set_version(release_version)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
# Update cache info
|
112
|
+
if (! FalkorLib.config[:versioning].nil?) &&
|
113
|
+
FalkorLib.config[:versioning][:type] == 'gem' &&
|
114
|
+
File.exists?(File.join(FalkorLib::Git.rootdir, 'Gemfile'))
|
115
|
+
info "Updating Gemfile information"
|
116
|
+
run %{
|
117
|
+
# Update cache info
|
118
118
|
bundle list > /dev/null
|
119
119
|
git commit -s -m "Update Gemfile.lock accordingly" Gemfile.lock
|
120
120
|
}
|
121
|
-
|
121
|
+
end
|
122
122
|
warning "The version number has already been bumped"
|
123
123
|
warning "==> run 'rake version:release' to finalize the release and merge the current version of the repository into the '#{FalkorLib.config[:gitflow][:branches][:master]}' branch"
|
124
124
|
else
|
@@ -128,35 +128,37 @@ namespace :version do
|
|
128
128
|
end
|
129
129
|
end # namespace version:bump
|
130
130
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
131
|
+
########### release ###########
|
132
|
+
desc "Finalize the release of a given bumped version"
|
133
|
+
task :release do |t|
|
134
|
+
version = FalkorLib::Versioning.get_version
|
135
|
+
branch = FalkorLib::Git.branch?
|
136
|
+
expected_branch = FalkorLib.config[:gitflow][:prefix][:release] + version
|
137
|
+
error "You are not in the '#{expected_branch}' branch but in the '#{branch}' one. May be you forgot to run 'rake version:bump:{patch,minor,major}' first" if branch != expected_branch
|
138
|
+
info "=> Finalize the release of the version '#{version}' into the '#{FalkorLib.config[:gitflow][:branches][:master]}' branch/environment"
|
139
|
+
o = FalkorLib::GitFlow.finish('release', version, Dir.pwd, '-s')
|
140
|
+
error "Git flow release process failed" unless o == 0
|
141
|
+
if FalkorLib::Git.remotes?
|
142
|
+
info("=> about to update remote tracked branches")
|
143
|
+
really_continue?
|
144
|
+
FalkorLib.config[:gitflow][:branches].each do |type, branch|
|
145
|
+
run %{
|
146
|
+
git checkout #{branch}
|
147
|
+
git push origin
|
148
|
+
}
|
149
|
+
end
|
150
|
+
run %{ git push origin --tags }
|
151
|
+
end
|
152
|
+
#info "Update the changelog"
|
153
|
+
if (! FalkorLib.config[:versioning].nil?) &&
|
154
|
+
FalkorLib.config[:versioning][:type] == 'gem'
|
155
|
+
warn "About to push the released new gem (version #{version}) to the gem server (rybygems.org)"
|
156
|
+
really_continue?
|
157
|
+
Rake::Task['gem:release'].invoke
|
158
|
+
end
|
159
|
+
|
160
|
+
#Rake::Task['git:push'].invoke
|
161
|
+
end # task version:release
|
160
162
|
|
161
163
|
|
162
164
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# Time-stamp: <Lun 2014-08-25 21:46 svarrette>
|
4
|
+
################################################################################
|
5
|
+
#
|
6
|
+
# FalkorLib rake tasks to pilot Puppet operations
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'falkorlib'
|
11
|
+
require 'falkorlib/tasks'
|
12
|
+
|
13
|
+
module FalkorLib #:nodoc:
|
14
|
+
class PuppetTasks
|
15
|
+
include Rake::DSL if defined? Rake::DSL
|
16
|
+
|
17
|
+
# Install the puppet tasks for Rake
|
18
|
+
def install_tasks
|
19
|
+
load 'falkorlib/tasks/puppet_modules.rake'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
FalkorLib::PuppetTasks.new.install_tasks
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# puppet_modules.rake - Special tasks for the management of Puppet modules
|
4
|
+
# Time-stamp: <Lun 2014-08-25 22:54 svarrette>
|
5
|
+
#
|
6
|
+
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
7
|
+
# http://varrette.gforge.uni.lu
|
8
|
+
################################################################################
|
9
|
+
|
10
|
+
require 'falkorlib'
|
11
|
+
require 'falkorlib/tasks'
|
12
|
+
require 'falkorlib/puppet'
|
13
|
+
|
14
|
+
#.....................
|
15
|
+
namespace :bootstrap do
|
16
|
+
#.....................
|
17
|
+
namespace :puppet do
|
18
|
+
|
19
|
+
########### bootstrap:puppet:module ###########
|
20
|
+
desc "Bootstrap a new Puppet module"
|
21
|
+
task :module, [:name] do |t, args|
|
22
|
+
info "#{t.comment}"
|
23
|
+
name = args.name == 'name' ? ask("Enter the module name") : args.name
|
24
|
+
error "You need to provide a module name" unless name != ''
|
25
|
+
error "The module name cannot contain spaces" if name =~ /\s+/
|
26
|
+
moduledir = File.join( FalkorLib.config[:puppet][:modulesdir], name)
|
27
|
+
dir = ask("Destination directory:", moduledir)
|
28
|
+
error "The module '#{name}' already exists" if File.directory?(dir)
|
29
|
+
FalkorLib::Puppet::Modules.init(dir, name)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end # namespace bootstrap:puppet
|
34
|
+
end # namespace bootstrap
|
35
|
+
|
@@ -32,7 +32,7 @@ begin
|
|
32
32
|
# Glob pattern to match files.
|
33
33
|
#t.pattern = "spec/**/test_*.rb"
|
34
34
|
#t.pattern = "spec/**/*_spec.rb"
|
35
|
-
#t.pattern = "spec/**/
|
35
|
+
#t.pattern = "spec/**/puppet*spec.rb"
|
36
36
|
|
37
37
|
# Whether or not to fail Rake when an error occurs (typically when
|
38
38
|
# examples fail).
|
data/lib/falkorlib/version.rb
CHANGED
@@ -19,7 +19,7 @@ module FalkorLib #:nodoc:
|
|
19
19
|
# MAJOR: Defines the major version
|
20
20
|
# MINOR: Defines the minor version
|
21
21
|
# PATCH: Defines the patch version
|
22
|
-
MAJOR, MINOR, PATCH = 0,
|
22
|
+
MAJOR, MINOR, PATCH = 0, 3, 0
|
23
23
|
|
24
24
|
module_function
|
25
25
|
|
@@ -71,3 +71,4 @@ module FalkorLib #:nodoc:
|
|
71
71
|
# Shorter version of the Gem's VERSION
|
72
72
|
VERSION = Version.to_s
|
73
73
|
end
|
74
|
+
|
data/lib/falkorlib/versioning.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Sam 2014-08-23 12:32 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
6
6
|
#
|
7
7
|
# FalkorLib Version management
|
8
8
|
#
|
9
|
+
require 'json'
|
9
10
|
|
10
11
|
module FalkorLib #:nodoc:
|
11
12
|
|
@@ -28,6 +29,9 @@ module FalkorLib #:nodoc:
|
|
28
29
|
#:setmethod => 'FalkorLib::Version.set',
|
29
30
|
#:pattern => '^(\s*)MAJOR\s*,\s*MINOR,\s*PATCH\s*=\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)'
|
30
31
|
},
|
32
|
+
'puppet_module' => {
|
33
|
+
:filename => 'metadata.json'
|
34
|
+
},
|
31
35
|
'tag' => {
|
32
36
|
:suffix => 'v'
|
33
37
|
},
|
@@ -75,6 +79,10 @@ module FalkorLib #:nodoc:
|
|
75
79
|
when 'gem'
|
76
80
|
getmethod = source[:getmethod ]
|
77
81
|
version = eval( getmethod ) unless (getmethod.nil? || getmethod.empty?)
|
82
|
+
when 'puppet_module'
|
83
|
+
jsonfile = File.join( rootdir, source[:filename] )
|
84
|
+
metadata = JSON.parse( IO.read( jsonfile ) )
|
85
|
+
version = metadata["version"]
|
78
86
|
end
|
79
87
|
version
|
80
88
|
end
|
@@ -101,6 +109,13 @@ module FalkorLib #:nodoc:
|
|
101
109
|
f.rewind
|
102
110
|
f.write(text)
|
103
111
|
end
|
112
|
+
when 'puppet_module'
|
113
|
+
info "=> writing version changes in #{source[:filename]}"
|
114
|
+
metadata = JSON.parse( IO.read( versionfile ) )
|
115
|
+
metadata["version"] = version
|
116
|
+
File.open(versionfile,"w") do |f|
|
117
|
+
f.write JSON.pretty_generate( metadata )
|
118
|
+
end
|
104
119
|
#exit 1
|
105
120
|
end
|
106
121
|
Dir.chdir( rootdir ) do
|
data/spec/falkorlib/git_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# git_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <
|
5
|
+
# Time-stamp: <Sam 2014-08-23 15:26 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Git operations
|
8
8
|
#
|
@@ -44,6 +44,11 @@ describe FalkorLib::Git do
|
|
44
44
|
t.should be_true
|
45
45
|
end
|
46
46
|
|
47
|
+
it "#remotes? -- should be false" do
|
48
|
+
t = FalkorLib::Git.remotes?(dir)
|
49
|
+
t.should be_false
|
50
|
+
end
|
51
|
+
|
47
52
|
it "#rootdir #gitdir - checks git dir and working tree" do
|
48
53
|
subdir = File.join(dir, 'some_dir')
|
49
54
|
Dir.mkdir( subdir )
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# gitflow_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <
|
5
|
+
# Time-stamp: <Mar 2014-08-26 11:15 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Git Flow operations -- see https://github.com/nvie/gitflow
|
8
8
|
#
|
@@ -30,9 +30,9 @@ describe FalkorLib::GitFlow do
|
|
30
30
|
context "Test git-flow operations within temporary directory " do
|
31
31
|
|
32
32
|
it "#init? - fails on non-git directory" do
|
33
|
-
t = FalkorLib::
|
33
|
+
t = FalkorLib::GitFlow.init?(dir)
|
34
34
|
t.should be_false
|
35
|
-
end
|
35
|
+
end
|
36
36
|
|
37
37
|
it "#init - initialize a git-flow repository" do
|
38
38
|
STDIN.should_receive(:gets).and_return('Yes')
|
@@ -42,6 +42,11 @@ describe FalkorLib::GitFlow do
|
|
42
42
|
t.should be_true
|
43
43
|
end
|
44
44
|
|
45
|
+
it "#init? - succeed on git-flow enabled directory" do
|
46
|
+
t = FalkorLib::GitFlow.init?(dir)
|
47
|
+
t.should be_true
|
48
|
+
end
|
49
|
+
|
45
50
|
#['feature', 'hotfix', 'support'].each do |op|
|
46
51
|
['feature'].each do |op|
|
47
52
|
name = 'toto'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#########################################
|
3
|
+
# puppet_modules_spec.rb
|
4
|
+
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
+
# Time-stamp: <Mar 2014-08-26 15:04 svarrette>
|
6
|
+
#
|
7
|
+
# @description Check the Puppet Modules operations
|
8
|
+
#
|
9
|
+
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
10
|
+
# . http://varrette.gforge.uni.lu
|
11
|
+
##############################################################################
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'tmpdir'
|
15
|
+
require 'falkorlib/puppet'
|
16
|
+
|
17
|
+
describe FalkorLib::Puppet::Modules do
|
18
|
+
include FalkorLib::Common
|
19
|
+
|
20
|
+
dir = Dir.mktmpdir
|
21
|
+
#afile = File.join(dir, 'a_file')
|
22
|
+
|
23
|
+
after :all do
|
24
|
+
FileUtils.remove_entry_secure dir
|
25
|
+
end
|
26
|
+
|
27
|
+
#############################################################
|
28
|
+
context "Test Puppet Module creation within temporary directory " do
|
29
|
+
|
30
|
+
it "#init -- create a puppet module" do
|
31
|
+
Array.new(18).each { |e| STDIN.should_receive(:gets).and_return('') }
|
32
|
+
name = 'toto'
|
33
|
+
FalkorLib::Puppet::Modules.init(dir, name)
|
34
|
+
templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
|
35
|
+
s = true
|
36
|
+
Dir["#{templatedir}/**/*"].each do |e|
|
37
|
+
next if File.directory?(e)
|
38
|
+
relative_dir = Pathname.new( File.realpath( File.dirname(e) )).relative_path_from Pathname.new(templatedir)
|
39
|
+
file = e.gsub(/templatename/, "#{name}")
|
40
|
+
filename = File.basename(file)
|
41
|
+
filename = File.basename(file, '.erb') unless file =~ /templates\/toto-variables\.erb/
|
42
|
+
f = File.join(dir, relative_dir, filename)
|
43
|
+
#puts "checking #{f} - #{File.exists?( f )}"
|
44
|
+
s &= File.exists?( f )
|
45
|
+
end
|
46
|
+
s.should be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falkorlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Varrette
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -100,6 +100,34 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.2'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: json
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.8'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.8'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: license-generator
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
103
131
|
- !ruby/object:Gem::Dependency
|
104
132
|
name: bundler
|
105
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,12 +277,18 @@ files:
|
|
249
277
|
- lib/falkorlib/git/flow.rb
|
250
278
|
- lib/falkorlib/git_tasks.rb
|
251
279
|
- lib/falkorlib/loader.rb
|
280
|
+
- lib/falkorlib/puppet.rb
|
281
|
+
- lib/falkorlib/puppet/base.rb
|
282
|
+
- lib/falkorlib/puppet/modules.rb
|
283
|
+
- lib/falkorlib/puppet_tasks.rb
|
252
284
|
- lib/falkorlib/tasks.rb
|
253
285
|
- lib/falkorlib/tasks/gem.rake
|
254
286
|
- lib/falkorlib/tasks/gem.rb
|
255
287
|
- lib/falkorlib/tasks/git.rake
|
256
288
|
- lib/falkorlib/tasks/git.rb
|
257
289
|
- lib/falkorlib/tasks/gitflow.rake
|
290
|
+
- lib/falkorlib/tasks/puppet.rb
|
291
|
+
- lib/falkorlib/tasks/puppet_modules.rake
|
258
292
|
- lib/falkorlib/tasks/rspec.rake
|
259
293
|
- lib/falkorlib/tasks/yard.rake
|
260
294
|
- lib/falkorlib/version.rb
|
@@ -262,6 +296,7 @@ files:
|
|
262
296
|
- spec/falkorlib/common_spec.rb
|
263
297
|
- spec/falkorlib/git_spec.rb
|
264
298
|
- spec/falkorlib/gitflow_spec.rb
|
299
|
+
- spec/falkorlib/puppet_modules_spec.rb
|
265
300
|
- spec/falkorlib/versioning_gem_spec.rb
|
266
301
|
- spec/falkorlib/versioning_spec.rb
|
267
302
|
- spec/falkorlib_spec.rb
|
@@ -296,6 +331,7 @@ test_files:
|
|
296
331
|
- spec/falkorlib/common_spec.rb
|
297
332
|
- spec/falkorlib/git_spec.rb
|
298
333
|
- spec/falkorlib/gitflow_spec.rb
|
334
|
+
- spec/falkorlib/puppet_modules_spec.rb
|
299
335
|
- spec/falkorlib/versioning_gem_spec.rb
|
300
336
|
- spec/falkorlib/versioning_spec.rb
|
301
337
|
- spec/falkorlib_spec.rb
|