falkorlib 0.4.1 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be6b7e9b76a06c18709b775c77d17e487e318cbd
4
- data.tar.gz: 7ba5fa7986575faea59f5c26d085c5f953f444d1
3
+ metadata.gz: 66b087ab11950e193ccd65ee4139b55641d00afe
4
+ data.tar.gz: 9c0addcd32c2e2f4c4f42cd8ef82173b351fd641
5
5
  SHA512:
6
- metadata.gz: 91aeab1807f5b5bbdc057bebe6430d686bbd0471985afa9ef89de425ea8e03530912d0b450fc84092d84ec6e2529c7bebc4a404476ec2a5e36b79fa703e7ac28
7
- data.tar.gz: 079ed9bf07a7a96afc217af7e4b66b75e3ada0d595197ed4cede9c043750fbe4b7233016942125d3db1ce5f003ea6f2ec23b066516dced0dfa711bc2d0f90f42
6
+ metadata.gz: 38b0b4b09e4535c68c63ff4df89bf67eb268b7547c637679e50a5e0c8894090113c3a39e3ae3708d1605cac75c8e1d629f16cba408e9b46a51670cea8f537f6a
7
+ data.tar.gz: ee95891a9412a8ebe66d124a56aa8f59d6ccbcc4553dcfc3f4d36e14abcfa32e46d64b7503ded8fd3287fa5c4e42fdc7dfa2dc2ef2bac82eb905ceeb7b5c75ec
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.4.1)
4
+ falkorlib (0.4.2)
5
+ artii (>= 2.1)
5
6
  awesome_print (~> 1.2)
6
7
  configatron (~> 3.2)
7
8
  deep_merge (~> 1.0.1)
@@ -19,6 +20,7 @@ GEM
19
20
  remote: http://rubygems.org/
20
21
  specs:
21
22
  addressable (2.3.6)
23
+ artii (2.1.1)
22
24
  awesome_print (1.6.1)
23
25
  backports (3.6.0)
24
26
  codeclimate-test-reporter (0.3.0)
data/falkorlib.gemspec CHANGED
@@ -136,6 +136,7 @@ Gem::Specification.new do |s|
136
136
  s.add_runtime_dependency("diffy", '>= 3.0')
137
137
  s.add_runtime_dependency("logger", '>= 1.2.8')
138
138
  s.add_runtime_dependency("thor", '>= 0.19')
139
+ s.add_runtime_dependency("artii", '>= 2.1')
139
140
  #s.add_runtime_dependency("mercenary", '>= 0.3.5')
140
141
 
141
142
  #
@@ -1,12 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Dim 2015-02-01 14:43 svarrette>
3
+ # Time-stamp: <Mar 2015-02-24 21:58 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 'erb' # required for module generation
11
+ require 'artii'
10
12
 
11
13
  include FalkorLib::Common
12
14
 
@@ -19,24 +21,62 @@ module FalkorLib #:nodoc:
19
21
  {
20
22
  :metadata => {
21
23
  :name => '',
22
- :version => '0.0.1',
24
+ :type => [],
23
25
  :author => "#{ENV['GIT_AUTHOR_NAME']}",
24
26
  :mail => "#{ENV['GIT_AUTHOR_EMAIL']}",
25
27
  :summary => "rtfm",
26
28
  :description => '',
29
+ :forge => :gforge,
27
30
  :source => '',
28
31
  :project_page => '',
32
+ :license => '',
29
33
  :issues_url => '',
30
34
  :tags => []
31
35
  },
32
36
  :trashdir => '.Trash',
33
- :types => [ 'article', 'slides', 'gem', 'octopress', 'puppet_module', 'rvm' ],
37
+ :types => [ :latex, :gem, :octopress, :puppet_module, :rvm, :pyenv ],
38
+ :licenses => {
39
+ "none" => {},
40
+ "Apache-2.0" => {
41
+ :url => "http://www.apache.org/licenses/LICENSE-2.0",
42
+ :logo => "https://www.apache.org/images/feather-small.gif"
43
+ },
44
+ "BSD" => {
45
+ :url => "http://www.linfo.org/bsdlicense.html",
46
+ :logo => "http://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/License_icon-bsd.svg/200px-License_icon-bsd.svg.png"
47
+ },
48
+ "CC by-nc-sa" => {
49
+ :name => "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International",
50
+ :url => "http://creativecommons.org/licenses/by-nc-sa/4.0",
51
+ :logo => "https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png"
52
+ },
53
+ "GPL-2.0" => {
54
+ :url => "http://www.gnu.org/licenses/gpl-2.0.html",
55
+ :logo => "https://licensebuttons.net/l/GPL/2.0/88x62.png"
56
+ },
57
+ "GPL-3.0" => {
58
+ :url => "http://www.gnu.org/licenses/gpl-3.0.html",
59
+ :logo => "https://www.gnu.org/graphics/gplv3-88x31.png",
60
+ },
61
+ "LGPL-2.1" => {
62
+ :url => "https://www.gnu.org/licenses/lgpl-2.1.html",
63
+ :logo => "https://licensebuttons.net/l/LGPL/2.1/88x62.png",
64
+ },
65
+ "LGPL-3.0" => {
66
+ :url => "https://www.gnu.org/licenses/lgpl.html",
67
+ :logo => "https://www.gnu.org/graphics/lgplv3-88x31.png",
68
+ },
69
+ "MIT" => {
70
+ :url => "http://opensource.org/licenses/MIT",
71
+ :logo => "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/License_icon-mit-2.svg/200px-License_icon-mit-2.svg.png"
72
+ },
73
+ },
34
74
  :puppet => {},
35
75
  :forge => {
36
- :gforge => { :url => 'http://gforge.uni.lu', :name => 'GForge @ Uni.lu' },
37
- :github => { :url => 'http://github.com', :name => 'Github', :login => 'ULHPC' },
38
- :gitlab => { :url => 'http://gitlab.uni.lu', :name => 'Gitlab @ Uni.lu' },
39
- :none => { :url => '', :name => "None"}
76
+ :none => { :url => '', :name => "None"},
77
+ :gforge => { :url => 'https://gforge.uni.lu', :name => 'GForge @ Uni.lu' },
78
+ :github => { :url => 'https://github.com', :name => 'Github', :login => "#{`whoami`.chomp.capitalize}" },
79
+ :gitlab => { :url => 'https://gitlab.uni.lu', :name => 'Gitlab @ Uni.lu' },
40
80
  },
41
81
  }
