falkorlib 0.6.19 → 0.7.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/.gitignore +1 -0
- data/.rubocop.yml +88 -0
- data/.travis.yml +56 -4
- data/Gemfile +4 -4
- data/Gemfile.lock +55 -27
- data/Rakefile +12 -8
- data/Vagrantfile +68 -0
- data/completion/_falkor +55 -7
- data/falkorlib.gemspec +14 -12
- data/lib/falkorlib.rb +22 -21
- data/lib/falkorlib/bootstrap.rb +5 -1
- data/lib/falkorlib/bootstrap/base.rb +385 -693
- data/lib/falkorlib/bootstrap/git.rb +137 -0
- data/lib/falkorlib/bootstrap/latex.rb +186 -0
- data/lib/falkorlib/bootstrap/link.rb +108 -96
- data/lib/falkorlib/bootstrap/ruby.rb +102 -0
- data/lib/falkorlib/cli.rb +82 -26
- data/lib/falkorlib/cli/config.rb +8 -8
- data/lib/falkorlib/cli/link.rb +8 -9
- data/lib/falkorlib/cli/new.rb +25 -39
- data/lib/falkorlib/common.rb +425 -425
- data/lib/falkorlib/config.rb +114 -110
- data/lib/falkorlib/error.rb +27 -16
- data/lib/falkorlib/gem_tasks.rb +12 -11
- data/lib/falkorlib/git.rb +3 -4
- data/lib/falkorlib/git/base.rb +439 -396
- data/lib/falkorlib/git/flow.rb +163 -165
- data/lib/falkorlib/git_tasks.rb +31 -31
- data/lib/falkorlib/loader.rb +1 -1
- data/lib/falkorlib/puppet.rb +3 -5
- data/lib/falkorlib/puppet/base.rb +10 -15
- data/lib/falkorlib/puppet/modules.rb +367 -365
- data/lib/falkorlib/puppet_tasks.rb +11 -8
- data/lib/falkorlib/tasks.rb +51 -54
- data/lib/falkorlib/tasks/gem.rake +42 -43
- data/lib/falkorlib/tasks/gem.rb +12 -11
- data/lib/falkorlib/tasks/git.rake +101 -107
- data/lib/falkorlib/tasks/git.rb +31 -31
- data/lib/falkorlib/tasks/gitflow.rake +131 -141
- data/lib/falkorlib/tasks/puppet.rb +11 -8
- data/lib/falkorlib/tasks/puppet_modules.rake +143 -154
- data/lib/falkorlib/tasks/rspec.rake +94 -59
- data/lib/falkorlib/tasks/yard.rake +35 -39
- data/lib/falkorlib/version.rb +55 -55
- data/lib/falkorlib/versioning.rb +169 -167
- data/spec/falkorlib/bootstrap_helpers_spec.rb +106 -56
- data/spec/falkorlib/bootstrap_latex_spec.rb +145 -0
- data/spec/falkorlib/bootstrap_link_spec.rb +137 -0
- data/spec/falkorlib/bootstrap_ruby_spec.rb +118 -0
- data/spec/falkorlib/bootstrap_spec.rb +112 -129
- data/spec/falkorlib/git_spec.rb +94 -22
- data/spec/falkorlib/gitflow_spec.rb +54 -42
- data/spec/falkorlib/puppet_modules_spec.rb +35 -26
- data/spec/falkorlib/versioning_puppet_module_spec.rb +94 -90
- data/spec/falkorlib_spec.rb +5 -0
- data/spec/spec_helper.rb +88 -47
- data/templates/latex/article-ieee/main.tex.erb +509 -0
- data/templates/latex/article/_abstract.tex.erb +19 -0
- data/templates/latex/article/_acronyms.tex.erb +116 -0
- data/templates/latex/article/_conclusion.tex.erb +25 -0
- data/templates/latex/article/_context.tex.erb +17 -0
- data/templates/latex/article/_experiments.tex.erb +27 -0
- data/templates/latex/article/_implem.tex.erb +17 -0
- data/templates/latex/article/_introduction.tex.erb +39 -0
- data/templates/latex/article/_related_works.tex.erb +19 -0
- data/templates/latex/article/biblio.bib.erb +28 -0
- data/templates/latex/article/template.tex.erb +16 -0
- data/templates/latex/ieee/IEEEtran.bst +2409 -0
- data/templates/latex/ieee/IEEEtran.cls +6347 -0
- data/templates/motd/motd.erb +2 -1
- metadata +82 -2
data/completion/_falkor
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#compdef falkor
|
2
2
|
########################################################################################
|
3
3
|
# -*- mode:sh; -*-
|
4
|
-
# Time-stamp: <
|
4
|
+
# Time-stamp: <Mon 2016-11-14 15:24 svarrette>
|
5
5
|
#
|
6
6
|
# ZSH completion for [FalkorLib](https://github.com/Falkor/falkorlib)
|
7
7
|
#
|
@@ -17,7 +17,12 @@
|
|
17
17
|
########################################################################################
|
18
18
|
# You can inspired from the (unfortunately buggy) automatic generation of the ZSH
|
19
19
|
# completion file (see https://github.com/labocho/thor-zsh_completion) using:
|
20
|
+
#
|
20
21
|
# bundle exec falkor zsh-completion > completion/_falkor.autogen
|
22
|
+
#
|
23
|
+
# Test modification in live in your shell:
|
24
|
+
#
|
25
|
+
# unfunction _falkor && autoload -U _falkor
|
21
26
|
|
22
27
|
typeset -A opt_args
|
23
28
|
|
@@ -35,7 +40,9 @@ _falkor()
|
|
35
40
|
_falkor_cmds=(
|
36
41
|
'config:Print the current configuration of FalkorLib'
|
37
42
|
'help:Describe available commands or one specific command'
|
38
|
-
'
|
43
|
+
'init:Bootstrap a Git Repository the falkor way'
|
44
|
+
'link:Initialize a special symlink (.root, .makefile.d etc.)'
|
45
|
+
'motd:bootstrap a Message of the Day (motd) file'
|
39
46
|
'new:Initialize the directory PATH with one of Falkors template(s)'
|
40
47
|
'version:Prints the FalkorLib version information'
|
41
48
|
)
|
@@ -63,10 +70,14 @@ _falkor()
|
|
63
70
|
;;
|
64
71
|
(config)
|
65
72
|
__falkor_config && ret=0 ;;
|
66
|
-
(
|
67
|
-
|
73
|
+
(init)
|
74
|
+
__falkor_init && ret=0 ;;
|
68
75
|
(link)
|
69
76
|
__falkor_link && ret=0 ;;
|
77
|
+
(motd)
|
78
|
+
__falkor_motd && ret=0 ;;
|
79
|
+
(new)
|
80
|
+
__falkor_new && ret=0 ;;
|
70
81
|
(version|*)
|
71
82
|
_nothing
|
72
83
|
;;
|
@@ -112,8 +123,8 @@ __falkor_new()
|
|
112
123
|
(letter)
|
113
124
|
_arguments -C \
|
114
125
|
'(-n --name)'{-n,--name}'[Name of the LaTeX project]' \
|
115
|
-
'(-d --dir)'{-d,--dir
|
116
|
-
|
126
|
+
'(-d --dir)'{-d,--dir}':Project directory (relative to the git root directory):_directories' && ret=0
|
127
|
+
;;
|
117
128
|
(repo)
|
118
129
|
_arguments -C \
|
119
130
|
'(--no-git-flow)--git-flow[Bootstrap the repository with Git-flow]' \
|
@@ -130,7 +141,7 @@ __falkor_new()
|
|
130
141
|
case "$state" in
|
131
142
|
(path)
|
132
143
|
_directories ;;
|
133
|
-
|
144
|
+
esac
|
134
145
|
;;
|
135
146
|
esac
|
136
147
|
;;
|
@@ -200,4 +211,41 @@ __falkor_config() {
|
|
200
211
|
}
|
201
212
|
|
202
213
|
|
214
|
+
##################
|
215
|
+
__falkor_init() {
|
216
|
+
local curcontext=$curcontext state line ret=1
|
217
|
+
declare -A opt_args
|
218
|
+
|
219
|
+
_arguments -C \
|
220
|
+
{--git-flow,--no-git-flow}'[Bootstrap the repository with (or without) Git-flow]' \
|
221
|
+
{-i,--interactive}'[Interactive mode, in particular to confirm Gitflow branch names]' \
|
222
|
+
{-r,--remote-sync}'[Operate a git remote synchronization with remote. By default, all commits stay local]' \
|
223
|
+
'--master[Master Branch name for production releases]' \
|
224
|
+
{-b,--branch,--devel,--develop}'[Branch name for development commits]' \
|
225
|
+
'--make[Use a Makefile to pilot the repository actions (default)]' \
|
226
|
+
'--rake[Use a Rakefile (and FalkorLib) to pilot the repository actions]' \
|
227
|
+
'*:directory:_directories'
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
##################
|
232
|
+
__falkor_motd() {
|
233
|
+
local curcontext=$curcontext state line ret=1
|
234
|
+
declare -A opt_args
|
235
|
+
|
236
|
+
_arguments -C \
|
237
|
+
{--file,-f}'[File storing the message of the day]:filename:_files' \
|
238
|
+
{--width,-w}'[Width for the text]:[0-9]#' \
|
239
|
+
{--title,-t}'[Title to be placed in the motd (using asciify or figlet)]:title' \
|
240
|
+
'--subtitle[Eventual subtitle to place below the title]:subtitle' \
|
241
|
+
'--hostname[Hostname]:hostname' \
|
242
|
+
{--support,-s}"[Support/Contact mail]:email:($(git config user.email) hpc-sysadmins@uni.lu)" \
|
243
|
+
{--desc,-d}'[Short Description of the host]:desc' \
|
244
|
+
{--nodemodel,-n}'[Node Model]:model' \
|
245
|
+
'*:directory:_files -/'
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
203
251
|
_falkor "$@"
|
data/falkorlib.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
3
3
|
require "falkorlib/version"
|
4
|
-
|
4
|
+
#$version = FalkorLib::Version.to_s
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "falkorlib"
|
8
|
-
s.version =
|
8
|
+
s.version = FalkorLib::Version.to_s #$version
|
9
9
|
s.date = Time.now.strftime('%Y-%m-%d')
|
10
10
|
s.summary = "Sebastien Varrette aka Falkor's Common library to share Ruby code and {rake,cap} tasks"
|
11
11
|
s.description = "This is my personal library I use to share the Ruby tidbits and Rake tasks I made it for my various projects, and also to bootstrap easily several element of my daily workflow (new git repository, new beamer slides etc.).\nThis is also my first gem so any comments on the code/organization are welcome, I'm a newbie in this domain. \nNote that I used [Noe](https://github.com/blambeau/noe) to bootstrap this project and get a fully documented environment."
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
|
39
39
|
|
40
40
|
# Alternative:
|
41
|
-
s.files
|
41
|
+
s.files = `git ls-files`.split("\n")
|
42
42
|
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
43
43
|
#s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
44
44
|
|
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
#
|
47
47
|
#s.bindir = "bin"
|
48
48
|
|
49
|
-
s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
|
49
|
+
s.executables = (Dir["bin/*"]).collect { |f| File.basename(f) }
|
50
50
|
|
51
51
|
################################################################### REQUIREMENTS & INSTALL
|
52
52
|
# Remember the gem version requirements operators and schemes:
|
@@ -83,9 +83,12 @@ Gem::Specification.new do |s|
|
|
83
83
|
s.add_runtime_dependency("thor", '>= 0.19')
|
84
84
|
s.add_runtime_dependency("artii", '>= 2.1')
|
85
85
|
s.add_runtime_dependency("facter", '~> 2.4.1')
|
86
|
-
|
86
|
+
s.add_runtime_dependency("thor-zsh_completion", '>= 0')
|
87
|
+
s.add_runtime_dependency("activesupport", '~> 4.0')
|
88
|
+
#s.add_runtime_dependency("benchmark", '~> 4.0')
|
87
89
|
#s.add_runtime_dependency("mercenary", '>= 0.3.5')
|
88
90
|
|
91
|
+
|
89
92
|
#
|
90
93
|
#
|
91
94
|
# One call to add_dependency('gem_name', 'gem version requirement') for each
|
@@ -94,15 +97,15 @@ Gem::Specification.new do |s|
|
|
94
97
|
# for each development dependency. These gems are required for developers
|
95
98
|
#
|
96
99
|
#s.add_development_dependency("rake", ">= 10.1.0") #"~> 0.9.2")
|
97
|
-
s.add_development_dependency("bundler",
|
98
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
100
|
+
s.add_development_dependency("bundler", "~> 1.0")
|
101
|
+
s.add_development_dependency 'rspec', '~> 3.0' #, '>= 2.7.0'
|
99
102
|
s.add_development_dependency("pry", "~> 0.9")
|
100
103
|
s.add_development_dependency("yard", "~> 0.8")
|
101
|
-
|
102
|
-
s.add_development_dependency("rubygems-tasks",
|
104
|
+
s.add_development_dependency('rubocop', '~> 0.45.0')
|
105
|
+
s.add_development_dependency("rubygems-tasks", "~> 0.2")
|
103
106
|
s.add_development_dependency("travis", "~> 1.6")
|
104
107
|
s.add_development_dependency("travis-lint", "~> 1.8")
|
105
|
-
|
108
|
+
s.add_development_dependency('simplecov', '~> 0.12.0')
|
106
109
|
s.add_development_dependency("codeclimate-test-reporter", '~> 0') #, group: :test, require: nil)
|
107
110
|
#s.add_development_dependency("bluecloth", "~> 2.2.0")
|
108
111
|
#s.add_development_dependency("wlang", "~> 0.10.2")
|
@@ -130,7 +133,7 @@ Gem::Specification.new do |s|
|
|
130
133
|
s.extensions = []
|
131
134
|
|
132
135
|
# External (to RubyGems) requirements that must be met for this gem to work.
|
133
|
-
# It
|
136
|
+
# It's simply information for the user.
|
134
137
|
#
|
135
138
|
s.requirements = nil
|
136
139
|
|
@@ -163,5 +166,4 @@ Gem::Specification.new do |s|
|
|
163
166
|
# Extra files to add to RDoc such as README
|
164
167
|
#
|
165
168
|
s.extra_rdoc_files = Dir["README.md"] + Dir["CHANGELOG.md"] + Dir["LICENCE.md"]
|
166
|
-
|
167
169
|
end
|
data/lib/falkorlib.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Mon 2016-11-07 22:06 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# _____ _ _ _ _ _
|
6
6
|
# | ___|_ _| | | _____ _ __| | (_) |__
|
@@ -15,15 +15,17 @@
|
|
15
15
|
# * [Official Gem](https://rubygems.org/gems/falkorlib)
|
16
16
|
################################################################################
|
17
17
|
|
18
|
-
require
|
18
|
+
require 'awesome_print'
|
19
|
+
# require 'active_support' # provides so many nice extensions
|
20
|
+
require 'active_support/core_ext/hash'
|
19
21
|
|
20
22
|
begin
|
21
|
-
|
22
|
-
|
23
|
-
rescue
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
require 'term/ansicolor'
|
24
|
+
COLOR = true
|
25
|
+
rescue LoadError
|
26
|
+
puts "/!\\ cannot find the 'term/ansicolor' library"
|
27
|
+
puts " Consider installing it by 'gem install term-ansicolor'"
|
28
|
+
COLOR = false
|
27
29
|
end
|
28
30
|
|
29
31
|
require 'yaml'
|
@@ -32,21 +34,20 @@ require 'yaml'
|
|
32
34
|
# and `{rake,cap}` tasks
|
33
35
|
module FalkorLib
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
# Return the root directory of the gem
|
38
|
+
def self.root
|
39
|
+
File.expand_path '../..', __FILE__
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
def self.lib
|
43
|
+
File.join root, 'lib'
|
44
|
+
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
def self.templates
|
47
|
+
File.join root, 'templates'
|
48
|
+
end
|
47
49
|
|
48
50
|
end # module FalkorLib
|
49
51
|
|
50
|
-
|
51
|
-
require
|
52
|
-
require "falkorlib/loader"
|
52
|
+
require 'falkorlib/version'
|
53
|
+
require 'falkorlib/loader'
|
data/lib/falkorlib/bootstrap.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Tue 2016-11-01 10:05 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Management of Bootstrapping operations
|
6
6
|
|
@@ -12,4 +12,8 @@ end # module FalkorLib
|
|
12
12
|
|
13
13
|
require "falkorlib/bootstrap/base"
|
14
14
|
require "falkorlib/bootstrap/link"
|
15
|
+
require "falkorlib/bootstrap/ruby"
|
16
|
+
require "falkorlib/bootstrap/git"
|
17
|
+
require "falkorlib/bootstrap/latex"
|
18
|
+
|
15
19
|
#require "falkorlib/bootstrap/repo"
|
@@ -1,718 +1,410 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <Sat 2016-
|
3
|
+
# Time-stamp: <Sat 2016-11-12 09:21 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Interface for the main Bootstrapping operations
|
6
6
|
#
|
7
7
|
|
8
8
|
require "falkorlib"
|
9
9
|
require "falkorlib/common"
|
10
|
-
require
|
10
|
+
require "falkorlib/bootstrap"
|
11
|
+
|
12
|
+
require 'erb' # required for module generation
|
11
13
|
require 'artii'
|
12
14
|
require 'facter'
|
13
15
|
|
14
16
|
include FalkorLib::Common
|
15
17
|
|
16
|
-
module FalkorLib
|
17
|
-
|
18
|
+
module FalkorLib #:nodoc:
|
19
|
+
module Config
|
20
|
+
# Default configuration for Bootstrapping processes
|
21
|
+
module Bootstrap
|
22
|
+
|
23
|
+
DEFAULTS =
|
24
|
+
{
|
25
|
+
:motd => {
|
26
|
+
:file => 'motd',
|
27
|
+
:hostname => `hostname -f`.chomp,
|
28
|
+
:title => "Title",
|
29
|
+
:desc => "Brief server description",
|
30
|
+
:support => `git config user.email`.chomp,
|
31
|
+
:width => 80
|
32
|
+
},
|
33
|
+
:latex => {
|
34
|
+
:name => '',
|
35
|
+
:author => `git config user.name`.chomp,
|
36
|
+
:mail => `git config user.email`.chomp,
|
37
|
+
:title => 'Title',
|
38
|
+
:subtitle => 'Overview and Open Challenges',
|
39
|
+
:image => 'images/logo_ULHPC.pdf',
|
40
|
+
:logo => 'images/logo_UL.pdf',
|
41
|
+
:url => 'http://csc.uni.lu/sebastien.varrette'
|
42
|
+
},
|
43
|
+
:letter => {
|
44
|
+
:author_title => 'PhD',
|
45
|
+
:institute => 'University of Luxembourg',
|
46
|
+
:department => 'Parallel Computing and Optimization Group',
|
47
|
+
:department_acro => 'PCOG',
|
48
|
+
:address => '7, rue Richard Coudenhove-Kalergie',
|
49
|
+
:zipcode => 'L-1359',
|
50
|
+
:location => 'Luxembourg',
|
51
|
+
:phone => '(+352) 46 66 44 6600',
|
52
|
+
:twitter => 'svarrette',
|
53
|
+
:linkedin => 'svarrette',
|
54
|
+
:skype => 'sebastien.varrette',
|
55
|
+
:scholar => '6PTStIcAAAAJ'
|
56
|
+
},
|
57
|
+
:metadata => {
|
58
|
+
:name => '',
|
59
|
+
:type => [],
|
60
|
+
:by => (ENV['USER']).to_s,
|
61
|
+
:author => `git config user.name`.chomp,
|
62
|
+
:mail => `git config user.email`.chomp,
|
63
|
+
:summary => "rtfm",
|
64
|
+
:description => '',
|
65
|
+
:forge => '',
|
66
|
+
:source => '',
|
67
|
+
:project_page => '',
|
68
|
+
:origin => '',
|
69
|
+
:license => '',
|
70
|
+
:issues_url => '',
|
71
|
+
:tags => []
|
72
|
+
},
|
73
|
+
:trashdir => '.Trash',
|
74
|
+
:types => [ :none, :latex, :gem, :octopress, :puppet_module, :rvm, :pyenv ],
|
75
|
+
:licenses => {
|
76
|
+
"none" => {},
|
77
|
+
"Apache-2.0" => {
|
78
|
+
:url => "http://www.apache.org/licenses/LICENSE-2.0",
|
79
|
+
:logo => "https://www.apache.org/images/feather-small.gif"
|
80
|
+
},
|
81
|
+
"BSD" => {
|
82
|
+
:url => "http://www.linfo.org/bsdlicense.html",
|
83
|
+
:logo => "http://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/License_icon-bsd.svg/200px-License_icon-bsd.svg.png"
|
84
|
+
},
|
85
|
+
"CC by-nc-sa" => {
|
86
|
+
:name => "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International",
|
87
|
+
:url => "http://creativecommons.org/licenses/by-nc-sa/4.0",
|
88
|
+
:logo => "https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png"
|
89
|
+
},
|
90
|
+
"GPL-2.0" => {
|
91
|
+
:url => "http://www.gnu.org/licenses/gpl-2.0.html",
|
92
|
+
:logo => "https://licensebuttons.net/l/GPL/2.0/88x62.png"
|
93
|
+
},
|
94
|
+
"GPL-3.0" => {
|
95
|
+
:url => "http://www.gnu.org/licenses/gpl-3.0.html",
|
96
|
+
:logo => "https://www.gnu.org/graphics/gplv3-88x31.png"
|
97
|
+
},
|
98
|
+
"LGPL-2.1" => {
|
99
|
+
:url => "https://www.gnu.org/licenses/lgpl-2.1.html",
|
100
|
+
:logo => "https://licensebuttons.net/l/LGPL/2.1/88x62.png"
|
101
|
+
},
|
102
|
+
"LGPL-3.0" => {
|
103
|
+
:url => "https://www.gnu.org/licenses/lgpl.html",
|
104
|
+
:logo => "https://www.gnu.org/graphics/lgplv3-88x31.png"
|
105
|
+
},
|
106
|
+
"MIT" => {
|
107
|
+
:url => "http://opensource.org/licenses/MIT",
|
108
|
+
:logo => "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/License_icon-mit-2.svg/200px-License_icon-mit-2.svg.png"
|
109
|
+
}
|
110
|
+
},
|
111
|
+
:puppet => {},
|
112
|
+
:forge => {
|
113
|
+
:none => { :url => '', :name => "None" },
|
114
|
+
:gforge => { :url => 'gforge.uni.lu', :name => 'GForge @ Uni.lu' },
|
115
|
+
:github => { :url => 'github.com', :name => 'Github', :login => (`whoami`.chomp.capitalize).to_s },
|
116
|
+
:gitlab => { :url => 'gitlab.uni.lu', :name => 'Gitlab @ Uni.lu', :login => (`whoami`.chomp.capitalize).to_s }
|
117
|
+
}
|
118
|
+
}
|
18
119
|
|
19
|
-
# Default configuration for Bootstrapping processes
|
20
|
-
module Bootstrap
|
21
|
-
DEFAULTS =
|
22
|
-
{
|
23
|
-
:motd => {
|
24
|
-
:title => "Title",
|
25
|
-
:support => "#{ENV['GIT_AUTHOR_EMAIL']}",
|
26
|
-
:width => 80,
|
27
|
-
:hostname => "`hostname -f`",
|
28
|
-
},
|
29
|
-
:latex => {
|
30
|
-
:name => '',
|
31
|
-
:author => %x( git config user.name ).chomp,
|
32
|
-
:mail => %x( git config user.email ).chomp,
|
33
|
-
:title => 'Title',
|
34
|
-
:subtitle => 'Overview and Open Challenges',
|
35
|
-
:image => 'images/logo_ULHPC.pdf',
|
36
|
-
:logo => 'images/logo_UL.pdf',
|
37
|
-
:url => 'http://csc.uni.lu/sebastien.varrette'
|
38
|
-
},
|
39
|
-
:letter => {
|
40
|
-
:author_title => 'PhD',
|
41
|
-
:institute => 'University of Luxembourg',
|
42
|
-
:department => 'Parallel Computing and Optimization Group',
|
43
|
-
:department_acro => 'PCOG',
|
44
|
-
:address => '7, rue Richard Coudenhove-Kalergie',
|
45
|
-
:zipcode => 'L-1359',
|
46
|
-
:location => 'Luxembourg',
|
47
|
-
:phone => '(+352) 46 66 44 6600',
|
48
|
-
:twitter => 'svarrette',
|
49
|
-
:linkedin => 'svarrette',
|
50
|
-
:skype => 'sebastien.varrette',
|
51
|
-
:scholar => '6PTStIcAAAAJ'
|
52
|
-
},
|
53
|
-
:metadata => {
|
54
|
-
:name => '',
|
55
|
-
:type => [],
|
56
|
-
:by => "#{ENV['USER']}",
|
57
|
-
:author => "#{ENV['GIT_AUTHOR_NAME']}",
|
58
|
-
:mail => "#{ENV['GIT_AUTHOR_EMAIL']}",
|
59
|
-
:summary => "rtfm",
|
60
|
-
:description => '',
|
61
|
-
:forge => '',
|
62
|
-
:source => '',
|
63
|
-
:project_page => '',
|
64
|
-
:origin => '',
|
65
|
-
:license => '',
|
66
|
-
:issues_url => '',
|
67
|
-
:tags => []
|
68
|
-
},
|
69
|
-
:trashdir => '.Trash',
|
70
|
-
:types => [ :none, :latex, :gem, :octopress, :puppet_module, :rvm, :pyenv ],
|
71
|
-
:licenses => {
|
72
|
-
"none" => {},
|
73
|
-
"Apache-2.0" => {
|
74
|
-
:url => "http://www.apache.org/licenses/LICENSE-2.0",
|
75
|
-
:logo => "https://www.apache.org/images/feather-small.gif"
|
76
|
-
},
|
77
|
-
"BSD" => {
|
78
|
-
:url => "http://www.linfo.org/bsdlicense.html",
|
79
|
-
:logo => "http://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/License_icon-bsd.svg/200px-License_icon-bsd.svg.png"
|
80
|
-
},
|
81
|
-
"CC by-nc-sa" => {
|
82
|
-
:name => "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International",
|
83
|
-
:url => "http://creativecommons.org/licenses/by-nc-sa/4.0",
|
84
|
-
:logo => "https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png"
|
85
|
-
},
|
86
|
-
"GPL-2.0" => {
|
87
|
-
:url => "http://www.gnu.org/licenses/gpl-2.0.html",
|
88
|
-
:logo => "https://licensebuttons.net/l/GPL/2.0/88x62.png"
|
89
|
-
},
|
90
|
-
"GPL-3.0" => {
|
91
|
-
:url => "http://www.gnu.org/licenses/gpl-3.0.html",
|
92
|
-
:logo => "https://www.gnu.org/graphics/gplv3-88x31.png",
|
93
|
-
},
|
94
|
-
"LGPL-2.1" => {
|
95
|
-
:url => "https://www.gnu.org/licenses/lgpl-2.1.html",
|
96
|
-
:logo => "https://licensebuttons.net/l/LGPL/2.1/88x62.png",
|
97
|
-
},
|
98
|
-
"LGPL-3.0" => {
|
99
|
-
:url => "https://www.gnu.org/licenses/lgpl.html",
|
100
|
-
:logo => "https://www.gnu.org/graphics/lgplv3-88x31.png",
|
101
|
-
},
|
102
|
-
"MIT" => {
|
103
|
-
:url => "http://opensource.org/licenses/MIT",
|
104
|
-
:logo => "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/License_icon-mit-2.svg/200px-License_icon-mit-2.svg.png"
|
105
|
-
},
|
106
|
-
},
|
107
|
-
:puppet => {},
|
108
|
-
:forge => {
|
109
|
-
:none => { :url => '', :name => "None"},
|
110
|
-
:gforge => { :url => 'gforge.uni.lu', :name => 'GForge @ Uni.lu' },
|
111
|
-
:github => { :url => 'github.com', :name => 'Github', :login => "#{`whoami`.chomp.capitalize}" },
|
112
|
-
:gitlab => { :url => 'gitlab.uni.lu', :name => 'Gitlab @ Uni.lu', :login => "#{`whoami`.chomp.capitalize}" },
|
113
|
-
},
|
114
|
-
}
|
115
|
-
end
|
116
120
|
end
|
121
|
+
end
|
117
122
|
end
|
118
123
|
|
119
124
|
|
120
125
|
|
121
126
|
module FalkorLib
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
127
|
+
module Bootstrap #:nodoc:
|
128
|
+
|
129
|
+
module_function
|
130
|
+
|
131
|
+
###
|
132
|
+
# Initialize a trash directory in path
|
133
|
+
##
|
134
|
+
def trash(path = Dir.pwd, dirname = FalkorLib.config[:templates][:trashdir], _options = {})
|
135
|
+
#args = method(__method__).parameters.map { |arg| arg[1].to_s }.map { |arg| { arg.to_sym => eval(arg) } }.reduce Hash.new, :merge
|
136
|
+
#ap args
|
137
|
+
exit_status = 0
|
138
|
+
trashdir = File.join(File.realpath(path), dirname)
|
139
|
+
if Dir.exist?(trashdir)
|
140
|
+
warning "The trash directory '#{dirname}' already exists"
|
141
|
+
return 1
|
142
|
+
end
|
143
|
+
Dir.chdir(path) do
|
144
|
+
info "creating the trash directory '#{dirname}'"
|
145
|
+
exit_status = run %(
|
140
146
|
mkdir -p #{dirname}
|
141
147
|
echo '*' > #{dirname}/.gitignore
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
erbfiles = [ 'header_rakefile.erb' ]
|
307
|
-
erbfiles << 'rakefile_gitflow.erb' if FalkorLib::GitFlow.init?(path)
|
308
|
-
erbfiles << 'footer_rakefile.erb'
|
309
|
-
write_from_erb_template(erbfiles, rakefile, {}, { :srcdir => "#{templatedir}" })
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
# === VERSION file ===
|
314
|
-
FalkorLib::Bootstrap.versionfile(path, :tag => 'v0.0.0')
|
315
|
-
|
316
|
-
# === RVM ====
|
317
|
-
FalkorLib::Bootstrap.rvm(path, options) if options[:rvm]
|
318
|
-
|
319
|
-
# === README ===
|
320
|
-
FalkorLib::Bootstrap.readme(path, options)
|
321
|
-
|
322
|
-
#===== remote synchro ========
|
323
|
-
if options[:remote_sync]
|
324
|
-
remotes = FalkorLib::Git.remotes(path)
|
325
|
-
if remotes.include?( 'origin' )
|
326
|
-
info "perform remote synchronization"
|
327
|
-
[ :master, :develop ].each do |t|
|
328
|
-
FalkorLib::Git.publish(gitflow_branches[t.to_sym], path, 'origin')
|
329
|
-
end
|
330
|
-
else
|
331
|
-
warning "no Git remote 'origin' found, thus no remote synchronization performed"
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
end # repo
|
336
|
-
|
337
|
-
###### versionfile ######
|
338
|
-
# Bootstrap a VERSION file at the root of a project
|
339
|
-
# Supported options:
|
340
|
-
# * :file [string] filename
|
341
|
-
# * :version [string] version to mention in the file
|
342
|
-
##
|
343
|
-
def versionfile(dir = Dir.pwd, options = {})
|
344
|
-
file = options[:file] ? options[:file] : 'VERSION'
|
345
|
-
version = options[:version] ? options[:version] : '0.0.0'
|
346
|
-
info " ==> bootstrapping a VERSION file"
|
347
|
-
path = normalized_path(dir)
|
348
|
-
path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
|
349
|
-
unless Dir.exists?( path )
|
350
|
-
warning "The directory #{path} does not exists and will be created"
|
351
|
-
really_continue?
|
352
|
-
FileUtils.mkdir_p path
|
353
|
-
end
|
354
|
-
versionfile = File.join(path, file)
|
355
|
-
unless File.exists?( versionfile )
|
356
|
-
FalkorLib::Versioning.set_version(version, path, {
|
357
|
-
:type => 'file',
|
358
|
-
:source => { :filename => file }
|
359
|
-
})
|
360
|
-
Dir.chdir( path ) do
|
361
|
-
run %{ git tag #{options[:tag]} } if options[:tag]
|
362
|
-
end
|
363
|
-
else
|
364
|
-
puts " ... not overwriting the #{file} file which already exists"
|
365
|
-
end
|
366
|
-
|
367
|
-
# unless File.exists?( versionfile )
|
368
|
-
# run %{ echo "#{version}" > #{versionfile} }
|
369
|
-
# if FalkorLib::Git.init?(path)
|
370
|
-
# FalkorLib::Git.add(versionfile, "Initialize #{file} file")
|
371
|
-
# Dir.chdir( path ) do
|
372
|
-
# run %{ git tag #{options[:tag]} } if options[:tag]
|
373
|
-
# end
|
374
|
-
# end
|
375
|
-
# else
|
376
|
-
# puts " ... not overwriting the #{file} file which already exists"
|
377
|
-
# end
|
378
|
-
end # versionfile
|
379
|
-
|
380
|
-
|
381
|
-
###### motd ######
|
382
|
-
# Generate a new motd (Message of the Day) file
|
383
|
-
# Supported options:
|
384
|
-
# * :force [boolean] force action
|
385
|
-
##
|
386
|
-
def motd(dir = Dir.pwd, options = {})
|
387
|
-
config = FalkorLib::Config::Bootstrap::DEFAULTS[:motd].merge!(options)
|
388
|
-
path = normalized_path(dir)
|
389
|
-
erbfile = File.join( FalkorLib.templates, 'motd', 'motd.erb')
|
390
|
-
outfile = (options[:file] =~ /^\//) ? options[:file] : File.join(path, options[:file])
|
391
|
-
info "Generate a motd (Message of the Day) file '#{outfile}'"
|
392
|
-
config[:os] = Facter.value(:lsbdistdescription) if Facter.value(:lsbdistdescription)
|
393
|
-
config[:os] = "Mac " + Facter.value(:sp_os_version) if Facter.value(:sp_os_version)
|
394
|
-
write_from_erb_template(erbfile, outfile, config, options)
|
395
|
-
end # motd
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
###### readme ######
|
400
|
-
# Bootstrap a README file for various context
|
401
|
-
# Supported options:
|
402
|
-
# * :no_interaction [boolean]: do not interact
|
403
|
-
# * :force [boolean] force overwritting
|
404
|
-
# * :latex [boolean] describe a LaTeX project
|
405
|
-
# * :octopress [boolean] octopress site
|
406
|
-
##
|
407
|
-
def readme(dir = Dir.pwd, options = {})
|
408
|
-
info "Bootstrap a README file for this project"
|
409
|
-
# get the local configuration
|
410
|
-
local_config = FalkorLib::Config.get(dir)
|
411
|
-
config = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].clone
|
412
|
-
name = get_project_name(dir)
|
413
|
-
if local_config[:project]
|
414
|
-
config.deep_merge!( local_config[:project])
|
415
|
-
else
|
416
|
-
config[:name] = ask("\tProject name: ", name) unless options[:name]
|
417
|
-
end
|
418
|
-
if options[:rake]
|
419
|
-
options[:make] = false
|
420
|
-
options[:rvm] = true
|
421
|
-
end
|
422
|
-
config[:type] << :rvm if options[:rake]
|
423
|
-
# Type of project
|
424
|
-
config[:type] << :latex if options[:latex]
|
425
|
-
if config[:type].empty?
|
426
|
-
t = select_from( FalkorLib::Config::Bootstrap::DEFAULTS[:types],
|
427
|
-
'Select the type of project to describe:', 1)
|
428
|
-
config[:type] << t
|
429
|
-
config[:type] << [ :ruby, :rvm ] if [ :gem, :rvm, :octopress, :puppet_module ].include?( t )
|
430
|
-
config[:type] << :python if t == :pyenv
|
431
|
-
end
|
432
|
-
config[:type].uniq!
|
433
|
-
ap config
|
434
|
-
config[:type] = config[:type].uniq.flatten
|
435
|
-
# Apply options (if provided)
|
436
|
-
[ :name, :forge ].each do |k|
|
437
|
-
config[k.to_sym] = options[k.to_sym] if options[k.to_sym]
|
438
|
-
end
|
439
|
-
path = normalized_path(dir)
|
440
|
-
config[:filename] = options[:filename] ? options[:filename] : File.join(path, 'README.md')
|
441
|
-
if ( FalkorLib::Git.init?(dir) && FalkorLib::Git.remotes(dir).include?( 'origin' ))
|
442
|
-
config[:origin] = FalkorLib::Git.config('remote.origin.url')
|
443
|
-
if config[:origin] =~ /((gforge|gitlab|github)[\.\w_-]+)[:\d\/]+(\w*)/
|
444
|
-
config[:forge] = $2.to_sym
|
445
|
-
config[:by] = $3
|
446
|
-
end
|
447
|
-
else
|
448
|
-
config[:forge] = select_forge(config[:forge]).to_sym if config[:forge].empty?
|
449
|
-
end
|
450
|
-
forges = FalkorLib::Config::Bootstrap::DEFAULTS[:forge][ config[:forge].to_sym ]
|
451
|
-
#ap config
|
452
|
-
default_source = case config[:forge]
|
453
|
-
when :gforge
|
454
|
-
'https://' + forges[:url] + "/projects/" + name.downcase
|
455
|
-
when :github, :gitlab
|
456
|
-
'https://' + forges[:url] + "/" + config[:by] + "/" + name.downcase
|
457
|
-
else
|
458
|
-
""
|
459
|
-
end
|
460
|
-
FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].each do |k,v|
|
461
|
-
next if v.kind_of?(Array) or [ :license, :forge ].include?( k )
|
462
|
-
next if k == :name and ! config[:name].empty?
|
463
|
-
next if k == :issues_url and ! [ :github, :gitlab ].include?( config[:forge] )
|
464
|
-
#next unless [ :name, :summary, :description ].include?(k.to_sym)
|
465
|
-
default_answer = case k
|
466
|
-
when :author
|
467
|
-
(config[:by] == 'ULHPC') ? 'UL HPC Management Team' : config[:author]
|
468
|
-
when :mail
|
469
|
-
(config[:by] == 'ULHPC') ? 'hpc-sysadmins@uni.lu' : config[:mail]
|
470
|
-
when :description
|
471
|
-
config[:description].empty? ? "#{config[:summary]}" : "#{config[:description]}"
|
472
|
-
when :source
|
473
|
-
config[:source].empty? ? default_source : "#{config[:source]}"
|
474
|
-
when :project_page
|
475
|
-
config[:source].empty? ? v : config[:source]
|
476
|
-
when :issues_url
|
477
|
-
config[:project_page].empty? ? v : "#{config[:project_page]}/issues"
|
478
|
-
else
|
479
|
-
config[k.to_sym].empty? ? v : config[k.to_sym]
|
480
|
-
end
|
481
|
-
config[k.to_sym] = ask( "\t" + sprintf("Project %-20s", "#{k}"), default_answer)
|
482
|
-
end
|
483
|
-
tags = ask("\tKeywords (comma-separated list of tags)", config[:tags].join(','))
|
484
|
-
config[:tags] = tags.split(',')
|
485
|
-
config[:license] = select_licence() if config[:license].empty?
|
486
|
-
# stack the ERB files required to generate the README
|
487
|
-
templatedir = File.join( FalkorLib.templates, 'README')
|
488
|
-
erbfiles = [ 'header_readme.erb', ]
|
489
|
-
[ :latex ].each do |type|
|
490
|
-
erbfiles << "readme_#{type}.erb" if options[type.to_sym] and File.exist?( File.join(templatedir, "readme_#{type}.erb"))
|
491
|
-
end
|
492
|
-
erbfiles << "readme_issues.erb"
|
493
|
-
erbfiles << "readme_git.erb" if FalkorLib::Git.init?(dir)
|
494
|
-
erbfiles << "readme_gitflow.erb" if FalkorLib::GitFlow.init?(dir)
|
495
|
-
erbfiles << "readme_rvm.erb" if config[:type].include?(:rvm)
|
496
|
-
erbfiles << "footer_readme.erb"
|
497
|
-
|
498
|
-
content = ""
|
499
|
-
erbfiles.each do |f|
|
500
|
-
erbfile = File.join(templatedir, f)
|
501
|
-
content += ERB.new(File.read("#{erbfile}"), nil, '<>').result(binding)
|
502
|
-
end
|
503
|
-
show_diff_and_write(content, config[:filename], options)
|
504
|
-
|
505
|
-
# Eventually save/upgrade local config
|
506
|
-
info "=> saving customization of the FalkorLib configuration in #{FalkorLib.config[:config_files][:local]}"
|
507
|
-
really_continue?
|
508
|
-
FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].keys.each do |k|
|
509
|
-
local_config[:project] = {} unless local_config[:project]
|
510
|
-
local_config[:project][k.to_sym] = config[k.to_sym]
|
511
|
-
end
|
512
|
-
if FalkorLib::GitFlow.init?(dir)
|
513
|
-
local_config[:gitflow] = {} unless local_config[:gitflow]
|
514
|
-
local_config[:gitflow][:branches] = FalkorLib.config[:gitflow][:branches].clone unless local_config[:gitflow][:branches]
|
515
|
-
[ :master, :develop ].each do |b|
|
516
|
-
local_config[:gitflow][:branches][b.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
|
517
|
-
end
|
518
|
-
end
|
519
|
-
FalkorLib::Config.save(dir, local_config, :local)
|
520
|
-
#
|
521
|
-
end # readme
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
###### latex ######
|
526
|
-
# Bootstrap a LaTeX sub-project of type <type> within a given repository <dir>.
|
527
|
-
# Supported types:
|
528
|
-
# * :beamer LaTeX Beamer Slides
|
529
|
-
# * :article LaTeX article
|
530
|
-
# * :letter LaTeX Letter
|
531
|
-
# Supported options:
|
532
|
-
# * :force [boolean] force action
|
533
|
-
##
|
534
|
-
def latex(dir = Dir.pwd, type = :beamer, options = {})
|
535
|
-
ap options if options[:debug]
|
536
|
-
print_error_and_exit "Unsupported type" unless [ :beamer, :article, :letter ].include?( type )
|
537
|
-
path = normalized_path(dir)
|
538
|
-
config = FalkorLib::Config::Bootstrap::DEFAULTS[:latex].clone
|
539
|
-
if type == :letter
|
540
|
-
config.merge!(FalkorLib::Config::Bootstrap::DEFAULTS[:letter].clone)
|
541
|
-
[ :title, :subtitle, :image ].each { |k| config.delete k }
|
542
|
-
end
|
543
|
-
config.deep_merge!(FalkorLib::Config::Bootstrap::DEFAULTS[:letter].clone) if type == :letter
|
544
|
-
# initiate the repository if needed
|
545
|
-
unless File.directory?( path )
|
546
|
-
warn "The directory '#{path}' does not exists and will be created"
|
547
|
-
really_continue? unless options[:force]
|
548
|
-
run %{ mkdir -p #{path} }
|
549
|
-
end
|
550
|
-
repo(path, options) unless FalkorLib::Git.init?(path)
|
551
|
-
rootdir = FalkorLib::Git.rootdir(path)
|
552
|
-
info "Initiate a LaTeX #{type} project from the Git root directory: '#{rootdir}'"
|
553
|
-
really_continue? unless options[:force]
|
554
|
-
relative_path_to_root = (Pathname.new( FalkorLib::Git.rootdir(dir) ).relative_path_from Pathname.new( File.realpath(path))).to_s
|
555
|
-
config[:name] = options[:name] ? options[:name] : ask("\tEnter the name of the #{type} LaTeX project: ", File.basename(path))
|
556
|
-
raise FalkorLib::ExecError "Empty project name" if config[:name].empty?
|
557
|
-
default_project_dir = (Pathname.new( File.realpath(path) ).relative_path_from Pathname.new( FalkorLib::Git.rootdir(dir))).to_s
|
558
|
-
if relative_path_to_root == '.'
|
559
|
-
default_project_dir = case type
|
560
|
-
when :article
|
561
|
-
"articles/#{Time.now.year}/#{config[:name]}"
|
562
|
-
when :beamer
|
563
|
-
"slides/#{Time.now.year}/#{config[:name]}"
|
564
|
-
when :bookchapter
|
565
|
-
"chapters/#{config[:name]}"
|
566
|
-
when :letter
|
567
|
-
"letters/#{Time.now.year}/#{config[:name]}"
|
568
|
-
else
|
569
|
-
"#{config[:name]}"
|
570
|
-
end
|
571
|
-
else
|
572
|
-
default_project_dir += "/#{config[:name]}" unless default_project_dir =~ /#{config[:name]}$/
|
573
|
-
end
|
574
|
-
project_dir = options[:dir] ? options[:dir] : ask("\tLaTeX Sources directory (relative to the Git root directory)", "#{default_project_dir}")
|
575
|
-
raise FalkorLib::ExecError "Empty project directory" if project_dir.empty?
|
576
|
-
src_project_dir = File.join(project_dir, 'src')
|
577
|
-
srcdir = File.join(rootdir, src_project_dir)
|
578
|
-
if File.exists?(File.join(srcdir, '.root'))
|
579
|
-
warn "The directory '#{project_dir}' seems to have been already initialized"
|
580
|
-
really_continue? unless options[:force]
|
581
|
-
end
|
582
|
-
FalkorLib::GitFlow.start('feature', config[:name], rootdir) if FalkorLib::GitFlow.init?(rootdir)
|
583
|
-
# === prepare Git submodules ===
|
584
|
-
info " ==> prepare the relevant Git submodules"
|
585
|
-
submodules = {}
|
586
|
-
submodules['Makefiles'] = { :url => 'https://github.com/Falkor/Makefiles.git',
|
587
|
-
:branch => 'devel'
|
588
|
-
} if [ :article, :beamer, :bookchapter].include?(type)
|
589
|
-
submodules['beamerthemeFalkor'] = { :url => 'https://github.com/Falkor/beamerthemeFalkor' } if type == :beamer
|
590
|
-
FalkorLib::Git.submodule_init(rootdir, submodules)
|
591
|
-
info "bootstrapping the #{type} project sources in '#{src_project_dir}'"
|
592
|
-
# Create the project directory
|
593
|
-
Dir.chdir( rootdir ) do
|
594
|
-
run %{ mkdir -p #{src_project_dir}/images } unless File.directory?("#{srcdir}/images")
|
595
|
-
end
|
596
|
-
info "populating '#{src_project_dir}'"
|
597
|
-
#FalkorLib::Bootstrap::Link.root(srcdir, { :verbose => true} )
|
598
|
-
FalkorLib::Bootstrap::Link.makefile(srcdir, { :no_interaction => true })
|
599
|
-
[ '_style.sty', '.gitignore' ].each do |f|
|
600
|
-
Dir.chdir( srcdir ) do
|
601
|
-
dst = ".makefile.d/latex/#{f}"
|
602
|
-
run %{ ln -s #{dst} #{f} } unless File.exist?( File.join(srcdir, f) )
|
603
|
-
end
|
604
|
-
end
|
605
|
-
if type == :beamer
|
606
|
-
f = 'beamerthemeFalkor.sty'
|
607
|
-
dst = "#{FalkorLib.config[:git][:submodulesdir]}/beamerthemeFalkor/#{f}"
|
608
|
-
Dir.chdir( srcdir ) do
|
609
|
-
run %{ ln -s .root/#{dst} #{f} } unless File.exist?( File.join(srcdir, f) )
|
610
|
-
end
|
611
|
-
end
|
612
|
-
|
613
|
-
# Bootstrap the directory
|
614
|
-
templatedir = File.join( FalkorLib.templates, 'latex', "#{type}")
|
615
|
-
unless File.exists?( File.join(srcdir, "#{config[:name]}.tex"))
|
616
|
-
info "gathering information for the LaTeX templates"
|
617
|
-
prefix = case type
|
618
|
-
when :article
|
619
|
-
'Article '
|
620
|
-
when :beamer
|
621
|
-
'Slides '
|
622
|
-
when :bookchapter
|
623
|
-
'Book Chapter '
|
624
|
-
when :letter
|
625
|
-
'Letter '
|
148
|
+
)
|
149
|
+
if FalkorLib::Git.init?(path)
|
150
|
+
exit_status = FalkorLib::Git.add(File.join(trashdir.to_s, '.gitignore' ),
|
151
|
+
'Add Trash directory',
|
152
|
+
:force => true )
|
153
|
+
end
|
154
|
+
end
|
155
|
+
exit_status.to_i
|
156
|
+
end # trash
|
157
|
+
|
158
|
+
###### versionfile ######
|
159
|
+
# Bootstrap a VERSION file at the root of a project
|
160
|
+
# Supported options:
|
161
|
+
# * :file [string] filename
|
162
|
+
# * :version [string] version to mention in the file
|
163
|
+
##
|
164
|
+
def versionfile(dir = Dir.pwd, options = {})
|
165
|
+
file = (options[:file]) ? options[:file] : 'VERSION'
|
166
|
+
version = (options[:version]) ? options[:version] : '0.0.0'
|
167
|
+
info " ==> bootstrapping a VERSION file"
|
168
|
+
path = normalized_path(dir)
|
169
|
+
path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
|
170
|
+
unless Dir.exist?( path )
|
171
|
+
warning "The directory #{path} does not exists and will be created"
|
172
|
+
really_continue?
|
173
|
+
FileUtils.mkdir_p path
|
174
|
+
end
|
175
|
+
versionfile = File.join(path, file)
|
176
|
+
if File.exist?( versionfile )
|
177
|
+
puts " ... not overwriting the #{file} file which already exists"
|
178
|
+
else
|
179
|
+
FalkorLib::Versioning.set_version(version, path, :type => 'file',
|
180
|
+
:source => { :filename => file })
|
181
|
+
Dir.chdir( path ) do
|
182
|
+
run %( git tag #{options[:tag]} ) if options[:tag]
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# unless File.exists?( versionfile )
|
187
|
+
# run %{ echo "#{version}" > #{versionfile} }
|
188
|
+
# if FalkorLib::Git.init?(path)
|
189
|
+
# FalkorLib::Git.add(versionfile, "Initialize #{file} file")
|
190
|
+
# Dir.chdir( path ) do
|
191
|
+
# run %{ git tag #{options[:tag]} } if options[:tag]
|
192
|
+
# end
|
193
|
+
# end
|
194
|
+
# else
|
195
|
+
# puts " ... not overwriting the #{file} file which already exists"
|
196
|
+
# end
|
197
|
+
end # versionfile
|
198
|
+
|
199
|
+
|
200
|
+
###### motd ######
|
201
|
+
# Generate a new motd (Message of the Day) file
|
202
|
+
# Supported options:
|
203
|
+
# * :force [boolean] force action
|
204
|
+
# * :title [string] title of the motd (in figlet)
|
205
|
+
# * :support [string] email address to use for getting support
|
206
|
+
# * :hostname [string] hostname of the server to mention in the motd
|
207
|
+
# * :width [number] width of the line used
|
208
|
+
##
|
209
|
+
def motd(dir = Dir.pwd, options = {})
|
210
|
+
config = FalkorLib::Config::Bootstrap::DEFAULTS[:motd].merge!(::ActiveSupport::HashWithIndifferentAccess.new(options).symbolize_keys)
|
211
|
+
path = normalized_path(dir)
|
212
|
+
erbfile = File.join( FalkorLib.templates, 'motd', 'motd.erb')
|
213
|
+
outfile = (config[:file] =~ /^\//) ? config[:file] : File.join(path, config[:file])
|
214
|
+
info "Generate a motd (Message of the Day) file '#{outfile}'"
|
215
|
+
FalkorLib::Config::Bootstrap::DEFAULTS[:motd].keys.each do |k|
|
216
|
+
next if [:file, :width].include?(k)
|
217
|
+
config[k.to_sym] = ask( "\t" + format("Message of the Day (MotD) %-10s", k.to_s), config[k.to_sym]) unless options[:no_interaction]
|
218
|
+
end
|
219
|
+
config[:os] = Facter.value(:lsbdistdescription) if Facter.value(:lsbdistdescription)
|
220
|
+
config[:os] = "Mac " + Facter.value(:sp_os_version) if Facter.value(:sp_os_version)
|
221
|
+
unless options[:nodemodel]
|
222
|
+
config[:nodemodel] = Facter.value(:sp_machine_name) if Facter.value(:sp_machine_name)
|
223
|
+
config[:nodemodel] += " (#{Facter.value(:sp_cpu_type)}" if Facter.value(:sp_cpu_type)
|
224
|
+
config[:nodemodel] += " " + Facter.value(:sp_current_processor_speed) if Facter.value(:sp_current_processor_speed)
|
225
|
+
config[:nodemodel] += " #{Facter.value(:sp_number_processors)} cores )" if Facter.value(:sp_number_processors)
|
226
|
+
end
|
227
|
+
config[:nodemodel] = Facter.value(:sp_machine_name) unless options[:nodemodel]
|
228
|
+
write_from_erb_template(erbfile, outfile, config, options)
|
229
|
+
end # motd
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
###### readme ######
|
234
|
+
# Bootstrap a README file for various context
|
235
|
+
# Supported options:
|
236
|
+
# * :no_interaction [boolean]: do not interact
|
237
|
+
# * :force [boolean] force overwritting
|
238
|
+
# * :latex [boolean] describe a LaTeX project
|
239
|
+
# * :octopress [boolean] octopress site
|
240
|
+
##
|
241
|
+
def readme(dir = Dir.pwd, options = {})
|
242
|
+
info "Bootstrap a README file for this project"
|
243
|
+
# get the local configuration
|
244
|
+
local_config = FalkorLib::Config.get(dir)
|
245
|
+
config = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].clone
|
246
|
+
name = get_project_name(dir)
|
247
|
+
if local_config[:project]
|
248
|
+
config.deep_merge!( local_config[:project])
|
249
|
+
else
|
250
|
+
config[:name] = ask("\tProject name: ", name) unless options[:name]
|
251
|
+
end
|
252
|
+
if options[:rake]
|
253
|
+
options[:make] = false
|
254
|
+
options[:rvm] = true
|
255
|
+
end
|
256
|
+
config[:type] << :rvm if options[:rake]
|
257
|
+
# Type of project
|
258
|
+
config[:type] << :latex if options[:latex]
|
259
|
+
if config[:type].empty?
|
260
|
+
t = select_from( FalkorLib::Config::Bootstrap::DEFAULTS[:types],
|
261
|
+
'Select the type of project to describe:', 1)
|
262
|
+
config[:type] << t
|
263
|
+
config[:type] << [ :ruby, :rvm ] if [ :gem, :rvm, :octopress, :puppet_module ].include?( t )
|
264
|
+
config[:type] << :python if t == :pyenv
|
265
|
+
end
|
266
|
+
config[:type].uniq!
|
267
|
+
ap config
|
268
|
+
config[:type] = config[:type].uniq.flatten
|
269
|
+
# Apply options (if provided)
|
270
|
+
[ :name, :forge ].each do |k|
|
271
|
+
config[k.to_sym] = options[k.to_sym] if options[k.to_sym]
|
272
|
+
end
|
273
|
+
path = normalized_path(dir)
|
274
|
+
config[:filename] = (options[:filename]) ? options[:filename] : File.join(path, 'README.md')
|
275
|
+
if ( FalkorLib::Git.init?(dir) && FalkorLib::Git.remotes(dir).include?( 'origin' ))
|
276
|
+
config[:origin] = FalkorLib::Git.config('remote.origin.url')
|
277
|
+
if config[:origin] =~ /((gforge|gitlab|github)[\.\w_-]+)[:\d\/]+(\w*)/
|
278
|
+
config[:forge] = Regexp.last_match(2).to_sym
|
279
|
+
config[:by] = Regexp.last_match(3)
|
280
|
+
end
|
281
|
+
elsif config[:forge].empty?
|
282
|
+
config[:forge] = select_forge(config[:forge]).to_sym
|
283
|
+
end
|
284
|
+
forges = FalkorLib::Config::Bootstrap::DEFAULTS[:forge][ config[:forge].to_sym ]
|
285
|
+
#ap config
|
286
|
+
default_source = case config[:forge]
|
287
|
+
when :gforge
|
288
|
+
'https://' + forges[:url] + "/projects/" + name.downcase
|
289
|
+
when :github, :gitlab
|
290
|
+
'https://' + forges[:url] + "/" + config[:by] + "/" + name.downcase
|
291
|
+
else
|
292
|
+
""
|
293
|
+
end
|
294
|
+
FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].each do |k, v|
|
295
|
+
next if v.is_a?(Array) || [ :license, :forge ].include?( k )
|
296
|
+
next if (k == :name) && !config[:name].empty?
|
297
|
+
next if (k == :issues_url) && ![ :github, :gitlab ].include?( config[:forge] )
|
298
|
+
#next unless [ :name, :summary, :description ].include?(k.to_sym)
|
299
|
+
default_answer = case k
|
300
|
+
when :author
|
301
|
+
(config[:by] == 'ULHPC') ? 'UL HPC Management Team' : config[:author]
|
302
|
+
when :mail
|
303
|
+
(config[:by] == 'ULHPC') ? 'hpc-sysadmins@uni.lu' : config[:mail]
|
304
|
+
when :description
|
305
|
+
(config[:description].empty?) ? (config[:summary]).to_s : (config[:description]).to_s
|
306
|
+
when :source
|
307
|
+
(config[:source].empty?) ? default_source : (config[:source]).to_s
|
308
|
+
when :project_page
|
309
|
+
(config[:source].empty?) ? v : config[:source]
|
310
|
+
when :issues_url
|
311
|
+
(config[:project_page].empty?) ? v : "#{config[:project_page]}/issues"
|
626
312
|
else
|
627
|
-
|
313
|
+
(config[k.to_sym].empty?) ? v : config[k.to_sym]
|
628
314
|
end
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
315
|
+
config[k.to_sym] = ask( "\t" + Kernel.format("Project %-20s", k.to_s), default_answer)
|
316
|
+
end
|
317
|
+
tags = ask("\tKeywords (comma-separated list of tags)", config[:tags].join(','))
|
318
|
+
config[:tags] = tags.split(',')
|
319
|
+
config[:license] = select_licence if config[:license].empty?
|
320
|
+
# stack the ERB files required to generate the README
|
321
|
+
templatedir = File.join( FalkorLib.templates, 'README')
|
322
|
+
erbfiles = [ 'header_readme.erb' ]
|
323
|
+
[ :latex ].each do |type|
|
324
|
+
erbfiles << "readme_#{type}.erb" if options[type.to_sym] && File.exist?( File.join(templatedir, "readme_#{type}.erb"))
|
325
|
+
end
|
326
|
+
erbfiles << "readme_issues.erb"
|
327
|
+
erbfiles << "readme_git.erb" if FalkorLib::Git.init?(dir)
|
328
|
+
erbfiles << "readme_gitflow.erb" if FalkorLib::GitFlow.init?(dir)
|
329
|
+
erbfiles << "readme_rvm.erb" if config[:type].include?(:rvm)
|
330
|
+
erbfiles << "footer_readme.erb"
|
331
|
+
|
332
|
+
content = ""
|
333
|
+
erbfiles.each do |f|
|
334
|
+
erbfile = File.join(templatedir, f)
|
335
|
+
content += ERB.new(File.read(erbfile.to_s), nil, '<>').result(binding)
|
336
|
+
end
|
337
|
+
show_diff_and_write(content, config[:filename], options)
|
338
|
+
|
339
|
+
# Eventually save/upgrade local config
|
340
|
+
info "=> saving customization of the FalkorLib configuration in #{FalkorLib.config[:config_files][:local]}"
|
341
|
+
really_continue?
|
342
|
+
FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].keys.each do |k|
|
343
|
+
local_config[:project] = {} unless local_config[:project]
|
344
|
+
local_config[:project][k.to_sym] = config[k.to_sym]
|
345
|
+
end
|
346
|
+
if FalkorLib::GitFlow.init?(dir)
|
347
|
+
local_config[:gitflow] = {} unless local_config[:gitflow]
|
348
|
+
local_config[:gitflow][:branches] = FalkorLib.config[:gitflow][:branches].clone unless local_config[:gitflow][:branches]
|
349
|
+
[ :master, :develop ].each do |b|
|
350
|
+
local_config[:gitflow][:branches][b.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
FalkorLib::Config.save(dir, local_config, :local)
|
354
|
+
#
|
355
|
+
end # readme
|
356
|
+
|
357
|
+
|
358
|
+
###
|
359
|
+
# Select the forge (gforge, github, etc.) hosting the project sources
|
360
|
+
##
|
361
|
+
def select_forge(default = :gforge, _options = {})
|
362
|
+
forge = FalkorLib::Config::Bootstrap::DEFAULTS[:forge]
|
363
|
+
#ap forge
|
364
|
+
default_idx = forge.keys.index(default)
|
365
|
+
default_idx = 0 if default_idx.nil?
|
366
|
+
v = select_from(forge.map { |_k, u| u[:name] },
|
367
|
+
"Select the Forge hosting the project sources",
|
368
|
+
default_idx + 1,
|
369
|
+
forge.keys)
|
370
|
+
v
|
371
|
+
end # select_forge
|
372
|
+
|
373
|
+
###### select_licence ######
|
374
|
+
# Select a given licence for the project
|
375
|
+
##
|
376
|
+
def select_licence(default_licence = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata][:license],
|
377
|
+
_options = {})
|
378
|
+
list_license = FalkorLib::Config::Bootstrap::DEFAULTS[:licenses].keys
|
379
|
+
idx = list_license.index(default_licence) unless default_licence.nil?
|
380
|
+
select_from(list_license,
|
381
|
+
'Select the license index for this project:',
|
382
|
+
(idx.nil?) ? 1 : idx + 1)
|
383
|
+
#licence
|
384
|
+
end # select_licence
|
385
|
+
|
386
|
+
###### get_badge ######
|
387
|
+
# Return a Markdown-formatted string for a badge to display, typically in a README.
|
388
|
+
# Based on http://shields.io/
|
389
|
+
# Supported options:
|
390
|
+
# * :style [string] style of the badge, Elligible: ['plastic', 'flat', 'flat-square']
|
391
|
+
##
|
392
|
+
def get_badge(subject, status, color = 'blue', options = {})
|
393
|
+
st = status.gsub(/-/, '--').gsub(/_/, '__')
|
394
|
+
res = "https://img.shields.io/badge/#{subject}-#{st}-#{color}.svg"
|
395
|
+
res += "?style=#{options[:style]}" if options[:style]
|
396
|
+
res
|
397
|
+
end # get_licence_badge
|
398
|
+
|
399
|
+
###### get_project_name ######
|
400
|
+
# Return a "reasonable" project name from a given [sub] directory i.e. its basename
|
401
|
+
##
|
402
|
+
def get_project_name(dir = Dir.pwd, _options = {})
|
403
|
+
path = normalized_path(dir)
|
404
|
+
path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
|
405
|
+
File.basename(path)
|
406
|
+
end # get_project_name
|
407
|
+
|
408
|
+
|
409
|
+
end # module Bootstrap
|
718
410
|
end # module FalkorLib
|