falkorlib 0.7.18 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9ac26908e8ce646855d75dcb16306238e5d076a
4
- data.tar.gz: 5bc7b5df10fa94899039eb60ec0734fc544a6872
3
+ metadata.gz: 293f8e0a679cbb41fe60088ac8c5af3733314836
4
+ data.tar.gz: 3dfb1d70887c8a85970e17f953ab587669eb7939
5
5
  SHA512:
6
- metadata.gz: 89e9b34f9c11dbfbeb6f4bcddd4a2cf85ae86038fc601f34f30c3c3822d258cd486c2fe0f907c0ffcdadd0af11691e1c4d026d159203b35915a42653ecf9691d
7
- data.tar.gz: 0af69b51808b3a84741ebf1a6f00baefe038904b23920058253c2e89ac29fab3ce87d2a47ea2456f7a08b201cc103ae09036bf67ed02877f9ca4323cc13a023b
6
+ metadata.gz: d8757a823057832f31e7a5f09155bb2d41df3275a1584a947bb68333d36fbd99cdcb7ccbf130274ccf645fc2003869f6af454090c33f0050b14a21b1cfc7284f
7
+ data.tar.gz: 4119b57d72bc6ede622aebda462777c7c7d6ef4a852c95a1c609e5d390f12c532b65765c1c088ac4db4e3126de0b3867fa0c46fe3297bb5d0f39cbd87c7ddad1
@@ -23,15 +23,18 @@ addons:
23
23
  - unzip
24
24
  - git
25
25
  - git-flow
26
- - git-crypt
26
+ # - git-crypt
27
27
  hosts:
28
28
  - travis.dev
29
29
  before_install:
30
30
  - gem install bundler
31
31
  rvm:
32
- - 2.0.0
32
+ # - 2.0.0
33
33
  - 2.1
34
34
  - 2.2
35
+ - 2.3
36
+ - 2.4
37
+ - 2.5
35
38
  env:
36
39
  global:
37
40
  - TRAVIS_CI_RUN=true
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.7.18)
4
+ falkorlib (0.8.1)
5
5
  activesupport (~> 4.0)
6
6
  artii (>= 2.1)
7
7
  awesome_print (~> 1.2)
data/README.md CHANGED
@@ -2,10 +2,8 @@
2
2
 