42
82
 
@@ -147,6 +187,11 @@ module FalkorLib
147
187
  # :make [boolean] Use a Makefile to pilot the repository actions
148
188
  # :rake [boolean] Use a Rakefile (and FalkorLib) to pilot the repository action
149
189
  # :remote_sync [boolean] Operate a git remote synchronization
190
+ # :latex [boolean] Initiate a LaTeX project
191
+ # :gem [boolean] Initiate a Ruby gem project
192
+ # :rvm [boolean] Initiate a RVM-based Ruby project
193
+ # :pyenv [boolean] Initiate a pyenv-based Python project
194
+ # :octopress [boolean] Initiate an Octopress web site
150
195
  ##
151
196
  def repo(name, options = {})
152
197
  ap options if options[:debug]
@@ -205,6 +250,9 @@ module FalkorLib
205
250
  # === VERSION file ===
206
251
  FalkorLib::Bootstrap.versionfile(path, :tag => 'v0.0.0')
207
252
 
253
+ # === README ===
254
+ FalkorLib::Bootstrap.readme(path, options)
255
+
208
256
  #===== remote synchro ========
209
257
  if options[:remote_sync]
210
258
  remotes = FalkorLib::Git.remotes(path)
@@ -271,24 +319,99 @@ module FalkorLib
271
319
  # * :latex [boolean] describe a LaTeX project
272
320
  # * :octopress [boolean] octopress site
273
321
  ##
274
- def readme(dir = Dir.pwd, type = 'latex', options = {})
275
- info "Bootstrap a README file"
276
- #if File.exists?(File.join(dir, ))
322
+ def readme(dir = Dir.pwd, options = {})
323
+ info "Bootstrap a README file for this project"
324
+ # get the local configuration
325
+ local_config = FalkorLib::Config.get(dir)
277
326
  config = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].clone
278
- config[:filename] = options[:filename] ? options[:filename] : 'README.md'
279
- config[:name] = options[:name] ? options[:name] : File.basename(dir)
280
- default_forge = options[:forge] ? options[:forge] : :github
281
- forges = FalkorLib::Config::Bootstrap::DEFAULTS[:forge]
282
- case select_forge(default_forge)
283
- when :gforge
284
- config[:project_page] = forges[:url] + "/projects/"
327
+ if local_config[:project]
328
+ config.deep_merge!( local_config[:project])
329
+ else
330
+ config[:name] = ask("\tProject name: ", get_project_name(dir)) unless options[:name]
285
331
  end
332
+ # Type of project
333
+ config[:type] << :latex if options[:latex]
334
+ if config[:type].empty?
335
+ t = select_from( FalkorLib::Config::Bootstrap::DEFAULTS[:types],
336
+ 'Select the type of project to describe:')
337
+ config[:type] << t
338
+ config[:type] << [ :ruby, :rvm ] if [ :gem, :rvm, :octopress, :puppet_module ].include?( t )
339
+ config[:type] << :python if t == :pyenv
340
+ end
341
+ config[:type] = config[:type].uniq.flatten
342
+ # Apply options (if provided)
343
+ [ :name, :forge ].each do |k|
344
+ config[k.to_sym] = options[k.to_sym] if options[k.to_sym]
345
+ end
346
+ path = normalized_path(dir)
347
+ config[:filename] = options[:filename] ? options[:filename] : File.join(path, 'README.md')
348
+ config[:forge] = select_forge(config[:forge]).to_sym if config[:forge].empty?
349
+ forges = FalkorLib::Config::Bootstrap::DEFAULTS[:forge][ config[:forge].to_sym ]
350
+ default_source = case config[:forge]
351
+ when :gforge
352
+ forges[:url] + "/projects/" + config[:name].downcase
353
+ when :github
354
+ forges[:url] + "/" + forges[:login] + "/" + config[:name].downcase
355
+ when :gitlab
356
+ forges[:url] + "/" + forges[:name].downcase
357
+ end
286
358
 
