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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +88 -0
  4. data/.travis.yml +56 -4
  5. data/Gemfile +4 -4
  6. data/Gemfile.lock +55 -27
  7. data/Rakefile +12 -8
  8. data/Vagrantfile +68 -0
  9. data/completion/_falkor +55 -7
  10. data/falkorlib.gemspec +14 -12
  11. data/lib/falkorlib.rb +22 -21
  12. data/lib/falkorlib/bootstrap.rb +5 -1
  13. data/lib/falkorlib/bootstrap/base.rb +385 -693
  14. data/lib/falkorlib/bootstrap/git.rb +137 -0
  15. data/lib/falkorlib/bootstrap/latex.rb +186 -0
  16. data/lib/falkorlib/bootstrap/link.rb +108 -96
  17. data/lib/falkorlib/bootstrap/ruby.rb +102 -0
  18. data/lib/falkorlib/cli.rb +82 -26
  19. data/lib/falkorlib/cli/config.rb +8 -8
  20. data/lib/falkorlib/cli/link.rb +8 -9
  21. data/lib/falkorlib/cli/new.rb +25 -39
  22. data/lib/falkorlib/common.rb +425 -425
  23. data/lib/falkorlib/config.rb +114 -110
  24. data/lib/falkorlib/error.rb +27 -16
  25. data/lib/falkorlib/gem_tasks.rb +12 -11
  26. data/lib/falkorlib/git.rb +3 -4
  27. data/lib/falkorlib/git/base.rb +439 -396
  28. data/lib/falkorlib/git/flow.rb +163 -165
  29. data/lib/falkorlib/git_tasks.rb +31 -31
  30. data/lib/falkorlib/loader.rb +1 -1
  31. data/lib/falkorlib/puppet.rb +3 -5
  32. data/lib/falkorlib/puppet/base.rb +10 -15
  33. data/lib/falkorlib/puppet/modules.rb +367 -365
  34. data/lib/falkorlib/puppet_tasks.rb +11 -8
  35. data/lib/falkorlib/tasks.rb +51 -54
  36. data/lib/falkorlib/tasks/gem.rake +42 -43
  37. data/lib/falkorlib/tasks/gem.rb +12 -11
  38. data/lib/falkorlib/tasks/git.rake +101 -107
  39. data/lib/falkorlib/tasks/git.rb +31 -31
  40. data/lib/falkorlib/tasks/gitflow.rake +131 -141
  41. data/lib/falkorlib/tasks/puppet.rb +11 -8
  42. data/lib/falkorlib/tasks/puppet_modules.rake +143 -154
  43. data/lib/falkorlib/tasks/rspec.rake +94 -59
  44. data/lib/falkorlib/tasks/yard.rake +35 -39
  45. data/lib/falkorlib/version.rb +55 -55
  46. data/lib/falkorlib/versioning.rb +169 -167
  47. data/spec/falkorlib/bootstrap_helpers_spec.rb +106 -56
  48. data/spec/falkorlib/bootstrap_latex_spec.rb +145 -0
  49. data/spec/falkorlib/bootstrap_link_spec.rb +137 -0
  50. data/spec/falkorlib/bootstrap_ruby_spec.rb +118 -0
  51. data/spec/falkorlib/bootstrap_spec.rb +112 -129
  52. data/spec/falkorlib/git_spec.rb +94 -22
  53. data/spec/falkorlib/gitflow_spec.rb +54 -42
  54. data/spec/falkorlib/puppet_modules_spec.rb +35 -26
  55. data/spec/falkorlib/versioning_puppet_module_spec.rb +94 -90
  56. data/spec/falkorlib_spec.rb +5 -0
  57. data/spec/spec_helper.rb +88 -47
  58. data/templates/latex/article-ieee/main.tex.erb +509 -0
  59. data/templates/latex/article/_abstract.tex.erb +19 -0
  60. data/templates/latex/article/_acronyms.tex.erb +116 -0
  61. data/templates/latex/article/_conclusion.tex.erb +25 -0
  62. data/templates/latex/article/_context.tex.erb +17 -0
  63. data/templates/latex/article/_experiments.tex.erb +27 -0
  64. data/templates/latex/article/_implem.tex.erb +17 -0
  65. data/templates/latex/article/_introduction.tex.erb +39 -0
  66. data/templates/latex/article/_related_works.tex.erb +19 -0
  67. data/templates/latex/article/biblio.bib.erb +28 -0
  68. data/templates/latex/article/template.tex.erb +16 -0
  69. data/templates/latex/ieee/IEEEtran.bst +2409 -0
  70. data/templates/latex/ieee/IEEEtran.cls +6347 -0
  71. data/templates/motd/motd.erb +2 -1
  72. metadata +82 -2
