falkorlib 0.2.11 → 0.2.12
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 +1 -1
- data/lib/falkorlib/common.rb +105 -53
- data/lib/falkorlib/tasks/git.rake +5 -5
- data/lib/falkorlib/tasks/gitflow.rake +3 -3
- data/lib/falkorlib/tasks.rb +3 -3
- data/lib/falkorlib/version.rb +1 -1
- data/spec/falkorlib/gitflow_spec.rb +2 -2
- data/spec/falkorlib/versioning_gem_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b30dddfa9585e963002ffde18c2233028282f0c3
|
4
|
+
data.tar.gz: e19f0ce91512743338d9423c81093ddda90d702f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89bb6c7980ddd8fa72c8c561d2bd8ecf7ffbcc97f34a7bc9373ca5d8e4c23b406232d57fdec45c70e37c6ecd7dcc18dc6267e453abc2e284a76580d684f9b956
|
7
|
+
data.tar.gz: ea1babfa0cb0a798f888aaae50bb3d95df1cdf87bfa15c99cc3fcee2087cbecbf3aa4c3e79e62708fba2f31fe4247e4776982b0fa59821ba745215cc3e350976
|
data/Gemfile.lock
CHANGED
data/lib/falkorlib/common.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Sam 2014-07-12 21:43 svarrette>
|
4
4
|
################################################################################
|
5
5
|
|
6
6
|
require "falkorlib"
|
@@ -9,24 +9,24 @@ require 'open3'
|
|
9
9
|
|
10
10
|
module FalkorLib #:nodoc:
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
# @abstract
|
13
|
+
# Recipe for all my toolbox and versatile Ruby functions I'm using
|
14
|
+
# everywhere.
|
15
|
+
# You'll typically want to include the `FalkorLib::Common` module to bring
|
16
|
+
# the corresponding definitions into yoru scope.
|
17
|
+
#
|
18
|
+
# @example:
|
19
|
+
# require 'falkorlib'
|
20
|
+
# include FalkorLib::Common
|
21
|
+
#
|
22
|
+
# info 'exemple of information text'
|
23
|
+
# really_continue?
|
24
|
+
# run %{ echo 'this is an executed command' }
|
25
|
+
#
|
26
|
+
# Falkor.config.debug = true
|
27
|
+
# run %{ echo 'this is a simulated command that *will not* be executed' }
|
28
|
+
# error "that's an error text, let's exit with status code 1"
|
17
29
|
#
|
18
|
-
# @example:
|
19
|
-
# require 'falkorlib'
|
20
|
-
# include FalkorLib::Common
|
21
|
-
#
|
22
|
-
# info 'exemple of information text'
|
23
|
-
# really_continue?
|
24
|
-
# run %{ echo 'this is an executed command' }
|
25
|
-
#
|
26
|
-
# Falkor.config.debug = true
|
27
|
-
# run %{ echo 'this is a simulated command that *will not* be executed' }
|
28
|
-
# error "that's an error text, let's exit with status code 1"
|
29
|
-
#
|
30
30
|
module Common
|
31
31
|
module_function
|
32
32
|
##################################
|
@@ -108,64 +108,116 @@ module FalkorLib #:nodoc:
|
|
108
108
|
|
109
109
|
## Execute a given command, return exit code and print nicely stdout and stderr
|
110
110
|
def nice_execute(cmd)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
111
|
+
puts bold("[Running] #{cmd.gsub(/^\s*/, ' ')}")
|
112
|
+
stdout, stderr, exit_status = Open3.capture3( cmd )
|
113
|
+
unless stdout.empty?
|
114
|
+
stdout.each_line do |line|
|
115
|
+
print "** [out] #{line}"
|
116
|
+
$stdout.flush
|
117
|
+
end
|
118
|
+
end
|
119
|
+
unless stderr.empty?
|
120
|
+
stderr.each_line do |line|
|
121
|
+
$stderr.print red("** [err] #{line}")
|
122
|
+
$stderr.flush
|
123
|
+
end
|
124
|
+
end
|
125
|
+
exit_status
|
126
126
|
end
|
127
127
|
|
128
128
|
# Simpler version that use the system call
|
129
129
|
def execute(cmd)
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
puts bold("[Running] #{cmd.gsub(/^\s*/, ' ')}")
|
131
|
+
system(cmd)
|
132
|
+
$?
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
## Execute in a given directory
|
136
136
|
def execute_in_dir(path, cmd)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
137
|
+
exit_status = 0
|
138
|
+
Dir.chdir(path) do
|
139
|
+
exit_status = run %{ #{cmd} }
|
140
|
+
end
|
141
|
+
exit_status
|
142
142
|
end # execute_in_dir
|
143
143
|
|
144
|
-
|
145
|
-
|
146
144
|
## Execute a given command - exit if status != 0
|
147
145
|
def exec_or_exit(cmd)
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
status = execute(cmd)
|
147
|
+
if (status.to_i != 0)
|
148
|
+
error("The command '#{cmd}' failed with exit status #{status.to_i}")
|
151
149
|
end
|
152
|
-
|
150
|
+
status
|
153
151
|
end
|
154
152
|
|
155
153
|
## "Nice" way to present run commands
|
156
154
|
## Ex: run %{ hostname -f }
|
157
155
|
def run(cmds)
|
158
|
-
|
156
|
+
exit_status = 0
|
159
157
|
puts bold("[Running]\n#{cmds.gsub(/^\s*/, ' ')}")
|
160
|
-
|
158
|
+
$stdout.flush
|
161
159
|
#puts cmds.split(/\n */).inspect
|
162
160
|
cmds.split(/\n */).each do |cmd|
|
163
161
|
next if cmd.empty?
|
164
162
|
system("#{cmd}") unless FalkorLib.config.debug
|
165
|
-
|
163
|
+
exit_status = $?
|
166
164
|
end
|
167
|
-
|
168
|
-
end
|
165
|
+
exit_status
|
166
|
+
end
|
167
|
+
|
168
|
+
## List items from a glob pattern
|
169
|
+
## list_items
|
170
|
+
def list_items(glob_pattern, options = {})
|
171
|
+
list = { 0 => 'Exit' }
|
172
|
+
index = 1
|
173
|
+
raw_list = { }
|
174
|
+
|
175
|
+
Dir["#{glob_pattern}"].each do |elem|
|
176
|
+
#puts "=> element '#{elem}' - dir = #{File.directory?(elem)}; file = #{File.file?(elem)}"
|
177
|
+
next if (! options[:only_files].nil?) && options[:only_files] && File.directory?(elem)
|
178
|
+
next if (! options[:only_dirs].nil?) && options[:only_dirs] && File.file?(elem)
|
179
|
+
entry = File.basename(elem)
|
180
|
+
unless options[:pattern_include].nil?
|
181
|
+
select_entry = false
|
182
|
+
options[:pattern_include].each do |pattern|
|
183
|
+
#puts "considering pattern '#{pattern}' on entry '#{entry}'"
|
184
|
+
select_entry |= entry =~ /#{pattern}/
|
185
|
+
end
|
186
|
+
next unless select_entry
|
187
|
+
end
|
188
|
+
unless options[:pattern_exclude].nil?
|
189
|
+
select_entry = false
|
190
|
+
options[:pattern_exclude].each do |pattern|
|
191
|
+
#puts "considering pattern '#{pattern}' on entry '#{entry}'"
|
192
|
+
select_entry |= entry =~ /#{pattern}/
|
193
|
+
end
|
194
|
+
next if select_entry
|
195
|
+
end
|
196
|
+
#puts "selected entry = '#{entry}'"
|
197
|
+
list[index] = entry
|
198
|
+
raw_list[index] = elem
|
199
|
+
index += 1
|
200
|
+
end
|
201
|
+
text = options[:text].nil? ? "select the index" : options[:text]
|
202
|
+
default_idx = options[:default].nil? ? 0 : options[:default]
|
203
|
+
raise SystemExit.new('Empty list') if index == 1
|
204
|
+
# puts list.to_yaml
|
205
|
+
# answer = ask("=> #{text}", "#{default_idx}")
|
206
|
+
# raise SystemExit.new('exiting selection') if answer == '0'
|
207
|
+
# raise RangeError.new('Undefined index') if Integer(answer) >= list.length
|
208
|
+
# raw_list[Integer(answer)]
|
209
|
+
select_from(list, text, default_idx, raw_list)
|
210
|
+
end
|
211
|
+
|
212
|
+
## Display a indexed list to select an i
|
213
|
+
def select_from(list, text = 'Select the index', default_idx = 0, raw_list = list)
|
214
|
+
puts list.to_yaml
|
215
|
+
answer = ask("=> #{text}", "#{default_idx}")
|
216
|
+
raise SystemExit.new('exiting selection') if answer == '0'
|
217
|
+
raise RangeError.new('Undefined index') if Integer(answer) >= list.length
|
218
|
+
raw_list[Integer(answer)]
|
219
|
+
end # select_from
|
220
|
+
|
169
221
|
|
170
222
|
###############################
|
171
223
|
### YAML File loading/store ###
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
3
|
# git.rake - Special tasks for the management of Git operations
|
4
|
-
# Time-stamp: <
|
4
|
+
# Time-stamp: <Lun 2014-08-18 21:22 svarrette>
|
5
5
|
#
|
6
6
|
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
7
7
|
# http://varrette.gforge.uni.lu
|
@@ -21,7 +21,7 @@ namespace :git do
|
|
21
21
|
|
22
22
|
|
23
23
|
########### git:fetch ###########
|
24
|
-
desc "Fetch the latest changes on remotes"
|
24
|
+
#desc "Fetch the latest changes on remotes"
|
25
25
|
task :fetch do |t|
|
26
26
|
info t.comment
|
27
27
|
FalkorLib::Git.fetch()
|
@@ -34,9 +34,9 @@ namespace :git do
|
|
34
34
|
when 'push'; "Push your modifications onto the remote branches"
|
35
35
|
end
|
36
36
|
########### git:{up,push} ###########
|
37
|
-
desc "#{description}"
|
37
|
+
#desc "#{description}"
|
38
38
|
task op.to_sym do |t|
|
39
|
-
|
39
|
+
info description # t.comment
|
40
40
|
if remotes.empty? || ! remotes.include?( 'origin' )
|
41
41
|
warn "No git remote configured... Exiting #{t}"
|
42
42
|
next
|
@@ -79,7 +79,7 @@ namespace :git do
|
|
79
79
|
namespace :submodules do
|
80
80
|
|
81
81
|
########### git:submodules:update ###########
|
82
|
-
desc "Update the git submodules from '#{git_root_dir}'"
|
82
|
+
#desc "Update the git submodules from '#{git_root_dir}'"
|
83
83
|
task :update do |t|
|
84
84
|
info t.comment
|
85
85
|
FalkorLib::Git.submodule_update( git_root_dir )
|
@@ -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: <Lun 2014-08-18 21:18 svarrette>
|
4
4
|
#
|
5
5
|
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
6
6
|
# http://varrette.gforge.uni.lu
|
@@ -17,7 +17,7 @@ namespace :git do
|
|
17
17
|
git_root_dir = FalkorLib::Git.rootdir
|
18
18
|
|
19
19
|
########### git:init ###########
|
20
|
-
desc "Initialize Git repository"
|
20
|
+
#desc "Initialize Git repository"
|
21
21
|
task :init => [ 'git:flow:init' ]
|
22
22
|
|
23
23
|
#.....................
|
@@ -76,7 +76,7 @@ end # namespace git
|
|
76
76
|
namespace :version do
|
77
77
|
|
78
78
|
########### version:info ###########
|
79
|
-
desc "Get versioning information"
|
79
|
+
#desc "Get versioning information"
|
80
80
|
task :info do |t|
|
81
81
|
include FalkorLib::Versioning
|
82
82
|
version = get_version
|
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-18 21:19 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
|
-
desc "Print the current configuration of FalkorLib"
|
20
|
+
#desc "Print the current configuration of FalkorLib"
|
21
21
|
task :conf do
|
22
22
|
puts FalkorLib.config.to_yaml
|
23
23
|
end
|
@@ -28,7 +28,7 @@ end # namespace falkorlib
|
|
28
28
|
namespace :bundle do
|
29
29
|
|
30
30
|
########### init ###########
|
31
|
-
desc "Initialize your Bundler configuration from your Gemfile"
|
31
|
+
#desc "Initialize your Bundler configuration from your Gemfile"
|
32
32
|
task :init do |t|
|
33
33
|
info "#{t.comment}"
|
34
34
|
run %{ bundle }
|
data/lib/falkorlib/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# gitflow_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <Jeu 2014-
|
5
|
+
# Time-stamp: <Jeu 2014-07-03 23:58 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Git Flow operations -- see https://github.com/nvie/gitflow
|
8
8
|
#
|
@@ -16,7 +16,7 @@ require 'tmpdir'
|
|
16
16
|
describe FalkorLib::GitFlow do
|
17
17
|
include FalkorLib::Common
|
18
18
|
|
19
|
-
if command?('
|
19
|
+
if command?('git-flow')
|
20
20
|
|
21
21
|
|
22
22
|
dir = Dir.mktmpdir
|
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
#########################################
|
3
|
-
#
|
3
|
+
# versioning_gem_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <Mar 2014-07-01
|
5
|
+
# Time-stamp: <Mar 2014-07-01 17:29 svarrette>
|
6
6
|
#
|
7
|
-
# @description Check the
|
7
|
+
# @description Check the versioning operations on Gems
|
8
8
|
#
|
9
9
|
# Copyright (c) 2013 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
10
10
|
# . http://varrette.gforge.uni.lu
|
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.2.
|
4
|
+
version: 0.2.12
|
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-
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|