359
+ FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].each do |k,v|
360
+ next if v.kind_of?(Array) or [ :license, :forge ].include?( k )
361
+ next if k == :name and ! name.empty?
362
+ next if k == :issues_url and ! [ :github, :gitlab ].include?( config[:forge] )
363
+ #next unless [ :name, :summary, :description ].include?(k.to_sym)
364
+ default_answer = case k
365
+ when :description
366
+ config[:description].empty? ? "#{config[:summary]}" : "#{config[:description]}"
367
+ when :source
368
+ config[:source].empty? ? default_source : "#{config[:source]}"
369
+ when :project_page
370
+ config[:source].empty? ? v : config[:source]
371
+ when :issues_url
372
+ config[:project_page].empty? ? v : "#{config[:project_page]}/issues"
373
+ else
374
+ config[k.to_sym].empty? ? v : config[k.to_sym]
375
+ end
376
+ config[k.to_sym] = ask( "\t" + sprintf("Project %-20s", "#{k}"), default_answer)
377
+ end
378
+ tags = ask("\tKeywords (comma-separated list of tags)", config[:tags].join(','))
379
+ config[:tags] = tags.split(',')
380
+ config[:license] = select_licence() if config[:license].empty?
381
+ # stack the ERB files required to generate the README
382
+ templatedir = File.join( FalkorLib.templates, 'README')
383
+ erbfiles = [ 'header_readme.erb', ]
384
+ [ :latex ].each do |type|
385
+ erbfiles << "readme_#{type}.erb" if options[type.to_sym] and File.exist?( File.join(templatedir, "readme_#{type}.erb"))
386
+ end
387
+ erbfiles << "readme_git.erb" if FalkorLib::Git.init?(dir)
388
+ erbfiles << "readme_gitflow.erb" if FalkorLib::GitFlow.init?(dir)
389
+ erbfiles << "readme_rvm.erb" if config[:type].include?(:rvm)
390
+ erbfiles << "footer_readme.erb"
287
391
 
288
- # config[:project_page] = case forge
289
- # when :gforge
290
-
291
- # end
392
+ content = ""
393
+ erbfiles.each do |f|
394
+ erbfile = File.join(templatedir, f)
395
+ content += ERB.new(File.read("#{erbfile}"), nil, '<>').result(binding)
396
+ end
397
+ show_diff_and_write(content, config[:filename], options)
398
+
399
+ # Eventually save/upgrade local config
400
+ info "=> saving customization of the FalkorLib configuration in #{FalkorLib.config[:config_files][:local]}"
401
+ really_continue?
402
+ FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].keys.each do |k|
403
+ local_config[:project] = {} unless local_config[:project]
404
+ local_config[:project][k.to_sym] = config[k.to_sym]
405
+ end
406
+ if FalkorLib::GitFlow.init?(dir)
407
+ local_config[:gitflow] = {} unless local_config[:gitflow]
408
+ local_config[:gitflow][:branches] = FalkorLib.config[:gitflow][:branches].clone unless local_config[:gitflow][:branches]
409
+ [ :master, :develop ].each do |b|
410
+ local_config[:gitflow][:branches][b.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
411
+ end
412
+ end
413
+ FalkorLib::Config.save(dir, local_config, :local)
414
+ #
292
415
  end # readme
293
416
 
294
417
  ###
@@ -296,17 +419,51 @@ module FalkorLib
296
419
  ##
297
420
  def select_forge(default = :gforge, options = {})
298
421
  forge = FalkorLib::Config::Bootstrap::DEFAULTS[:forge]
299
- ap forge
422
+ #ap forge
300
423
  default_idx = forge.keys.index(default)
301
- default_idx = 0 if default_idx.nil?
424
+ default_idx = 0 if default_idx.nil?
302
425
  v = select_from(forge.map{ |k,v| v[:name] },
303
426
  "Select the Forge hosting the project sources",
304
427
  default_idx+1,
305
428
  forge.keys)
306
- ap v
429
+ v
307
430
  end # select_forge
308
431
 
432
+ ###### select_licence ######
433
+ # Select a given licence for the project
434
+ ##
435
+ def select_licence(default_licence = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata][:license],
436
+ options = {})
437
+ list_license = FalkorLib::Config::Bootstrap::DEFAULTS[:licenses].keys
438
+ idx = list_license.index(default_licence) unless default_licence.nil?
439
+ select_from(list_license,
440
+ 'Select the license index for this project:',
441
+ idx.nil? ? 1 : idx + 1)
442
+ #licence
443
+ end # select_licence
444
+
445
+ ###### get_badge ######
446
+ # Return a Markdown-formatted string for a badge to display, typically in a README.
447
+ # Based on http://shields.io/
448
+ # Supported options:
449
+ # * :style [string] style of the badge, Elligible: ['plastic', 'flat', 'flat-square']
450
+ ##
451
+ def get_badge(subject, status, color = 'blue', options = {})
452
+ st = status.gsub(/-/, '--').gsub(/_/, '__')
453
+ res = "https://img.shields.io/badge/#{subject}-#{st}-#{color}.svg"
454
+ res += "?style=#{options[:style]}" if options[:style]
455
+ res
456
+ end # get_licence_badge
457
+
458
+ ###### get_project_name ######
459
+ # Return a "reasonable" project name from a given [sub] directory i.e. its basename
460
+ ##
461
+ def get_project_name(dir = Dir.pwd, options = {})
462
+ path = normalized_path(dir)
463
+ path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
464
+ File.basename(path)
465
+ end # get_project_name
466
+
309
467
 