@@ -0,0 +1,137 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Fri 2016-11-11 15:05 svarrette>
4
+ ################################################################################
5
+ # Interface for the main Bootstrapping operations
6
+ #
7
+
8
+ require "falkorlib"
9
+ require "falkorlib/common"
10
+ require "falkorlib/bootstrap"
11
+
12
+ require 'erb' # required for module generation
13
+ require 'artii'
14
+ require 'facter'
15
+
16
+ include FalkorLib::Common
17
+
18
+
19
+ module FalkorLib
20
+ module Bootstrap #:nodoc:
21
+
22
+ module_function
23
+
24
+ ###### repo ######
25
+ # Initialize a Git repository for a project with my favorite layout
26
+ # Supported options:
27
+ # * :no_interaction [boolean]: do not interact
28
+ # * :gitflow [boolean]: bootstrap with git-flow
29
+ # * :interactive [boolean] Confirm Gitflow branch names
30
+ # * :master [string] Branch name for production releases
31
+ # * :develop [string] Branch name for development commits
32
+ # * :make [boolean] Use a Makefile to pilot the repository actions
33
+ # * :rake [boolean] Use a Rakefile (and FalkorLib) to pilot the repository action
34
+ # * :remote_sync [boolean] Operate a git remote synchronization
35
+ # * :latex [boolean] Initiate a LaTeX project
36
+ # * :gem [boolean] Initiate a Ruby gem project
37
+ # * :rvm [boolean] Initiate a RVM-based Ruby project
38
+ # * :pyenv [boolean] Initiate a pyenv-based Python project
39
+ # * :octopress [boolean] Initiate an Octopress web site
40
+ ##
41
+ def repo(name, options = {})
42
+ ap options if options[:debug]
43
+ path = normalized_path(name)
44
+ project = File.basename(path)
45
+ use_git = FalkorLib::Git.init?(path)
46
+ if options[:rake]
47
+ options[:make] = false
48
+ options[:rvm] = true
49
+ end
50
+ info "Bootstrap a [Git] repository for the project '#{project}'"
51
+ if use_git
52
+ warning "Git is already initialized for the repository '#{name}'"
53
+ really_continue? unless options[:force]
54
+ end
55
+ if options[:git_flow]
56
+ info " ==> initialize Git flow in #{path}"
57
+ FalkorLib::GitFlow.init(path, options)
58
+ gitflow_branches = {}
59
+ [ :master, :develop ].each do |t|
60
+ gitflow_branches[t.to_sym] = FalkorLib::GitFlow.branches(t, path)
61
+ end
62
+ else
63
+ FalkorLib::Git.init(path, options)
64
+ end
65
+ # === prepare Git submodules ===
66
+ info " ==> prepare the relevant Git submodules"
67
+ submodules = {}
68
+ #'gitstats' => { :url => 'https://github.com/hoxu/gitstats.git' }
69
+ # }
70
+ if options[:make]
71
+ submodules['Makefiles'] = {
72
+ :url => 'https://github.com/Falkor/Makefiles.git',
73
+ :branch => 'devel'
74
+ }
75
+ end
76
+ FalkorLib::Git.submodule_init(path, submodules)
77
+ # === Prepare root [M|R]akefile ===
78
+ if options[:make]
79
+ info " ==> prepare Root Makefile"
80
+ makefile = File.join(path, "Makefile")
81
+ if File.exist?( makefile )
82
+ puts " ... not overwriting the root Makefile which already exists"
83
+ else
84
+ src_makefile = File.join(path, FalkorLib.config.git[:submodulesdir],
85
+ 'Makefiles', 'repo', 'Makefile')
86
+ FileUtils.cp src_makefile, makefile
87
+ info "adapting Makefile to the gitflow branches"
88
+ Dir.chdir( path ) do
89
+ run %(
90
+ sed -i '' \
91
+ -e \"s/^GITFLOW_BR_MASTER=production/GITFLOW_BR_MASTER=#{gitflow_branches[:master]}/\" \
92
+ -e \"s/^GITFLOW_BR_DEVELOP=devel/GITFLOW_BR_DEVELOP=#{gitflow_branches[:develop]}/\" \
93
+ Makefile
94
+ )
95
+ end
96
+ FalkorLib::Git.add(makefile, 'Initialize root Makefile for the repo')
97
+ end
98
+ end
99
+ if options[:rake]
100
+ info " ==> prepare Root Rakefile"
101
+ rakefile = File.join(path, "Rakefile")
102
+ unless File.exist?( rakefile )
103
+ templatedir = File.join( FalkorLib.templates, 'Rakefile')
104
+ erbfiles = [ 'header_rakefile.erb' ]
105
+ erbfiles << 'rakefile_gitflow.erb' if FalkorLib::GitFlow.init?(path)
106
+ erbfiles << 'footer_rakefile.erb'
107
+ write_from_erb_template(erbfiles, rakefile, {}, :srcdir => templatedir.to_s)
108
+ end
109
+ end
110
+
111
+ # === VERSION file ===
112
+ FalkorLib::Bootstrap.versionfile(path, :tag => 'v0.0.0')
113
+
114
+ # === RVM ====
115
+ FalkorLib::Bootstrap.rvm(path, options) if options[:rvm]
116
+
117
+ # === README ===
118
+ FalkorLib::Bootstrap.readme(path, options)
119
+
120
+ #===== remote synchro ========
121
+ if options[:remote_sync]
122
+ remotes = FalkorLib::Git.remotes(path)
123
+ if remotes.include?( 'origin' )
124
+ info "perform remote synchronization"
125
+ [ :master, :develop ].each do |t|
126
+ FalkorLib::Git.publish(gitflow_branches[t.to_sym], path, 'origin')
127
+ end
128
+ else
129
+ warning "no Git remote 'origin' found, thus no remote synchronization performed"
130
+ end
131
+ end
132
+ end # repo
133
+
134
+
135
+
136
+ end # module Bootstrap
137
+ end # module FalkorLib
@@ -0,0 +1,186 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Sat 2016-11-12 12:18 svarrette>
4
+ ################################################################################
5
+ # Interface for the main Bootstrapping operations
6
+ #
7
+
8
+ require "falkorlib"
9
+ require "falkorlib/common"
10
+ require "falkorlib/bootstrap"
11
+
12
+ require 'erb' # required for module generation
13
+ require 'artii'
14
+ require 'facter'
15
+
16
+ include FalkorLib::Common
17
+
18
+
19
+ module FalkorLib
20
+ module Bootstrap #:nodoc:
21
+
22
+ module_function
23
+
24
+ ###### latex ######
25
+ # Bootstrap a LaTeX sub-project of type <type> within a given repository <dir>.
26
+ # * :beamer LaTeX Beamer Slides
27
+ # * :article LaTeX article
28
+ # * :ieee LaTeX IEEE conference article
29
+ # * :ieee_jnl LaTeX IEEE journal
30
+ # * :acm LaTeX ACM conference article
31
+ # * :letter LaTeX Letter
32
+ # Supported options:
33
+ # * :force [boolean] force action
34
+ # * :no_interaction [boolean]: do not interact
35
+ ##
36
+ def latex(dir = Dir.pwd, type = :beamer, options = {})
37
+ ap options if options[:debug]
38
+ error "Unsupported type" unless [ :beamer, :article, :ieee, :letter ].include?( type )
39
+ path = normalized_path(dir)
40
+ config = FalkorLib::Config::Bootstrap::DEFAULTS[:latex].clone
41
+ if type == :letter
42
+ config.merge!(FalkorLib::Config::Bootstrap::DEFAULTS[:letter].clone)
43
+ [ :title, :subtitle, :image ].each { |k| config.delete k }
44
+ end
45
+ config.deep_merge!(FalkorLib::Config::Bootstrap::DEFAULTS[:letter].clone) if type == :letter
46
+ # initiate the repository if needed
47
+ unless File.directory?( path )
48
+ warn "The directory '#{path}' does not exists and will be created"
49
+ really_continue? unless options[:no_interaction]
50
+ run %( mkdir -p #{path} )
51
+ end
52
+ repo(path, options) unless FalkorLib::Git.init?(path)
53
+ rootdir = FalkorLib::Git.rootdir(path)
54
+ info "Initiate a LaTeX #{type} project from the Git root directory: '#{rootdir}'"
55
+ really_continue? unless options[:no_interaction]
56
+ relative_path_to_root = (Pathname.new( FalkorLib::Git.rootdir(dir) ).relative_path_from Pathname.new( File.realpath(path))).to_s
57
+ config[:name] = (options[:name]) ? options[:name] : ask("\tEnter the name of the #{type} LaTeX project: ", File.basename(path))
58
+ raise FalkorLib::ExecError "Empty project name" if config[:name].empty?
59
+ default_project_dir = (Pathname.new( File.realpath(path) ).relative_path_from Pathname.new( FalkorLib::Git.rootdir(dir))).to_s
60
+ if relative_path_to_root == '.'
61
+ default_project_dir = case type
62
+ when :article, :ieee
63
+ "articles/#{Time.now.year}/#{config[:name]}"
64
+ when :beamer
65
+ "slides/#{Time.now.year}/#{config[:name]}"
66
+ when :bookchapter
67
+ "chapters/#{config[:name]}"
68
+ when :letter
69
+ "letters/#{Time.now.year}/#{config[:name]}"
70
+ else
71
+ (config[:name]).to_s
72
+ end
73
+ else
74
+ default_project_dir += "/#{config[:name]}" unless default_project_dir =~ /#{config[:name]}$/
75
+ end
76
+ project_dir = (options[:dir]) ? options[:dir] : default_project_dir
77
+ project_dir = ask("\tLaTeX Sources directory (relative to the Git root directory)", project_dir.to_s) unless options[:no_interaction]
78
+ raise FalkorLib::ExecError "Empty project directory" if project_dir.empty?
79
+ src_project_dir = File.join(project_dir, 'src')
80
+ srcdir = File.join(rootdir, src_project_dir)
81
+ if File.exist?(File.join(srcdir, '.root'))
82
+ warn "The directory '#{project_dir}' seems to have been already initialized"
83
+ really_continue? unless options[:no_interaction]
84
+ end
85
+ FalkorLib::GitFlow.start('feature', config[:name], rootdir) if FalkorLib::GitFlow.init?(rootdir)
86
+ # === prepare Git submodules ===
87
+ info " ==> prepare the relevant Git submodules"
88
+ submodules = {}
89
+ if [ :article, :beamer, :bookchapter].include?(type)
90
+ submodules['Makefiles'] = { :url => 'https://github.com/Falkor/Makefiles.git',
91
+ :branch => 'devel' }
92
+ end
93
+ submodules['beamerthemeFalkor'] = { :url => 'https://github.com/Falkor/beamerthemeFalkor' } if type == :beamer
94
+ FalkorLib::Git.submodule_init(rootdir, submodules)
95
+ info "bootstrapping the #{type} project sources in '#{src_project_dir}'"
96
+ # Create the project directory
97
+ Dir.chdir( rootdir ) do
98
+ run %( mkdir -p #{src_project_dir}/images ) unless File.directory?("#{srcdir}/images")
99
+ end
100
+ info "populating '#{src_project_dir}'"
101
+ #FalkorLib::Bootstrap::Link.root(srcdir, { :verbose => true} )
102
+ FalkorLib::Bootstrap::Link.makefile(srcdir, :no_interaction => true)
103
+ [ '_style.sty', '.gitignore' ].each do |f|
104
+ Dir.chdir( srcdir ) do
105
+ dst = ".makefile.d/latex/#{f}"
106
+ run %( ln -s #{dst} #{f} ) unless File.exist?( File.join(srcdir, f) )
107
+ end
108
+ end
109
+ if type == :beamer
110
+ f = 'beamerthemeFalkor.sty'
111
+ dst = "#{FalkorLib.config[:git][:submodulesdir]}/beamerthemeFalkor/#{f}"
112
+ Dir.chdir( srcdir ) do
113
+ run %( ln -s .root/#{dst} #{f} ) unless File.exist?( File.join(srcdir, f) )
114
+ end
115
+ end
116
+
117
+ # Bootstrap the directory
118
+ src_templatedir = File.join( FalkorLib.templates, 'latex')
119
+ unless File.exist?( File.join(srcdir, "#{config[:name]}.tex"))
120
+ info "gathering information for the LaTeX templates"
121
+ prefix = case type
122
+ when :article, :ieee, :acm
123
+ 'Article '
124
+ when :ieee_journal
125
+ 'IEEE Journal '
126
+ when :beamer
127
+ 'Slides '
128
+ when :bookchapter
129
+ 'Book Chapter '
130
+ when :letter
131
+ 'Letter '
132
+ else
133
+ ''
134
+ end
135
+ config.each do |k, v|
136
+ next if k == :name
137
+ config[k.to_sym] = ask( "\t" + Kernel.format("%-20s", "#{prefix}#{k.capitalize}"), v) unless options[:no_interaction]
138
+ end
139
+ templates = [ File.join(src_templatedir, type.to_s) ]
140
+ if [ :ieee, :ieee_journal, :acm].include?( type )
141
+ templates << File.join(src_templatedir, 'article')
142
+ templates << File.join(src_templatedir, "article-#{type}")
143
+ end
144
+ if type == :article
145
+ templates << File.join(src_templatedir, 'ieee')
146
+ templates << File.join(src_templatedir, 'article-ieee')
147
+ end
148
+ templates.each do |templatedir|
149
+ info "**** using templatedir = #{templatedir}"
150
+ init_from_template(templatedir, srcdir, config, :no_interaction => true,
151
+ :no_commit => true)
152
+ end
153
+ # Rename the main file
154
+ Dir.chdir( srcdir ) do
155
+ run %( mv main.tex #{config[:name]}.tex )
156
+ end
157
+ end
158
+ # Create the trash directory
159
+ trash(srcdir)
160
+
161
+ # populate the images/ directory
162
+ baseimages = File.join( FalkorLib.templates, 'latex', 'images')
163
+ #images_makefile_src = "#{FalkorLib.config[:git][:submodulesdir]}/Makefiles/generic/Makefile.insrcdir"
164
+ images = File.join(srcdir, 'images')
165
+ info "populating the image directory"
166
+ Dir.chdir( images ) do
167
+ run %( rsync -avzu #{baseimages}/ . )
168
+ run %( ln -s ../.root .root ) unless File.exist?(File.join(images, '.root'))
169
+ #run %{ ln -s .root/#{images_makefile_src} Makefile } unless File.exists?(File.join(images, 'Makefile'))
170
+ end
171
+ FalkorLib::Bootstrap::Link.makefile(images, :images => true, :no_interaction => true )
172
+
173
+ # Prepare the src/ directory
174
+ FalkorLib::Bootstrap::Link.makefile(File.join(rootdir, project_dir), :src => true, :no_interaction => true )
175
+
176
+
177
+ # default_project_dir = case type
178
+ # when :beamer
179
+ # "slides/#{Time.new.yea}"
180
+ # end
181
+ end # project
182
+
183
+
184
+
185
+ end # module Bootstrap
186
+ end # module FalkorLib
@@ -1,12 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sat 2016-10-15 22:55 svarrette>
3
+ # Time-stamp: <Sun 2016-11-13 06:44 svarrette>
4
4
  ################################################################################
5
5
  # Interface for Bootstrapping various symlinks within your project
6
6
  #
7
7
  require "falkorlib"
8
8
  require "falkorlib/common"
9
- require 'erb' # required for module generation
9
+ require "falkorlib/bootstrap"
10
+
11
+ require 'erb' # required for module generation
10
12
  require 'artii'
11
13
  require 'facter'
12
14
 
@@ -14,103 +16,113 @@ include FalkorLib::Common
14
16
 
15
17
 
16
18
  module FalkorLib
17
- module Bootstrap
18
- module Link
19
+ module Bootstrap
20
+ # Hold [sim]link fonction creations
21
+ module Link
19
22
 
20
- module_function
23
+ module_function
21
24
 
22
- ###### makefile ######
23
- # Create a symlink to the one of Falkor's Makefile, typically bring as a Git submodule
24
- # Supported options:
25
- # * :force [boolean] force action
26
- # * :latex [boolean] Makefile to compile LaTeX documents
27
- # * :gnuplot [boolean] Makefile to compile GnuPlot scripts
28
- # * :markdown [boolean] Makefile to convert Markdown files to HTML
29
- # * :refdir [string] Path to Falkor's Makefile repository
30
- # * :src [boolean] Path to latex_src
31
- # * :no_interaction [boolean] do not interact
32
- ##
33
- def makefile(dir = Dir.pwd,
34
- options = {
35
- :no_interaction => false
36
- })
37
- path = normalized_path(dir)
38
- rootdir = FalkorLib::Git.rootdir(path)
39
- info "Create a symlink to one of Falkor's Makefile"
40
- # Add Falkor's Makefiles
41
- submodules = FalkorLib.config[:git][:submodules]
42
- submodules['Makefiles'] = {
43
- :url => 'https://github.com/Falkor/Makefiles.git',
44
- :branch => 'devel'
45
- } if submodules['Makefiles'].nil?
46
- FalkorLib::Git.submodule_init(rootdir, submodules)
47
- FalkorLib::Bootstrap::Link.root(dir)
48
- refdir = File.join(FalkorLib.config[:git][:submodulesdir], 'Makefiles')
49
- refdir = options[:refdir] unless options[:refdir].nil?
50
- dst = File.join('.root', refdir)
51
- makefile_d = '.makefile.d'
52
- unless File.exists?(File.join(path, makefile_d))
53
- Dir.chdir( path ) do
54
- run %{ ln -s #{dst} #{makefile_d} }
55
- FalkorLib::Git.add(File.join(path, makefile_d), "Add symlink '#{makefile_d}' to Falkor's Makefile directory")
56
- end
57
- end
58
- #ap options
59
- makefile = 'Makefile'
60
- type = 'latex'
61
- # recall to place the default option (--latex) at the last position
62
- [ :gnuplot, :images, :generic, :markdown] .each do |e|
63
- if options[e.to_sym]
64
- type = e.to_s
65
- break
66
- end
67
- end
68
- type = 'latex_src' if options[:src]
69
- makefile = 'Makefile.insubdir' if options[:generic]
70
- makefile = 'Makefile.to_html' if options[:markdown]
71
- dst = File.join(makefile_d, type, makefile)
72
- unless File.exists?( File.join(path, 'Makefile'))
73
- info "Bootstrapping #{type.capitalize} Makefile (as symlink to Falkor's Makefile)"
74
- really_continue? unless options[:no_interaction]
75
- Dir.chdir( path ) do
76
- run %{ ln -s #{dst} Makefile }
77
- end
78
- #ap File.join(path, 'Makefile')
79
- FalkorLib::Git.add(File.join(path, 'Makefile'), "Add symlink to the #{type.capitalize} Makefile")
80
- else
81
- puts " ... Makefile already setup"
82
- end
83
- end # makefile_link
25
+ ###### makefile ######
26
+ # Create a symlink to the one of Falkor's Makefile, typically bring as a Git submodule
27
+ # Supported options:
28
+ # * :force [boolean] force action
29
+ # * :latex [boolean] Makefile to compile LaTeX documents
30
+ # * :gnuplot [boolean] Makefile to compile GnuPlot scripts
31
+ # * :markdown [boolean] Makefile to convert Markdown files to HTML
32
+ # * :refdir [string] Path to Falkor's Makefile repository
33
+ # * :src [boolean] Path to latex_src
34
+ # * :no_interaction [boolean] do not interact
35
+ ##
36
+ def makefile(dir = Dir.pwd,
37
+ options = {
38
+ :no_interaction => false
39
+ })
40
+ raise FalkorLib::ExecError "Not used in a Git repository" unless FalkorLib::Git.init?
41
+ exit_status = 0
42
+ path = normalized_path(dir)
43
+ rootdir = FalkorLib::Git.rootdir(path)
44
+ info "Create a symlink to one of Falkor's Makefile"
45
+ # Add Falkor's Makefiles
46
+ submodules = FalkorLib.config[:git][:submodules]
47
+ if submodules['Makefiles'].nil?
48
+ submodules['Makefiles'] = {
49
+ :url => 'https://github.com/Falkor/Makefiles.git',
50
+ :branch => 'devel'
51
+ }
52
+ end
53
+ FalkorLib::Git.submodule_init(rootdir, submodules)
54
+ FalkorLib::Bootstrap::Link.root(dir)
55
+ refdir = File.join(FalkorLib.config[:git][:submodulesdir], 'Makefiles')
56
+ refdir = options[:refdir] unless options[:refdir].nil?
57
+ dst = File.join('.root', refdir)
58
+ makefile_d = '.makefile.d'
59
+ unless File.exist?(File.join(path, makefile_d))
60
+ Dir.chdir( path ) do
61
+ run %( ln -s #{dst} #{makefile_d} )
62
+ FalkorLib::Git.add(makefile_d, "Add symlink '#{makefile_d}' to Falkor's Makefile directory")
63
+ end
64
+ end
65
+ #ap options
66
+ makefile = 'Makefile'
67
+ type = 'latex'
68
+ # recall to place the default option (--latex) at the last position
69
+ [ :gnuplot, :images, :generic, :markdown, :repo] .each do |e|
70
+ if options[e.to_sym]
71
+ type = e.to_s
72
+ break
73
+ end
74
+ end
75
+ type = 'latex_src' if options[:src]
76
+ makefile = 'Makefile.insubdir' if options[:generic]
77
+ makefile = 'Makefile.to_html' if options[:markdown]
78
+ dst = File.join(makefile_d, type, makefile)
79
+ if File.exist?( File.join(path, 'Makefile'))
80
+ puts " ... Makefile already setup"
81
+ exit_status = 1
82
+ else
83
+ info "Bootstrapping #{type.capitalize} Makefile (as symlink to Falkor's Makefile)"
84
+ really_continue? unless options[:no_interaction]
85
+ Dir.chdir( path ) do
86
+ exit_status = run %( ln -s #{dst} Makefile )
87
+ exit_status = FalkorLib::Git.add('Makefile', "Add symlink to the #{type.capitalize} Makefile")
88
+ end
89
+ end
90
+ exit_status.to_i
91
+ end # makefile_link
84
92
 
85
- ###### rootlink ######
86
- # Create a symlink '.root' targeting the relative path to the git root directory
87
- # Supported options:
88
- # * :name [string] name of the symlink ('.root' by default)
89
- ##
90
- def root(dir = Dir.pwd, options = {})
91
- raise FalkorLib::ExecError "Not used in a Git repository" unless FalkorLib::Git.init?
92
- path = normalized_path(dir)
93
- relative_path_to_root = (Pathname.new( FalkorLib::Git.rootdir(dir) ).relative_path_from Pathname.new( File.realpath(path)))
94
- if "#{relative_path_to_root}" == "."
95
- FalkorLib::Common.warning "Already at the root directory of the Git repository"
96
- FalkorLib::Common.really_continue? unless options[:no_interaction]
97
- end
98
- target = options[:name] ? options[:name] : '.root'
99
- puts "Entering '#{relative_path_to_root}'"
100
- unless File.exists?( File.join(path, target))
101
- warning "creating the symboling link '#{target}' which points to '#{relative_path_to_root}'" if options[:verbose]
102
- # Format: ln_s(old, new, options = {}) -- Creates a symbolic link new which points to old.
103
- #FileUtils.ln_s "#{relative_path_to_root}", "#{target}"
104
- Dir.chdir( path ) do
105
- run %{ ln -s #{relative_path_to_root} #{target} }
106
- end
107
- FalkorLib::Git.add(File.join(path, target), "Add symlink to the root directory as .root")
108
- else
109
- puts " ... the symbolic link '#{target}' already exists"
110
- end
111
- end # rootlink
93
+ ###### rootlink ######
94
+ # Create a symlink '.root' targeting the relative path to the git root directory
95
+ # Supported options:
96
+ # * :name [string] name of the symlink ('.root' by default)
97
+ ##
98
+ def root(dir = Dir.pwd, options = {})
99
+ raise FalkorLib::ExecError "Not used in a Git repository" unless FalkorLib::Git.init?
100
+ exit_status = 0
101
+ path = normalized_path(dir)
102
+ relative_path_to_root = (Pathname.new( FalkorLib::Git.rootdir(dir) ).relative_path_from Pathname.new( File.realpath(path)))
103
+ if relative_path_to_root.to_s == "."
104
+ FalkorLib::Common.warning "Already at the root directory of the Git repository"
105
+ FalkorLib::Common.really_continue? unless options[:no_interaction]
106
+ end
107
+ target = (options[:name]) ? options[:name] : '.root'
108
+ puts "Entering '#{relative_path_to_root}'"
109
+ if File.exist?( File.join(path, target))
110
+ puts " ... the symbolic link '#{target}' already exists"
111
+ exit_status = 1
112
+ else
113
+ warning "creating the symboling link '#{target}' which points to '#{relative_path_to_root}'" if options[:verbose]
114
+ # Format: ln_s(old, new, options = {}) -- Creates a symbolic link new which points to old.
115
+ #FileUtils.ln_s "#{relative_path_to_root}", "#{target}"
116
+ Dir.chdir( path ) do
117
+ exit_status = run %( ln -s #{relative_path_to_root} #{target} )
118
+ end
119
+ exit_status = FalkorLib::Git.add(File.join(path, target),
120
+ "Add symlink to the root directory as .root")
121
+ end
122
+ exit_status.to_i
123
+ end # rootlink
112
124
 
113
125
 
114
- end # module Link
115
- end # module Bootstrap
126
+ end # module Link
127
+ end # module Bootstrap
116
128
  end # module FalkorLib