3
3
  [![Version ](https://badge.fury.io/rb/falkorlib.png)](http://badge.fury.io/rb/falkorlib)
4
4
  [![Build Status](https://travis-ci.org/Falkor/falkorlib.png)](https://travis-ci.org/Falkor/falkorlib)
5
- [![Code Climate](https://codeclimate.com/github/Falkor/falkorlib.png)](https://codeclimate.com/github/Falkor/falkorlib)
6
- [![Test Coverage](https://codeclimate.com/github/Falkor/falkorlib/coverage.png)](https://codeclimate.com/github/Falkor/falkorlib)
7
- [![Inline docs ](http://inch-ci.org/github/Falkor/falkorlib.svg)](http://inch-ci.org/github/Falkor/falkorlib)
8
- [![Gittip](http://img.shields.io/gittip/Falkor.svg)](http://gittip.com/Falkor)
5
+ [![Code Climate](https://codeclimate.com/github/Falkor/falkorlib.png)](https://codeclimate.com/github/Falkor/falkorlib) [![Test Coverage](https://api.codeclimate.com/v1/badges/9f1c7762f29572b3f8f0/test_coverage)](https://codeclimate.com/github/Falkor/falkorlib/test_coverage)
6
+ [![Inline docs ](http://inch-ci.org/github/Falkor/falkorlib.svg)](http://inch-ci.org/github/Falkor/falkorlib)[![Liberapay receiving](https://img.shields.io/liberapay/receives/Falkor.svg)](https://liberapay.com/Falkor/donate)
9
7
 
10
8
  _____ _ _ _ _ _
11
9
  | ___|_ _| | | _____ _ __| | (_) |__
@@ -14,7 +12,7 @@
14
12
  |_| \__,_|_|_|\_\___/|_| |_____|_|_.__/
15
13
 
16
14
 
17
- Copyright (c) 2012-2017 Sebastien Varrette <Sebastien.Varrette@uni.lu>
15
+ Copyright (c) 2012-2018 Sebastien Varrette <Sebastien.Varrette@uni.lu>
18
16
 
19
17
  Sebastien Varrette aka Falkor's Common library to share Ruby code, `{rake,cap}`
20
18
  tasks and project templates
@@ -46,7 +44,7 @@ Or install it yourself as:
46
44
  This library features two aspects
47
45
 
48
46
  * a binary `falkor` I use daily to bootstrap and operate with the projects I'm
49
- working one
47
+ working one -- see below for an brief overview of the provided commands
50
48
 
51
49
  * A set of toolbox functions / components I'm using everywhere in my Ruby
52
50
  developments, more specifically a set of modules:
@@ -98,7 +96,7 @@ This library features two aspects
98
96
 
99
97
  require "falkorlib/tasks/<object>" # OR require "falkorlib/<object>_tasks"
100
98
 
101
- ### `FalkorLib` Ruby Modules / Classes Documentation
99
+ ## `FalkorLib` Ruby Modules / Classes Documentation
102
100
 
103
101
  [Online documentation](https://rubygems.org/gems/falkorlib) is a available.
104
102
  Yet to get the latest version, you might want to run
@@ -111,7 +109,65 @@ Statistics on the documentation generation (in particular *non*-documented compo
111
109
 
112
110
  $> rake yard:stats
113
111
 
114
- ### Overview of the implemented Rake tasks
112
+ ## Overview of the `falkor` CLI
113
+
114
+ This library comes with a CLI `falkor`, providing the following [sub] commands.
115
+
116
+ __Base commands__
117
+
118
+ | Command | Description |
119
+ |------------------------------------|-------------------------------------------------------------------|
120
+ | `falkor --version, -V` | Print the version number of Falkor[Lib] |
121
+ | `falkor help [COMMAND]` | Describe available commands or one specific command |
122
+ | `falkor gitcrypt <PATH> [options]` | Initialize git-crypt for the current repository |
123
+ | `falkor init <PATH> [options]` | Bootstrap a Git[flow] Repository |
124
+ | `falkor mkdocs [options]` | Initialize mkdocs for the current project |
125
+ | `falkor motd <PATH> [options]` | Initiate a 'motd' file - message of the day |
126
+ | `falkor vagrant [options]` | Initialize vagrant for the current project |
127
+
128
+ __`falkor link <type> [path]`__
129
+
130
+ Initialize a special symlink in `<path>` (the current directory by default)
131
+
132
+ | Command | Description |
133
+ |---------------------------------|-----------------------------------------------------------------------------------------------------------|
134
+ | `falkor link help [COMMAND]` | Get help on the corresponding sub command |
135
+ | `falkor link make [options]` | Create a symlink to one of [Falkor's Makefile](https://github.com/Falkor/Makefiles), set as Git submodule |
136
+ | `falkor link rootdir [options]` | Create a symlink `.root` which targets the root of the repository |
137
+
138
+ __`falkor new <stuff> [path]`__
139
+
140
+ Initialize the directory `<path>` (the current directory by default) with one of FalkorLib's template(s)
141
+
142
+ | Command | Description |
143
+ |-----------------------------------------|----------------------------------------------------------------|
144
+ | `falkor new help [COMMAND]` | Describe subcommands or one specific subcommand |
145
+ | `falkor new article [options]` | Bootstrap a LaTeX Article |
146
+ | `falkor new letter [options]` | LaTeX-based letter |
147
+ | `falkor new license [options]` | Generate an Open-Source License for your project |
148
+ | `falkor new make [options]` | Initiate one of Falkor's Makefile |
149
+ | `falkor new pyenv PATH [options]` | Initialize pyenv/direnv |
150
+ | `falkor new readme PATH [options]` | Initiate a README file in the PATH directory ('./' by default) |
151
+ | `falkor new repo NAME [options]` | Bootstrap a Git Repository |
152
+ | `falkor new rvm PATH [options]` | Initialize RVM |
153
+ | `falkor new slides [options]` | Bootstrap LaTeX Beamer slides |
154
+ | `falkor new trash PATH` | Add a Trash directory |
155
+ | `falkor new versionfile PATH [options]` | initiate a VERSION file |
156
+
157
+ __`falkor make <type> [path]`__
158
+
159
+ | Command | Description |
160
+ |-----------------------------|-------------------------------------------------------|
161
+ | `falkor new help [COMMAND]` | Describe subcommands or one specific subcommand |
162
+ | `falkor make generic` | Symlink to Generic Makefile for sub directory |
163
+ | `falkor make gnuplot` | Symlink to a Makefile to compile GnuPlot scripts |
164
+ | `falkor make latex` | Symlink to a Makefile to compile LaTeX documents |
165
+ | `falkor make repo` | Create a root Makefile piloting repository operations |
166
+
167
+
168
+ A ZSH completion files is also maintained for this command, you'll find it in [`completion/_falkor`](completion/_falkor)
169
+
170
+ ## Overview of the implemented Rake tasks
115
171
 
116
172
  You can find the list of implemented Rake tasks (detailed below) in the
117
173
  `lib/falkorlib/*_tasks.rb` files
@@ -1,7 +1,7 @@
1
1
  #compdef falkor
2
2
  ########################################################################################
3
3
  # -*- mode:sh; -*-
4
- # Time-stamp: <Thu 2018-11-08 23:50 svarrette>
4
+ # Time-stamp: <Wed 2018-11-21 11:53 svarrette>
5
5
  #
6
6
  # ZSH completion for [FalkorLib](https://github.com/Falkor/falkorlib)
7
7
  #
@@ -105,16 +105,17 @@ __falkor_new()
105
105
  {
106
106
  local -a _falkor_new_cmds
107
107
  _falkor_new_cmds=(
108
- 'repo:Bootstrap a Git Repository with my favorite git-flow layout'
109
108
  'article:Bootstrap a LaTeX Article'
110
109
  'letter:LaTeX-based letter'
110
+ 'license:Generate an Open-Source License for your project'
111
+ 'make:Initiate one of Falkor Makefile'
112
+ 'pyenv:Initialize pyenv/direnv'
113
+ 'readme:Initiate a README file in the PATH directory (''./'' by default)'
114
+ 'repo:Bootstrap a Git Repository with my favorite git-flow layout'
115
+ 'rvm:Initialize RVM'
111
116
  'slides:Bootstrap LaTeX Beamer slides'
112
117
  'trash:Add a Trash directory for your LaTeX project'
113
- 'rvm:Initialize RVM'
114
118
  'versionfile:initiate a VERSION file'
115
- 'license:Generate an Open-Source License for your project'
116
- 'motd:Initiate a ''motd'' file - message of the day'
117
- 'readme:Initiate a README file in the PATH directory (''./'' by default)'
118
119
  'help:Describe subcommands or one specific subcommand'
119
120
  )
120
121
 
@@ -161,6 +162,16 @@ __falkor_new()
161
162
  {--images,-i,--img}'[Makefile to optimize images]' \
162
163
  {--src,-s}'[Path to Falkor''s Makefile for latex_src]' && ret=0
163
164
  ;;
165
+ (pyenv)
166
+ _arguments -C \
167
+ '--python[Python version to configure]:version' \
168
+ '--virtualenv[Virtualenv to configure for this directory]:env' \
169
+ '*: :->path' && ret=0
170
+ case "$state" in
171
+ (path)
172
+ _directories ;;
173
+ esac
174
+ ;;
164
175
  (readme)
165
176
  _arguments -C \
166
177
  '--make[Use a Makefile to pilot the repository actions]' \
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Fri 2018-04-27 13:46 svarrette>
3
+ # Time-stamp: <Sun 2018-11-11 18:03 svarrette>
4
4
  ################################################################################
5
5
  # Management of Bootstrapping operations
6
6
 
@@ -11,11 +11,12 @@ module FalkorLib #:nodoc:
11
11
  end # module FalkorLib
12
12
 
13
13
  require "falkorlib/bootstrap/base"
14
- require "falkorlib/bootstrap/link"
15
- require "falkorlib/bootstrap/ruby"
16
14
  require "falkorlib/bootstrap/git"
17
15
  require "falkorlib/bootstrap/latex"
16
+ require "falkorlib/bootstrap/link"
18
17
  require "falkorlib/bootstrap/mkdocs"
18
+ require "falkorlib/bootstrap/ruby"
19
+ require "falkorlib/bootstrap/python"
19
20
  require "falkorlib/bootstrap/vagrant"
20
21
 
21
22
  #require "falkorlib/bootstrap/repo"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Thu 2018-11-08 17:47 svarrette>
3
+ # Time-stamp: <Thu 2018-11-29 11:39 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Bootstrapping operations
6
6
  #
@@ -183,7 +183,7 @@ module FalkorLib
183
183
  gitflow_branches = FalkorLib::Config::GitFlow::DEFAULTS[:branches]
184
184
  if FalkorLib::GitFlow.init?(path)
185
185
  [ :master, :develop ].each do |b|
186
- gitflow_branches[t.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
186
+ gitflow_branches[b.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
187
187
  end
188
188
  end
189
189
  unless options.nil?
@@ -0,0 +1,169 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Wed 2018-11-21 11:46 svarrette>
4
+ ################################################################################
5
+ # Interface for the main python 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
+
20
+ module FalkorLib
21
+ module Bootstrap #:nodoc:
22
+
23
+ module_function
24
+
25
+ ###### pyenv ######
26
+ # Initialize pyenv/direnv in the current directory
27
+ # Supported options:
28
+ # * :force [boolean] force overwritting
29
+ # * :python [string] Python version to configure for pyenv
30
+ # * :virtualenv [string] Python virtualenv name to configure
31
+ # * :versionfile [string] Python Version file
32
+ # * :virtualenvfile [string] Python virtualenv file (specifying its name)
33
+ # * :direnvfile [string] Direnv configuration file
34
+ # * :commit [boolean] Commit the changes NOT YET USED
35
+ # * :global [boolean] Also configure the global direnv configuration
36
+ # . in ~/.config/direnv
37
+ ##
38
+ def pyenv(dir = Dir.pwd, options = {})
39
+ info "Initialize Pyenv-virtualenv and direnv setup in '#{dir}'"
40
+ ap options if options[:debug]
41
+ path = normalized_path(dir)
42
+ unless File.directory?(path)
43
+ warning "The directory '#{path}' does not exist yet."
44
+ warning 'Do you want to create (and git init) this directory?'
45
+ really_continue?
46
+ run %(mkdir -p #{path})
47
+ end
48
+ use_git = FalkorLib::Git.init?(path)
49
+ rootdir = (use_git) ? FalkorLib::Git.rootdir(path) : path
50
+ config = FalkorLib::Config::DEFAULTS[:pyenv].clone
51
+ files = {} # list of files to create
52
+ exit_status = 1
53
+ # Specialize configuration
54
+ [:versionfile, :virtualenvfile, :direnvfile].each do |k|
55
+ #config[k] = (options[k]) ? options[k] : ask("\t" + Kernel.format("%-20s", "#{k.to_s.capitalize.gsub!(/file/, ' filename')}"), config[k])
56
+ config[k] = options[k] if options[k]
57
+ if File.exist?( File.join( rootdir, config[k] ))
58
+ content = `cat #{File.join( rootdir, config[k])}`.chomp
59
+ warning "The python/pyenv file '#{config[k]}' already exists"
60
+ warning " (with content '#{content}')" unless k == :direnvfile
61
+ next unless options[:force]
62
+ warning "... and it WILL BE overwritten"
63
+ end
64
+ files[k] = config[k]
65
+ end
66
+ # ==== Python version ===
67
+ unless files[:versionfile].nil?
68
+ file = File.join(rootdir, config[:versionfile])
69
+ config[:version] = FalkorLib.config[:pyenv][:version]
70
+ if options[:python]
71
+ config[:version] = options[:python]
72
+ else
73
+ config[:version] = select_from(FalkorLib.config[:pyenv][:versions],
74
+ "Select Python pyenv version to configure for this directory",
75
+ (FalkorLib.config[:pyenv][:versions].find_index(FalkorLib.config[:pyenv][:version]) + 1))
76
+ end
77
+ info " ==> configuring pyenv version file '#{config[:versionfile]}' for python version '#{config[:version]}'"
78
+ File.open(file, 'w') do |f|
79
+ f.puts config[:version]
80
+ end
81
+ exit_status = (File.exist?(file) && (`cat #{file}`.chomp == config[:version])) ? 0 : 1
82
+ FalkorLib::Git.add( file ) if use_git
83
+ end
84
+ # === Virtualenv ===
85
+ if files[:virtualenvfile]
86
+ file = File.join(rootdir, files[:virtualenvfile])
87
+ default_virtualenv = File.basename(rootdir)
88
+ default_virtualenv = `cat #{file}`.chomp if File.exist?( file )
89
+ g = (options[:virtualenv]) ? options[:virtualenv] : ask("Enter virtualenv name for this directory", default_virtualenv)
90
+ info " ==> configuring virtualenv file '#{files[:virtualenvfile]}' with content '#{g}'"
91
+ File.open( File.join(rootdir, files[:virtualenvfile]), 'w') do |f|
92
+ f.puts g
93
+ end
94
+ exit_status = (File.exist?(file) && (`cat #{file}`.chomp == g)) ? 0 : 1
95
+ FalkorLib::Git.add(File.join(rootdir, files[:virtualenvfile])) if use_git
96
+ end
97
+ # ==== Global direnvrc ====
98
+ if options and options[:global]
99
+ direnvrc = config[:direnvrc]
100
+ direnvrc_dir = File.dirname( direnvrc )
101
+ unless File.directory?( direnvrc_dir )
102
+ warning "The directory '#{direnvrc_dir}' meant for hosting the globa direnv settings does not exist"
103
+ warning "About to create this directory"
104
+ really_continue?
105
+ run %(mkdir -p #{direnvrc_dir})
106
+ end
107
+ if (!File.exists?(direnvrc) or options[:force])
108
+ templatedir = File.join( FalkorLib.templates, 'direnv')
109
+ info " ==> configuring Global direnvrc #{files[:direnvrc]}"
110
+ init_from_template(templatedir, direnvrc_dir, config,
111
+ :no_interaction => true,
112
+ :no_commit => true,
113
+ )
114
+ end
115
+ end
116
+ # ==== Local Direnv setup and .envrc ===
117
+ if files[:direnvfile]
118
+ envrc = File.join(rootdir, files[:direnvfile])
119
+ setup = File.join(rootdir, 'setup.sh')
120
+ if (!File.exists?(setup) or options[:force])
121
+ templatedir = File.join( FalkorLib.templates, 'python')
122
+ info " ==> configuring local direnv setup and #{files[:direnvfile]}"
123
+ init_from_template(templatedir, rootdir, config,
124
+ :no_interaction => true,
125
+ :no_commit => true,
126
+ )
127
+ end
128
+ if (!File.exists?(envrc) or options[:force])
129
+ run %(ln -s setup.sh #{envrc})
130
+ end
131
+ FalkorLib::Git.add( envrc ) if use_git
132
+ FalkorLib::Git.add( setup ) if use_git
133
+ end
134
+ # Last motd
135
+ warning <<-MOTD
136
+
137
+ ----------------------------------------------------------------------------
138
+ Direnv/Pyenv configured for #{path}.
139
+ For more detailed instructions, see
140
+ https://varrette.gforge.uni.lu/tutorials/pyenv.html
141
+
142
+ Now you probably need to perform the following actions:
143
+
144
+ cd #{path}
145
+ direnv allow .
146
+ # Eventually install the pyenv version
147
+ pyenv install #{config[:version]}
148
+
149
+ You can then enjoy your newly configured sand-boxed environment
150
+
151
+ pip list
152
+ pip install numpy scipy matplotlib
153
+ pip install jupyter ipykernel
154
+ python -m ipykernel install --user --name=$(head .python-virtualenv)
155
+ jupyter notebook
156
+
157
+ To freeze your environment to pass it around
158
+
159
+ pip freeze -l # List all the pip packages used in the virtual environment
160
+ pip freeze -l > requirements.txt # Dump it to a requirements file
161
+ git add requirements.txt
162
+ git commit -s -m 'Python package list' requirements.txt
163
+
164
+ MOTD
165
+ exit_status.to_i
166
+ end # rvm
167
+
168
+ end # module Bootstrap
169
+ end # module FalkorLib
@@ -1,8 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sat 2016-11-12 02:32 svarrette>
3
+ # Time-stamp: <Sun 2018-11-11 18:03 svarrette>
4
4
  ################################################################################
5
- # Interface for the main Bootstrapping operations
5
+ # Interface for the bootstrapping RVM/ruby operations
6
6
  #
7
7
 
8
8
  require "falkorlib"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Thu 2018-11-08 17:01 svarrette>
3
+ # Time-stamp: <Wed 2018-11-21 11:45 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require 'thor'
@@ -43,12 +43,12 @@ By default, NAME is '.' meaning that the repository will be initialized in the c
43
43
  method_option :make, :default => true, :type => :boolean, :desc => 'Use a Makefile to pilot the repository actions'
44
44
  method_option :rake, :type => :boolean, :desc => 'Use a Rakefile (and FalkorLib) to pilot the repository actions'
45
45
  method_option :interactive, :aliases => '-i', :default => true,
46
- :type => :boolean, :desc => "Interactive mode, in particular to confirm Gitflow branch names"
46
+ :type => :boolean, :desc => "Interactive mode, in particular to confirm Gitflow branch names"
47
47
  method_option :remote_sync, :aliases => '-r',
48
- :type => :boolean, :desc => "Operate a git remote synchronization with remote. By default, all commits stay local"
48
+ :type => :boolean, :desc => "Operate a git remote synchronization with remote. By default, all commits stay local"
49
49
  method_option :master, :default => 'production', :banner => 'BRANCH', :desc => "Master Branch name for production releases"
50
50
  method_option :develop, :aliases => [ '-b', '--branch', '--devel'],
51
- :default => 'devel', :banner => 'BRANCH', :desc => "Branch name for development commits"
51
+ :default => 'devel', :banner => 'BRANCH', :desc => "Branch name for development commits"
52
52
  #method_option :latex, :aliases => '-l', :type => :boolean, :desc => "Initiate a LaTeX project"
53
53
  #method_option :gem, :type => :boolean, :desc => "Initiate a Ruby gem project"
54
54
  method_option :ruby, :default => '2.1.10', :desc => "Ruby version to configure for RVM"
@@ -77,7 +77,7 @@ By default, NAME is '.' meaning that the repository will be initialized in the c
77
77
  desc "article [options]", "Bootstrap a LaTeX Article"
78
78
  #___________________
79
79
  def article(path = Dir.pwd)
80
- FalkorLib::Bootstrap.latex(path, :article, options)
80
+ FalkorLib::Bootstrap.latex(path, :article, options)
81
81
  end # article
82
82
 
83
83
 
@@ -103,17 +103,17 @@ By default, NAME is '.' meaning that the repository will be initialized in the c
103
103
 
104
104
  ##### make ######
105
105
  method_option :repo, :type => :boolean, :aliases => '-r',
106
- :desc => "Create a root Makefile piloting repository operations"
106
+ :desc => "Create a root Makefile piloting repository operations"
107
107
  method_option :latex, :type => :boolean, :aliases => '-l',
108
- :desc => "Makefile to compile LaTeX documents"
108
+ :desc => "Makefile to compile LaTeX documents"
109
109
  method_option :gnuplot, :type => :boolean, :aliases => ['--plot', '-p'],
110
- :desc => "Makefile to compile GnuPlot scripts"
110
+ :desc => "Makefile to compile GnuPlot scripts"
111
111
  method_option :generic, :type => :boolean, :aliases => '-g',
112
- :desc => "Generic Makefile for sub directory"
112
+ :desc => "Generic Makefile for sub directory"
113
113
  method_option :images, :type => :boolean, :aliases => [ '-i', '--img' ],
114
- :desc => "Makefile to optimize images"
114
+ :desc => "Makefile to optimize images"
115
115
  method_option :src, :type => :boolean, :aliases => [ '--src', '-s' ],
116
- :desc => "Path to Falkor's Makefile for latex_src"
116
+ :desc => "Path to Falkor's Makefile for latex_src"
117
117
  #......................................
118
118
  desc "make [options]", "Initiate one of Falkor's Makefile"
119
119
  def make(dir = Dir.pwd)
@@ -127,6 +127,39 @@ By default, NAME is '.' meaning that the repository will be initialized in the c
127
127
  end # make
128
128
 
129
129
 
130
+ ###### pyenv ######
131
+ desc "pyenv PATH [options]", "Initialize pyenv/direnv"
132
+ long_desc <<-PYENV_LONG_DESC
133
+ Initialize pyenv/direnv for the current directory (or at the root directory of the Git repository)
134
+ according to the configuration suggested on https://varrette.gforge.uni.lu/tutorials/pyenv.html
135
+
136
+ It consists of the following files:
137
+ \x5 * `.python-version`: Project file hosting a single line for the expected python version
138
+ \x5 * `.python-virtualenv`: Virtualenv file hosting a single line for the virtualenv to use for this project
139
+ \x5 * `.envrc` (symlink to `setup.sh`): Direnv configuration meant to automatically activate the configured virtualenv when entering the directory (and deactivate when quitting).
140
+
141
+ These files will be committed in Git to ensure a consistent environment for the project.
142
+
143
+ Eventually (with the --global option enabled by default), the global direnvrc file will be setup for you (in `~/.config/direnv/direnvrc`)
144
+ PYENV_LONG_DESC
145
+ method_option :force, :aliases => '-f',
146
+ :type => :boolean, :desc => 'Force overwritting the pyenv/direnv config'
147
+ method_option :python, :banner => 'VERSION', :aliases => [ '--pyenv', '-p' ],
148
+ :desc => 'Python version to configure / install for pyenv'
149
+ method_option :versionfile, :banner => 'FILE',
150
+ :default => FalkorLib.config[:pyenv][:versionfile], :desc => 'Python Version file'
151
+ method_option :virtualenv, :aliases => [ '--env', '-e' ],
152
+ :desc => 'Python virtualenv name to configure for this directory'
153
+ method_option :virtualenvfile, :banner => 'FILE',
154
+ :default => FalkorLib.config[:pyenv][:gemsetfile], :desc => ' Python virtualenv filename'
155
+ method_option :global, :aliases => '-g', :type => :boolean,
156
+ :default => true, :desc => 'Force overwritting the pyenv/direnv config'
157
+ #____________________
158
+ def pyenv(path = '.')
159
+ FalkorLib::Bootstrap.pyenv(path, options)
160
+ end # pyenv
161
+
162
+
130
163
  ###### slides ######
131
164
  #......................................
132
165
  desc "slides [options]", "Bootstrap LaTeX Beamer slides"
@@ -155,14 +188,14 @@ It consists of two files:
155
188
  These files will be committed in Git to ensure a consistent environment for the project.
156
189
  RVM_LONG_DESC
157
190
  method_option :force, :aliases => '-f',
158
- :type => :boolean, :desc => 'Force overwritting the RVM config'
191
+ :type => :boolean, :desc => 'Force overwritting the RVM config'
159
192
  method_option :ruby, :banner => 'VERSION',
160
- :desc => 'Ruby version to configure / install for RVM'
193
+ :desc => 'Ruby version to configure / install for RVM'
161
194
  method_option :versionfile, :banner => 'FILE',
162
- :default => FalkorLib.config[:rvm][:versionfile], :desc => 'RVM ruby version file'
195
+ :default => FalkorLib.config[:rvm][:versionfile], :desc => 'RVM ruby version file'
163
196
  method_option :gemset, :desc => 'RVM gemset to configure for this directory'
164
197
  method_option :gemsetfile, :banner => 'FILE',
165
- :default => FalkorLib.config[:rvm][:gemsetfile], :desc => 'RVM gemset file'
198
+ :default => FalkorLib.config[:rvm][:gemsetfile], :desc => 'RVM gemset file'
166
199
  #____________________
167
200
  def rvm(path = '.')
168
201
  FalkorLib::Bootstrap.rvm(path, options)
@@ -171,11 +204,11 @@ RVM_LONG_DESC
171
204
  ###### versionfile ######
172
205
  desc "versionfile PATH [options]", "initiate a VERSION file"
173
206
  method_option :file, :aliases => '-f',
174
- :desc => "Set the VERSION filename"
207
+ :desc => "Set the VERSION filename"
175
208
  method_option :tag, :aliases => '-t',
176
- :desc => "Git tag to use"
209
+ :desc => "Git tag to use"
177
210
  method_option :version, :aliases => '-v',
178
- :desc => "Set the version to initialize in the version file"
211
+ :desc => "Set the version to initialize in the version file"
179
212
  #_______________
180
213
  def versionfile(path = '.')
181
214
  FalkorLib::Bootstrap.versionfile(path, options)
@@ -184,7 +217,7 @@ RVM_LONG_DESC
184
217
 
185
218
  ###### readme ######
186
219
  method_option :make, :default => true,
187
- :type => :boolean, :desc => 'Use a Makefile to pilot the repository actions'
220
+ :type => :boolean, :desc => 'Use a Makefile to pilot the repository actions'
188
221
  method_option :rake,
189
222
  :type => :boolean, :desc => 'Use a Rakefile (and FalkorLib) to pilot the repository actions'
190
223
  method_option :latex, :aliases => '-l', :type => :boolean, :desc => "Describe a LaTeX project"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Fri 2018-04-27 13:52 svarrette>
3
+ # Time-stamp: <Mon 2018-11-12 07:15 svarrette>
4
4
  ################################################################################
5
5
  # FalkorLib Configuration
6
6
  #
@@ -60,6 +60,14 @@ module FalkorLib #:nodoc:
60
60
  :versionfile => '.ruby-version',
61
61
  :gemsetfile => '.ruby-gemset'
62
62
  },
63
+ :pyenv => {
64
+ :versions => ['2.7.14', '2.7.15', '3.6.4', '3.7.1' ],
65
+ :version => '2.7.14',
66
+ :versionfile => '.python-version',
67
+ :virtualenvfile => '.python-virtualenv',
68
+ :direnvfile => '.envrc',
69
+ :direnvrc => File.join( ENV['HOME'], '.config', 'direnv', 'direnvrc')
70
+ },
63
71
  :templates => {
64
72
  :trashdir => '.Trash',
65
73
  :puppet => {}
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Thu 2018-10-04 08:07 svarrette>
3
+ # Time-stamp: <Wed 2018-11-21 13:31 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Git operations
6
6
  #
@@ -398,7 +398,7 @@ module FalkorLib #:nodoc:
398
398
  remotes = FalkorLib::Git.remotes
399
399
  unless remotes.include?( remote )
400
400
  info "Initialize Git remote '#{remote}' from URL '#{url}'"
401
- exit_status = execute "git remote add -f #{remote} #{url}"
401
+ exit_status = execute "git remote add --no-tags -f #{remote} #{url}"
402
402
  end
403
403
  unless File.directory?( File.join(git_root_dir, dir) )
404
404
  info "initialize Git subtree '#{dir}'"
@@ -71,7 +71,7 @@ begin
71
71
  #t.pattern = "spec/**/common_*.rb"
72
72
  #t.pattern = "spec/**/versioning_*spec.rb"
73
73
  #t.pattern = "spec/**/puppet*spec.rb"
74
- #t.pattern = "spec/**/bootstrap_*spec.rb"
74
+ #t.pattern = "spec/**/bootstrap_spec.rb"
75
75
  #t.pattern = "spec/**/git*spec.rb"
76
76
  #t.pattern = "spec/**/error*spec.rb"
77
77
  #t.pattern = "spec/**/config*spec.rb"
@@ -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, 7, 18
22
+ MAJOR, MINOR, PATCH = 0, 8, 1
23
23
 
24
24
  module_function
25
25
 
@@ -74,3 +74,4 @@ module FalkorLib #:nodoc:
74
74
 
75
75
  end
76
76
 
77
+
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/ruby
2
+ #########################################
3
+ # bootstrap_python_spec.rb
4
+ # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
+ # Time-stamp: <Wed 2018-11-21 11:23 svarrette>
6
+ #
7
+ # @description Check the Bootstrapping operations for python-based projects
8
+ #
9
+ # Copyright (c) 2013 Sebastien Varrette <Sebastien.Varrette@uni.lu>
10
+ # . http://varrette.gforge.uni.lu
11
+ ##############################################################################
12
+
13
+ require 'spec_helper'
14
+ require 'tmpdir'
15
+ require 'fileutils'
16
+
17
+ describe FalkorLib::Bootstrap do
18
+
19
+ include FalkorLib::Common
20
+
21
+ dirs = {
22
+ :without_git => Dir.mktmpdir,
23
+ :with_git => Dir.mktmpdir,
24
+ }
25
+
26
+ #_____________
27
+ before :all do
28
+ $stdout.sync = true
29
+ FalkorLib.config[:no_interaction] = true
30
+ end
31
+
32
+ #____________
33
+ after :all do
34
+ dirs.each do |t,d|
35
+ #next if t == :with_git
36
+ FileUtils.remove_entry_secure d
37
+ end
38
+ FalkorLib.config[:no_interaction] = false
39
+ end
40
+
41
+ [ :without_git, :with_git ].each do |ctx|
42
+ # [ :without_git ].each do |ctx|
43
+ # [ :with_git ].each do |ctx|
44
+ dir = dirs[ctx]
45
+ ########################################################################
46
+ context "bootstrap/python (#{ctx}) within temporary directory '#{dir}'" do
47
+
48
+ if ctx == :with_git
49
+ it "initialize Git in the temporary directory #{dir}" do
50
+ c = FalkorLib::Git.init(dir)
51
+ expect(c).to eq(0)
52
+ t = FalkorLib::Git.init?(dir)
53
+ expect(t).to be true
54
+ end
55
+ end
56
+
57
+ ######### Pyenv/Direnv #########
58
+ it "#pyenv -- #{ctx}" do
59
+ c = FalkorLib::Bootstrap.pyenv(dir)
60
+ expect(c).to eq(0)
61
+ content = {}
62
+ [:versionfile, :virtualenvfile, :direnvfile].each do |type|
63
+ f = File.join(dir, FalkorLib.config[:pyenv][type.to_sym])
64
+ t = File.exists?(f)
65
+ expect(t).to be true
66
+ content[type.to_sym] = `cat #{f}`.chomp
67
+ end
68
+ expect(content[:versionfile]).to eq(FalkorLib.config[:pyenv][:version])
69
+ expect(content[:virtualenvfile]).to eq(File.basename(dir))
70
+ File.read(File.realpath( File.join(dir, FalkorLib.config[:pyenv][:direnvfile]))) do |f|
71
+ [
72
+ 'layout virtualenv ${pyversion} ${pvenv}',
73
+ 'layout activate ${pvenv}'
74
+ ].each do |pattern|
75
+ f.should include "#{pattern}"
76
+ end
77
+ end
78
+ end
79
+
80
+ it "#python -- #{ctx} -- repeat" do
81
+ t = FalkorLib::Bootstrap.pyenv(dir)
82
+ expect(t).to eq(1)
83
+ c = capture(:stdout) { FalkorLib::Bootstrap.pyenv(dir, { :force => true }) }
84
+ [
85
+ "The python/pyenv file '.python-version' already exists",
86
+ "The python/pyenv file '.python-virtualenv' already exists",
87
+ "The python/pyenv file '.envrc' already exists",
88
+ "and it WILL BE overwritten"
89
+ ].each do |pattern|
90
+ expect(c).to include pattern
91
+ end
92
+ end
93
+
94
+ it "#pyenv -- change targets (ctx = #{ctx}; dir = #{dir})" do
95
+ opts = {
96
+ :python => '3.7.1',
97
+ :versionfile => '.myversion',
98
+ :virtualenv => 'newvirtualenv',
99
+ :virtualenvfile => '.myvirtualenv'
100
+ }
101
+ c = FalkorLib::Bootstrap.pyenv(dir, opts)
102
+ expect(c).to eq(0)
103
+ content = {}
104
+ [:versionfile, :virtualenvfile].each do |type|
105
+ f = File.join(dir, opts[type.to_sym])
106
+ t = File.exists?(f)
107
+ expect(t).to be true
108
+ content[type.to_sym] = `cat #{f}`.chomp
109
+ end
110
+ expect(content[:versionfile]).to eq(opts[:python])
111
+ expect(content[:virtualenvfile]).to eq(opts[:virtualenv])
112
+ end
113
+
114
+
115
+
116
+ end # context "bootstrap/python"
117
+ end # each
118
+
119
+ end
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # bootstrap_ruby_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Sat 2016-11-12 02:28 svarrette>
5
+ # Time-stamp: <Wed 2018-11-21 08:48 svarrette>
6
6
  #
7
7
  # @description Check the Bootstrapping operations for ruby-based projects
8
8
  #
@@ -38,8 +38,8 @@ describe FalkorLib::Bootstrap do
38
38
  FalkorLib.config[:no_interaction] = false
39
39
  end
40
40
 
41
- #[ :without_git, :with_git ].each do |ctx|
42
- [ :without_git ].each do |ctx|
41
+ [ :without_git, :with_git ].each do |ctx|
42
+ # [ :without_git ].each do |ctx|
43
43
  # [ :with_git ].each do |ctx|
44
44
  dir = dirs[ctx]
45
45
  ########################################################################
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # bootstrap_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Thu 2018-11-08 16:26 svarrette>
5
+ # Time-stamp: <Fri 2018-11-09 09:43 svarrette>
6
6
  #
7
7
  # @description Check the basic Bootstrapping operations
8
8
  #
@@ -163,7 +163,7 @@ describe FalkorLib::Bootstrap do
163
163
  end
164
164
  end
165
165
 
166
- if ctx == :with_git
166
+ if (ctx == :with_git and !ENV['TRAVIS_CI_RUN'])
167
167
  it "#gitcrypt -- owner is empty" do
168
168
  c = FalkorLib::Bootstrap.gitcrypt(dir, { :owner => '', :no_interaction => true })
169
169
  [ '.git-crypt' ].each do |d|
@@ -0,0 +1,32 @@
1
+ # -*- mode: sh; -*-
2
+ # Global configuration for direnv to make it compliant with pyenv
3
+ # See https://direnv.net/
4
+ #
5
+ # Adapted from
6
+ # - https://github.com/direnv/direnv/wiki/Python#-pyenv and
7
+ # - https://github.com/direnv/direnv/wiki/Python#-virtualenvwrapper
8
+
9
+ # use a certain pyenv version
10
+ use_python() {
11
+ if [ -n "$(which pyenv)" ]; then
12
+ local pyversion=$1
13
+ pyenv local ${pyversion}
14
+ fi
15
+ }
16
+
17
+ layout_virtualenv() {
18
+ local pyversion=$1
19
+ local pvenv=$2
20
+ if [ -n "$(which pyenv-virtualenv)" ]; then
21
+ pyenv virtualenv --force --quiet ${pyversion} ${pvenv}-${pyversion}
22
+ fi
23
+ }
24
+
25
+ layout_activate() {
26
+ if [ -n "$(which pyenv)" ]; then
27
+ local pyenvprefix=$(pyenv prefix)
28
+ local pyversion=$(pyenv version-name)
29
+ local pvenv="$1"
30
+ source ${pyenvprefix}/envs/${pvenv}-${pyversion}/bin/activate
31
+ fi
32
+ }
@@ -17,7 +17,7 @@ group :test do
17
17
  gem "puppetlabs_spec_helper"
18
18
  gem "metadata-json-lint"
19
19
  gem "rspec-puppet-facts"
20
- gem 'rubocop', '0.33.0'
20
+ gem 'rubocop', '~> 0.51'
21
21
  gem 'simplecov', '>= 0.11.0'
22
22
  gem 'simplecov-console'
23
23
 
@@ -0,0 +1,21 @@
1
+ # -*- mode: sh; -*-
2
+ # (rootdir)/.envrc : direnv configuration file
3
+ # see https://direnv.net/
4
+ # Grab the latest version of this file from
5
+ # https://github.com/Falkor/dotfiles/blob/master/direnv/envrc
6
+ #
7
+ if [ -f ".python-version" ]; then
8
+ pyversion=$(head <%= config[:versionfile] %>)
9
+ else
10
+ pyversion=<%= FalkorLib.config[:pyenv][:version] %>
11
+ fi
12
+ use python ${pyversion}
13
+
14
+ if [ -f ".python-virtualenv" ]; then
15
+ pvenv=$(head <%= config[:virtualenvfile] %>)
16
+
17
+ # Create the virtualenv if not yet done
18
+ layout virtualenv ${pyversion} ${pvenv}
19
+ # activate it
20
+ layout activate ${pvenv} #-${pyversion}
21
+ fi
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.7.18
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-08 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -417,6 +417,7 @@ files:
417
417
  - lib/falkorlib/bootstrap/latex.rb
418
418
  - lib/falkorlib/bootstrap/link.rb
419
419
  - lib/falkorlib/bootstrap/mkdocs.rb
420
+ - lib/falkorlib/bootstrap/python.rb
420
421
  - lib/falkorlib/bootstrap/ruby.rb
421
422
  - lib/falkorlib/bootstrap/vagrant.rb
422
423
  - lib/falkorlib/cli.rb
@@ -452,6 +453,7 @@ files:
452
453
  - spec/falkorlib/bootstrap_helpers_spec.rb
453
454
  - spec/falkorlib/bootstrap_latex_spec.rb
454
455
  - spec/falkorlib/bootstrap_link_spec.rb
456
+ - spec/falkorlib/bootstrap_python_spec.rb
455
457
  - spec/falkorlib/bootstrap_ruby_spec.rb
456
458
  - spec/falkorlib/bootstrap_spec.rb
457
459
  - spec/falkorlib/common_spec.rb
@@ -477,6 +479,7 @@ files:
477
479
  - templates/Rakefile/footer_rakefile.erb
478
480
  - templates/Rakefile/header_rakefile.erb
479
481
  - templates/Rakefile/rakefile_gitflow.erb
482
+ - templates/direnv/direnvrc
480
483
  - templates/gems/Gemfile
481
484
  - templates/gems/LICENCE.md
482
485
  - templates/gems/README.md
@@ -554,6 +557,7 @@ files:
554
557
  - templates/puppet/modules/tests/vagrant/bootstrap.sh
555
558
  - templates/puppet/modules/tests/vagrant/config.yaml
556
559
  - templates/puppet/modules/tests/vagrant/puppet_modules_setup.rb
560
+ - templates/python/setup.sh.erb
557
561
  - templates/vagrant/Vagrantfile.erb
558
562
  - templates/vagrant/vagrant/bootstrap.sh
559
563
  - templates/vagrant/vagrant/config.yaml
@@ -592,6 +596,7 @@ test_files:
592
596
  - spec/falkorlib/config_spec.rb
593
597
  - spec/falkorlib/bootstrap_ruby_spec.rb
594
598
  - spec/falkorlib/bootstrap_link_spec.rb
599
+ - spec/falkorlib/bootstrap_python_spec.rb
595
600
  - spec/falkorlib/git_spec.rb
596
601
  - spec/falkorlib/gitflow_spec.rb
597
602
  - spec/falkorlib/bootstrap_latex_spec.rb