310
-
311
468
  end # module Bootstrap
312
469
  end # module FalkorLib
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Mar 2015-02-24 11:04 svarrette>
4
+ ################################################################################
5
+ # Management of the configuration specializations
6
+ #
7
+
8
+ require 'thor'
9
+ require 'falkorlib'
10
+
11
+ module FalkorLib
12
+ module CLI
13
+ class Config #< ::Thor
14
+
15
+
16
+
17
+
18
+
19
+ end # class Config
20
+ end # module CLI
21
+ end # module FalkorLib
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Ven 2015-01-30 15:20 svarrette>
3
+ # Time-stamp: <Mar 2015-02-24 22:03 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require 'thor'
@@ -37,6 +37,11 @@ By default, NAME is '.' meaning that the repository will be initialized in the c
37
37
  :default => 'production', :banner => 'BRANCH', :desc => "Master Branch name for production releases"
38
38
  method_option :develop, :aliases => [ '-b', '--branch', '--devel'],
39
39
  :default => 'devel', :banner => 'BRANCH', :desc => "Branch name for development commits"
40
+ method_option :latex, :aliases => '-l', :type => :boolean, :desc => "Initiate a LaTeX project"
41
+ method_option :gem, :type => :boolean, :desc => "Initiate a Ruby gem project"
42
+ method_option :rvm, :type => :boolean, :desc => "Initiate a RVM-based Ruby project"
43
+ method_option :pyenv, :type => :boolean, :desc => "Initiate a pyenv-based Python project"
44
+ method_option :octopress, :aliases => ['-o', '--www'], :type => :boolean, :desc => "Initiate an Octopress web site"
40
45
  #___________________
41
46
  def repo(name = '.')
42
47
  # _newrepo(name, options)
@@ -90,9 +95,19 @@ These files will be committed in Git to ensure a consistent environment for the
90
95
 
91
96
 
92
97
  ###### readme ######
98
+ method_option :make, :default => true,
99
+ :type => :boolean, :desc => 'Use a Makefile to pilot the repository actions'
100
+ method_option :rake,
101
+ :type => :boolean, :desc => 'Use a Rakefile (and FalkorLib) to pilot the repository actions'
102
+ method_option :latex, :aliases => '-l', :type => :boolean, :desc => "Describe a LaTeX project"
103
+ method_option :gem, :type => :boolean, :desc => "Describe a Ruby gem project"
104
+ method_option :rvm, :type => :boolean, :desc => "Describe a RVM-based Ruby project"
105
+ method_option :pyenv, :type => :boolean, :desc => "Describe a pyenv-based Python project"
106
+ method_option :octopress, :aliases => '--www', :type => :boolean, :desc => "Describe an Octopress web site"
93
107
  #......................................
94
- desc "readme PATH [options]", "Initiate a README file in the PATH directory"
108
+ desc "readme PATH [options]", "Initiate a README file in the PATH directory ('./' by default)"
95
109
  def readme(path = '.')
110
+ ap options
96
111
  FalkorLib::Bootstrap.readme(path, options)
97
112
  end # readme
98
113
  end # class Init
data/lib/falkorlib/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mar 2015-01-20 23:25 svarrette>
3
+ # Time-stamp: <Mar 2015-02-24 11:04 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the CLI
6
6
  #
@@ -43,7 +43,7 @@ module FalkorLib
43
43
  end
44
44
 
45
45
  ###### config ######
46
- desc "config", "Print the current configuration of FalkorLib", :hide => true
46
+ desc "config", "Print the current configuration of FalkorLib" #, :hide => true
47
47
  def config
48
48
  info "Thor options:"
49
49
  puts options.to_yaml
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sam 2015-01-31 23:54 svarrette>
3
+ # Time-stamp: <Mar 2015-02-24 22:09 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require "falkorlib"
@@ -256,12 +256,27 @@ module FalkorLib #:nodoc:
256
256
  end
257
257
 
258
258
  # Store the Hash object as a Yaml file
259
- def store_config(filepath, hash)
260
- File.open( filepath, 'w') do |f|
261
- f.print "# ", File.basename(filepath), "\n"
262
- f.puts "# /!\\ DO NOT EDIT THIS FILE: it has been automatically generated"
263
- f.puts hash.to_yaml
259
+ # Supported options:
260
+ # :header [string]: additional info to place in the header of the (stored) file
261
+ # :no_interaction [boolean]: do not interact
262
+ def store_config(filepath, hash, options = {})
263
+ content = "# " + File.basename(filepath) + "\n"
264
+ content += "# /!\\ DO NOT EDIT THIS FILE: it has been automatically generated\n"
265
+ if options[:header]
266
+ options[:header].split("\n").each { |line| content += "# #{line}" }
264
267
  end
268
+ content += hash.to_yaml
269
+ show_diff_and_write(content, filepath, options)
270
+ # File.open( filepath, 'w') do |f|
271
+ # f.print "# ", File.basename(filepath), "\n"
272
+ # f.puts "# /!\\ DO NOT EDIT THIS FILE: it has been automatically generated"
273
+ # if options[:header]
274
+ # options[:header].split("\n").each do |line|
275
+ # f.puts "# #{line}"
276
+ # end
277
+ # end
278
+ # f.puts hash.to_yaml
279
+ # end
265
280
  end
266
281
 
267
282
  #################################
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Jeu 2015-02-12 11:07 svarrette>
3
+ # Time-stamp: <Mar 2015-02-24 11:58 svarrette>
4
4
  ################################################################################
5
5
  # FalkorLib Configuration
6
6
  #
@@ -89,20 +89,38 @@ module FalkorLib #:nodoc:
89
89
  res
90
90
  end
91
91
 
92
- ###### load_project ######
93
- # Return the local project configuration
92
+ ###### get ######
93
+ # Return the { local | private } FalkorLib configuration
94
+ # Supported options:
95
+ # * :file [string] filename for the local configuration
94
96
  ##
95
- def load_project(dir = Dir.pwd, options = {})
96
- project_file = options[:file] ? options[:file] : FalkorLib.config[:config_files][:local]
97
+ def get(dir = Dir.pwd, type = :local, options = {})
97
98
  path = normalized_path(dir)
98
99
  path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
100
+ raise FalkorLib::Error, "Wrong FalkorLib configuration type" unless FalkorLib.config[:config_files].keys.include?( type.to_sym)
101
+ local_config_file = options[:file] ? options[:file] : File.join(path, FalkorLib.config[:config_files][type.to_sym])
99
102
  res = {}
100
- #if File.exists?( )
101
- end # load_project
103
+ res = load_config( local_config_file ) if File.exists?( local_config_file )
104
+ res
105
+ end # get
102
106
 
107
+ ###### save ######
108
+ # save the { local | private } configuration on YAML format
109
+ # Supported options:
110
+ # * :file [string] filename for the saved configuration
111
+ ##
112
+ def save(dir = Dir.pwd, config = {}, type = :local, options = {})
113
+ path = normalized_path(dir)
114
+ path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
115
+ raise FalkorLib::Error, "Wrong FalkorLib configuration type"unless FalkorLib.config[:config_files].keys.include?( type.to_sym)
116
+ conffile = options[:file] ? options[:file] : File.join(path, FalkorLib.config[:config_files][type.to_sym])
117
+ confdir = File.dirname( conffile )
118
+ unless File.directory?( confdir )
119
+ really_continue? "about to create the configuration directory #{confdir}"
120
+ run %{ mkdir -p #{confdir} }
121
+ end
122
+ store_config(conffile, config)
123
+ end # save
103
124
 
104
125
  end
105
-
106
-
107
-
108
126
  end # module FalkorLib
@@ -19,7 +19,7 @@ module FalkorLib #:nodoc:
19
19
  # MAJOR: Defines the major version
20
20
  # MINOR: Defines the minor version
21
21
  # PATCH: Defines the patch version
22
- MAJOR, MINOR, PATCH = 0, 4, 1
22
+ MAJOR, MINOR, PATCH = 0, 4, 2
23
23
 
24
24
  module_function
25
25
 
@@ -188,7 +188,7 @@ describe FalkorLib::Common do
188
188
  it "#store_config - should store the correct hash to YAML" do
189
189
  file_config = {:domain => "foo.com", :nested => { 'a1' => 2 }}
190
190
  f = Tempfile.new('toto')
191
- store_config(f.path, file_config)
191
+ store_config(f.path, file_config, { :no_interaction => true })
192
192
  copy_file_config = YAML::load_file(f.path)
193
193
  copy_file_config.should == file_config
194
194
  end
@@ -1,67 +1,19 @@
1
+ <% unless (config[:license].empty? or config[:license] == "none") %>
2
+ ## Licence
1
3
 
2
- ## Resources / Complementary information
4
+ This project is released under the terms of the [<%= config[:license] %>](LICENCE) licence.
3
5
 
4
- ### Git
6
+ [![Licence](<%= FalkorLib::Config::Bootstrap::DEFAULTS[:licenses][ config[:license] ][:logo] %>)](<%= FalkorLib::Config::Bootstrap::DEFAULTS[:licenses][ config[:license] ][:url] %>)
7
+ <% end %>
8
+ <% if config[:forge] == :github %>
5
9
 
6
- You should become familiar (if not yet) with Git. Consider these resources:
10
+ ## Contributing
7
11
 
8
- * [Simple Git Guide](http://rogerdudler.github.io/git-guide/)
9
- * [Git book](http://book.git-scm.com/index.html)
10
- * [Github:help](http://help.github.com/mac-set-up-git/)
11
- * [Git reference](http://gitref.org/)
12
-
13
- At least, you shall configure the following variables
14
-
15
- $> git config --global user.name "Your Name Comes Here"
16
- $> git config --global user.email you@yourdomain.example.com
17
- # configure colors
18
- $> git config --global color.diff auto
19
- $> git config --global color.status auto
20
- $> git config --global color.branch auto
21
-
22
- You might want also to configure various aliases to Git command.
23
- Consider my personal [`.gitconfig`](https://github.com/Falkor/dotfiles/blob/master/git/.gitconfig) as an example -- if you decide to use it, simply copy it in your home directory and adapt the `[user]` section.
24
-
25
- ### [git-flow](https://github.com/nvie/gitflow)
26
-
27
- The Git branching model for this repository follows the guidelines of
28
- [gitflow](http://nvie.com/posts/a-successful-git-branching-model/).
29
- In particular, the central repository holds two main branches with an infinite lifetime:
30
-
31
- * `<%= config[:gitflow][:branches][:master] %>`: the *production-ready* branch
32
- * `<%= config[:gitflow][:branches][:develop] %>`: the main branch where the latest developments interviene. This is the *default* branch you get when you clone the repository.
33
-
34
- ### Releasing mechanism
35
-
36
- The operation consisting of releasing a new version of this repository is automated by a set of tasks within the root `<%= config[:rake] ? 'R' : 'M' %>akefile`.
37
-
38
- In this context, a version number have the following format:
39
-
40
- <major>.<minor>.<patch>[-b<build>]
41
-
42
- where:
43
-
44
- * `< major >` corresponds to the major version number
45
- * `< minor >` corresponds to the minor version number
46
- * `< patch >` corresponds to the patching version number
47
- * (eventually) `< build >` states the build number _i.e._ the total number of commits within the `<%= config[:gitflow][:branches][:develop] %>` branch.
48
-
49
- Example: \`1.0.0-b28\`
50
-
51
- The current version number is stored in the root file `VERSION`. __/!\ NEVER MAKE ANY MANUAL CHANGES TO THIS FILE__
52
-
53
- For more information on the version, run:
54
-
55
- $> <%= config[:make] ? 'make versioninfo' : 'rake version:info' %>
56
-
57
- If a new version number such be bumped, you simply have to run:
58
-
59
- $> <%= config[:make] ? 'make start_bump_{major,minor,patch}' : 'rake version:{major,minor,patch}' %>
60
-
61
- This will start the release process for you using `git-flow`.
62
- Once you have finished to commit your last changes, make the release effective by running:
63
-
64
- $> <%= config[:make] ? 'make release' : 'rake version:release' %>
65
-
66
- it will finish the release using `git-flow`, create the appropriate tag in the `<%= config[:gitflow][:branches][:master] %>` branch and merge all things the way they should be.
12
+ That's quite simple:
67
13
 
14
+ 1. [Fork](https://help.github.com/articles/fork-a-repo/) it
15
+ 2. Create your own feature branch (`git checkout -b my-new-feature`)
16
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
17
+ 4. Push to the branch (`git push origin my-new-feature`)
18
+ 5. Create a new [Pull Request](https://help.github.com/articles/using-pull-requests/)
19
+ <% end %>
@@ -1,17 +1,36 @@
1
1
  -*- mode: markdown; mode: visual-line; fill-column: 80 -*-
2
- `<%= config[:filename] %>`
3
2
 
4
- Time-stamp: <Lun 2015-01-26 10:39 svarrette>
3
+ <% unless (config[:license].empty? or config[:license] == "none") %>
4
+ [![Licence](<%= FalkorLib::Bootstrap::get_badge("license", config[:license], 'blue') %>)](<%= FalkorLib::Config::Bootstrap::DEFAULTS[:licenses][ config[:license] ][:url] %>)
5
+ <% end %>
5
6
 
6
- ------------------
7
+ Time-stamp: <Mar 2015-02-24 21:23 svarrette>
7
8
 
8
- # <%= config[:shortname].capitalize %>
9
+ <%= ::Artii::Base.new().asciify( config[:name] ).split("\n").join("\n ") %>
10
+ Copyright (c) <%= Time.now.year %> <%= config[:author] %> <<%= config[:mail] %>>
9
11
 
10
12
  <%= config[:summary] %>
11
13
 
12
- Copyright (c) <%= Time.now.year %> <%= config[:author] %> <<%= config[:mail] %>>
14
+ <% unless (config[:license].empty? or config[:license] == "none") %>
15
+ * [<%= config[:license] %> Licence](<%= FalkorLib::Config::Bootstrap::DEFAULTS[:licenses][ config[:license] ][:url] %>)
16
+ <% end %>
17
+ * [Sources](<%= config[:source] %>)
13
18
 
14
19
  ## Synopsis
15
20
 
16
21
  <%= config[:description] %>
17
22
 
23
+ ## Installation
24
+
25
+ This repository is hosted on [<%= FalkorLib::Config::Bootstrap::DEFAULTS[:forge][ config[:forge].to_sym ][:name] %>](<%= config[:project_page] %>).
26
+
27
+ **`/!\ IMPORTANT`**: Once cloned, initiate your local copy of the repository by running:
28
+
29
+ $> cd <%= config[:name].downcase %>
30
+ <% if options[:make] %>
31
+ $> make setup
32
+ <% else %>
33
+ $> gem install rake # the very first time
34
+ $> rake setup
35
+ <% end %>
36
+
@@ -0,0 +1,18 @@
1
+ ## <%= config[:name] %> Gem Installation
2
+
3
+ You'll typically want to install <%= config[:name] %> using [Bundler](http://bundler.io/).
4
+ To do this, simply add this line to your application's `Gemfile`:
5
+
6
+ gem '<%= config[:name].downcase %>'
7
+
8
+ And then execute:
9
+
10
+ $> bundle
11
+
12
+ Or install it yourself as:
13
+
14
+ $> gem install <%= config[:name].downcase %>
15
+
16
+ **Note** you probably wants to do the above within an isolated environment. See
17
+ below for some explanation on this setup.
18
+
@@ -0,0 +1,44 @@
1
+
2
+ ## Resources
3
+
4
+ ### Git
5
+
6
+ This repository make use of [Git](http://git-scm.com/) such that you should have
7
+ it installed on your working machine:
8
+
9
+ $> apt-get install git-core # On Debian-like systems
10
+ $> yum install git # On CentOS-like systems
11
+ $> brew install git # On Mac OS, using [Homebrew](http://mxcl.github.com/homebrew/)
12
+ $> port install git # On Mac OS, using MacPort
13
+
14
+ Consider these resources to become more familiar (if not yet) with Git:
15
+
16
+ * [Simple Git Guide](http://rogerdudler.github.io/git-guide/)
17
+ * [Git book](http://book.git-scm.com/index.html)
18
+ * [Github:help](http://help.github.com/mac-set-up-git/)
19
+ * [Git reference](http://gitref.org/)
20
+
21
+ At least, you shall configure the following variables
22
+
23
+ $> git config --global user.name "Your Name Comes Here"
24
+ $> git config --global user.email you@yourdomain.example.com
25
+ # configure colors
26
+ $> git config --global color.diff auto
27
+ $> git config --global color.status auto
28
+ $> git config --global color.branch auto
29
+
30
+ Note that you can create git command aliases in `~/.gitconfig` as follows:
31
+
32
+ [alias]
33
+ up = pull origin
34
+ pu = push origin
35
+ st = status
36
+ df = diff
37
+ ci = commit -s
38
+ br = branch
39
+ w = whatchanged --abbrev-commit
40
+ ls = ls-files
41
+ gr = log --graph --oneline --decorate
42
+ amend = commit --amend
43
+
44
+ Consider my personal [`.gitconfig`](https://github.com/Falkor/dotfiles/blob/master/git/.gitconfig) as an example -- if you decide to use it, simply copy it in your home directory and adapt the `[user]` section.
@@ -0,0 +1,46 @@
1
+
2
+ ### [Git-flow](https://github.com/nvie/gitflow)
3
+
4
+ The Git branching model for this repository follows the guidelines of
5
+ [gitflow](http://nvie.com/posts/a-successful-git-branching-model/).
6
+ In particular, the central repository holds two main branches with an infinite lifetime:
7
+
8
+ * `<%= FalkorLib::GitFlow.branches(:master) %>`: the *production-ready* branch
9
+ * `<%= FalkorLib::GitFlow.branches(:develop) %>`: the main branch where the latest developments interviene. This is the *default* branch you get when you clone the repository.
10
+
11
+ Thus you are more than encouraged to install the [git-flow](https://github.com/nvie/gitflow) extensions following the [installation procedures](https://github.com/nvie/gitflow/wiki/Installation) to take full advantage of the proposed operations. The associated [bash completion](https://github.com/bobthecow/git-flow-completion) might interest you also.
12
+
13
+ ### Releasing mechanism
14
+
15
+ The operation consisting of releasing a new version of this repository is automated by a set of tasks within the root `<%= config[:rake] ? 'R' : 'M' %>akefile`.
16
+
17
+ In this context, a version number have the following format:
18
+
19
+ <major>.<minor>.<patch>[-b<build>]
20
+
21
+ where:
22
+
23
+ * `< major >` corresponds to the major version number
24
+ * `< minor >` corresponds to the minor version number
25
+ * `< patch >` corresponds to the patching version number
26
+ * (eventually) `< build >` states the build number _i.e._ the total number of commits within the `<%= FalkorLib::GitFlow.branches(:develop) %>` branch.
27
+
28
+ Example: \`1.0.0-b28\`
29
+
30
+ The current version number is stored in the root file `VERSION`. __/!\ NEVER MAKE ANY MANUAL CHANGES TO THIS FILE__
31
+
32
+ For more information on the version, run:
33
+
34
+ $> <%= config[:make] ? 'make versioninfo' : 'rake version:info' %>
35
+
36
+ If a new version number such be bumped, you simply have to run:
37
+
38
+ $> <%= config[:make] ? 'make start_bump_{major,minor,patch}' : 'rake version:{major,minor,patch}' %>
39
+
40
+ This will start the release process for you using `git-flow`.
41
+ Once you have finished to commit your last changes, make the release effective by running:
42
+
43
+ $> <%= config[:make] ? 'make release' : 'rake version:release' %>
44
+
45
+ it will finish the release using `git-flow`, create the appropriate tag in the `<%= FalkorLib::GitFlow.branches(:master) %>` branch and merge all things the way they should be.
46
+
@@ -0,0 +1,10 @@
1
+ ## Compilation of the LaTeX sources
2
+
3
+ The compilation of this document relies on [GNU Make](http://www.gnu.org/software/make/), and you should have a complete working LaTeX environment (including the `pdflatex` compiler).
4
+
5
+ To compile this document, simply run:
6
+
7
+ $> make
8
+
9
+ This shall generate the PDF version of the document
10
+
@@ -0,0 +1,22 @@
1
+ ### Ruby stuff: RVM, Rakefile and Ruby gems
2
+
3
+ The various operations that can be conducted from this repository are piloted from a [`Rakefile`](https://github.com/ruby/rake) and assumes you have a running [Ruby](https://www.ruby-lang.org/en/) installation. You'll also need [Ruby Gems](https://rubygems.org/) to facilitate the installation of ruby libraries.
4
+
5
+ $> apt-get install ruby rubygems # On Debian-like systems
6
+
7
+ Install the [rake](https://rubygems.org/gems/rake) gem as follows:
8
+
9
+ $> gem install rake
10
+
11
+ In order to have a consistent environment among the collaborators of this project, [Bundler](http://bundler.io/) is also used. Configuration of [Bundler](http://bundler.io/) is made via the [`Gemfile[.lock]` files](http://bundler.io/v1.3/gemfile.html).
12
+
13
+ Last but not least, I like to work on [Sandboxed environments](https://hpc.uni.lu/blog/2014/create-a-sandboxed-python-slash-ruby-environment/) and a great tool for that is [RVM](https://rvm.io/).
14
+ [RVM](https://rvm.io/) gives you compartmentalized independent ruby setups.
15
+ This means that ruby, gems and irb are all separate and self-contained - from the system, and from each other. Sandboxing with [RVM](https://rvm.io/) is straight-forward via the [notion of gemsets](https://rvm.io/gemsets) and is managed via the `.ruby-{version,gemset}` files.
16
+
17
+ If things are fine, you should be able to access the list of available tasks by running:
18
+
19
+ $> rake -T
20
+
21
+ You probably want to activate the bash-completion for rake tasks.
22
+ I personally use the one provided [here](https://github.com/ai/rake-completion).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falkorlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -184,6 +184,20 @@ dependencies:
184
184
  - - ">="
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0.19'
187
+ - !ruby/object:Gem::Dependency
188
+ name: artii
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '2.1'
194
+ type: :runtime
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '2.1'
187
201
  - !ruby/object:Gem::Dependency
188
202
  name: bundler
189
203
  requirement: !ruby/object:Gem::Requirement
@@ -336,6 +350,7 @@ files:
336
350
  - lib/falkorlib/bootstrap.rb
337
351
  - lib/falkorlib/bootstrap/base.rb
338
352
  - lib/falkorlib/cli.rb
353
+ - lib/falkorlib/cli/config.rb
339
354
  - lib/falkorlib/cli/new.rb
340
355
  - lib/falkorlib/common.rb
341
356
  - lib/falkorlib/config.rb
@@ -375,6 +390,11 @@ files:
375
390
  - spec/spec_helper.rb
376
391
  - templates/README/footer_readme.erb
377
392
  - templates/README/header_readme.erb
393
+ - templates/README/readme_gem.erb
394
+ - templates/README/readme_git.erb
395
+ - templates/README/readme_gitflow.erb
396
+ - templates/README/readme_latex.erb
397
+ - templates/README/readme_rvm.erb
378
398
  - templates/puppet/modules/.gitignore
379
399
  - templates/puppet/modules/.vagrant_init.rb
380
400
  - templates/puppet/modules/Gemfile