falkorlib 0.3.14 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e93d828315d07d5c2c2b2016c9e7436a8e10293
4
- data.tar.gz: afdca4fff506283b7e9f00bef8699e13ce01fb01
3
+ metadata.gz: 844b9104ffcc2838a8b9176658a6ee5b3db82e77
4
+ data.tar.gz: 918eab8d5e9945fcbc71beeb80d18c3eb2c3a6ae
5
5
  SHA512:
6
- metadata.gz: 10835e724bc95479750d8aa0ae112c2a814d41bef28f26f213d9e00cbe79234b564b9589771d9cc165ed40658b140dea1048bb544f5844cdddf5a63c2dc6ef44
7
- data.tar.gz: 145c8067c68d49fbb2f933c3417c8c82aa5eb89060e74ea731f383e7e5dbadae12da456353c9088aea39b788812a926bf245b35bd6f2b2d6bb5730ed8ff8569f
6
+ metadata.gz: 204b9fd452435462ee29119978f0747a65138ee6474b546c7a56b76bcc6c8b00c2c60560b8bc7d6ff817ac56829d314551220c54f18a6fde49852189a217ef45
7
+ data.tar.gz: 264f60f7e3cc56122815f4e0017cb2b55bf741978710f7c70b61d7f3ec25e541e0e2307e3f7594d085bca9ae639d8c3dc2698890fb04c5814f7ea53ec0651824
@@ -1,29 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.3.14)
4
+ falkorlib (0.4.0)
5
5
  awesome_print (~> 1.2)
6
6
  configatron (~> 3.2)
7
7
  diffy (>= 3.0)
8
8
  git_remote_branch (~> 0)
9
9
  json (~> 1.8)
10
10
  license-generator (~> 0)
11
+ logger (>= 1.2.8)
11
12
  minigit (~> 0)
12
13
  rake (~> 10.1, >= 10.1.0)
13
14
  term-ansicolor (~> 1.3)
15
+ thor (>= 0.19)
14
16
 
15
17
  GEM
16
18
  remote: http://rubygems.org/
17
19
  specs:
18
20
  addressable (2.3.6)
19
- awesome_print (1.2.0)
21
+ awesome_print (1.6.1)
20
22
  backports (3.6.0)
21
23
  codeclimate-test-reporter (0.3.0)
22
24
  simplecov (>= 0.7.1, < 1.0.0)
23
25
  coderay (1.1.0)
24
26
  configatron (3.2.0)
25
27
  diff-lcs (1.1.3)
26
- diffy (3.0.6)
28
+ diffy (3.0.7)
27
29
  docile (1.1.5)
28
30
  ethon (0.7.0)
29
31
  ffi (>= 1.3.0)
@@ -47,6 +49,7 @@ GEM
47
49
  addressable (~> 2.3)
48
50
  license-generator (0.4.1)
49
51
  thor
52
+ logger (1.2.8)
50
53
  method_source (0.8.2)
51
54
  minigit (0.0.4)
52
55
  multi_json (1.10.1)
@@ -60,7 +63,7 @@ GEM
60
63
  pusher-client (0.6.0)
61
64
  json
62
65
  websocket (~> 1.0)
63
- rake (10.3.2)
66
+ rake (10.4.2)
64
67
  rspec (2.7.0)
65
68
  rspec-core (~> 2.7.0)
66
69
  rspec-expectations (~> 2.7.0)
@@ -80,7 +83,7 @@ GEM
80
83
  term-ansicolor (1.3.0)
81
84
  tins (~> 1.0)
82
85
  thor (0.19.1)
83
- tins (1.3.2)
86
+ tins (1.3.3)
84
87
  travis (1.6.14)
85
88
  addressable (~> 2.3)
86
89
  backports
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  ##############################################################################
2
2
  # Rakefile - Configuration file for rake (http://rake.rubyforge.org/)
3
- # Time-stamp: <Ven 2014-06-20 00:10 svarrette>
3
+ # Time-stamp: <Lun 2015-01-12 21:10 svarrette>
4
4
  #
5
5
  # Copyright (c) 2012 Sebastien Varrette <Sebastien.Varrette@uni.lu>
6
6
  # . http://varrette.gforge.uni.lu
@@ -16,7 +16,7 @@
16
16
  # * http://www.stuartellis.eu/articles/rake/
17
17
  ##############################################################################
18
18
 
19
- task :default => [ :build, :rspec ]
19
+ task :default => [ :rspec ]
20
20
  #.....................
21
21
  require 'rake/clean'
22
22
 
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby -U
2
+ # -*- encoding: utf-8 -*-
3
+ ################################################################################
4
+ # Time-stamp: <Lun 2015-01-19 14:48 svarrette>
5
+ #
6
+ # Copyright (c) 2015 Sebastien Varrette <Sebastien.Varrette@uni.lu>
7
+ #
8
+ ################################################################################
9
+ # Resources:
10
+ #
11
+ # * [cleanthor](https://github.com/lastobelus/cleanthor)
12
+ # * http://chrisparai.so/creating-a-thor-gem/
13
+ # * http://willschenk.com/making-a-command-line-utility-with-gems-and-thor/
14
+
15
+ # Exit cleanly from an early interrupt
16
+ Signal.trap("INT") { exit 1 }
17
+
18
+
19
+
20
+ require "thor/error"
21
+ require 'falkorlib'
22
+
23
+ begin
24
+ FalkorLib::CLI::App.start(ARGV, :debug => true)
25
+ rescue Thor::InvocationError => e
26
+ error e.message.gsub(/^ERROR:/, '')
27
+ end
28
+
29
+
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ ################################################################################
3
+ # Time-stamp: <Lun 2015-01-19 16:25 svarrette>
4
+ #
5
+ # BASH completion for [FalkorLib](https://github.com/Falkor/falkorlib)
6
+ #
7
+ # Copyright (c) 2015 Sebastien Varrette <Sebastien.Varrette@uni.lu>
8
+ ################################################################################
9
+ _falkor() {
10
+ COMPREPLY=()
11
+ local word="${COMP_WORDS[COMP_CWORD]}"
12
+
13
+ if [ "$COMP_CWORD" -eq 1 ]; then
14
+ local commands="$(compgen -W "$(falkor commands)" -- "$word")"
15
+ COMPREPLY=( $commands $projects )
16
+ fi
17
+ }
18
+
19
+ complete -o default -F _falkor falkor
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env zsh
2
+ ################################################################################
3
+ # Time-stamp: <Lun 2015-01-19 16:24 svarrette>
4
+ #
5
+ # ZSH completion for [FalkorLib](https://github.com/Falkor/falkorlib)
6
+ #
7
+ # Copyright (c) 2015 Sebastien Varrette <Sebastien.Varrette@uni.lu>
8
+ ################################################################################
9
+
10
+ if [[ ! -o interactive ]]; then
11
+ return
12
+ fi
13
+
14
+ compctl -f -K _falkor falkor
15
+
16
+ _falkor() {
17
+ local words completions
18
+ read -cA words
19
+
20
+ if [ "${#words}" -eq 2 ]; then
21
+ completions="$(falkor commands)"
22
+ fi
23
+
24
+ reply=("${(ps:\n:)completions}")
25
+ }
@@ -101,7 +101,7 @@ Gem::Specification.new do |s|
101
101
 
102
102
  # Executables included in the gem.
103
103
  #
104
- #s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
104
+ s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
105
105
 
106
106
  ################################################################### REQUIREMENTS & INSTALL
107
107
  # Remember the gem version requirements operators and schemes:
@@ -133,7 +133,11 @@ Gem::Specification.new do |s|
133
133
  s.add_runtime_dependency("json", "~> 1.8")
134
134
  s.add_runtime_dependency("license-generator", '~> 0')
135
135
  s.add_runtime_dependency("diffy", '>= 3.0')
136
+ s.add_runtime_dependency("logger", '>= 1.2.8')
137
+ s.add_runtime_dependency("thor", '>= 0.19')
138
+ #s.add_runtime_dependency("mercenary", '>= 0.3.5')
136
139
 
140
+ #
137
141
  #
138
142
  # One call to add_dependency('gem_name', 'gem version requirement') for each
139
143
  # runtime dependency. These gems will be installed with your gem.
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sam 2014-08-23 23:18 svarrette>
3
+ # Time-stamp: <Mar 2015-01-13 21:24 svarrette>
4
4
  ################################################################################
5
5
  # _____ _ _ _ _ _
6
6
  # | ___|_ _| | | _____ _ __| | (_) |__
@@ -47,5 +47,6 @@ module FalkorLib
47
47
 
48
48
  end # module FalkorLib
49
49
 
50
+
50
51
  require "falkorlib/version"
51
52
  require "falkorlib/loader"
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Mer 2015-01-21 22:35 svarrette>
4
+ ################################################################################
5
+ # Management of Bootstrapping operations
6
+
7
+ require "falkorlib"
8
+
9
+ module FalkorLib #:nodoc:
10
+
11
+ end # module FalkorLib
12
+
13
+ require "falkorlib/bootstrap/base"
14
+ #require "falkorlib/bootstrap/repo"
15
+
@@ -0,0 +1,241 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Ven 2015-01-23 00:12 svarrette>
4
+ ################################################################################
5
+ # Interface for the main Bootstrapping operations
6
+ #
7
+
8
+ require "falkorlib"
9
+ require "falkorlib/common"
10
+
11
+ include FalkorLib::Common
12
+
13
+ module FalkorLib #:nodoc:
14
+ module Config
15
+
16
+ # Default configuration for Bootstrapping processes
17
+ module Bootstrap
18
+ DEFAULTS =
19
+ {
20
+ :trashdir => '.Trash',
21
+ :types => [ 'article', 'slides', 'gem', 'octopress', 'puppet_module', 'rvm' ],
22
+ :rvm => {
23
+ :version => '1.9.3',
24
+ :versionfile => '.ruby-version',
25
+ :gemsetfile => '.ruby-gemset'
26
+ },
27
+ :puppet => {},
28
+ }
29
+
30
+
31
+ end
32
+ end
33
+ end
34
+
35
+
36
+
37
+ module FalkorLib
38
+ module Bootstrap
39
+ module_function
40
+
41
+ ###
42
+ # Initialize a trash directory in path
43
+ ##
44
+ def trash(path = Dir.pwd, dirname = FalkorLib.config[:templates][:trashdir], options = {})
45
+ #args = method(__method__).parameters.map { |arg| arg[1].to_s }.map { |arg| { arg.to_sym => eval(arg) } }.reduce Hash.new, :merge
46
+ #ap args
47
+ exit_status = 0
48
+ trashdir = File.join(path, dirname)
49
+ if Dir.exists?(trashdir)
50
+ warning "The trash directory '#{dirname}' already exists"
51
+ return 1
52
+ end
53
+ Dir.chdir(path) do
54
+ info "creating the trash directory '#{dirname}'"
55
+ exit_status = run %{
56
+ mkdir -p #{dirname}
57
+ echo '*' > #{dirname}/.gitignore
58
+ }
59
+ if FalkorLib::Git.init?(path)
60
+ exit_status = FalkorLib::Git.add(File.join(path, dirname, '.gitignore' ),
61
+ 'Add Trash directory',
62
+ { :force => true } )
63
+ end
64
+ end
65
+ exit_status.to_i
66
+ end # trash
67
+
68
+ ###### rvm ######
69
+ # Initialize RVM in the current directory
70
+ # Supported options:
71
+ # * :force [boolean] force overwritting
72
+ # * :ruby [string] Ruby version to configure for RVM
73
+ # * :versionfile [string] Ruby Version file
74
+ # * :gemset [string] RVM Gemset to configure
75
+ # * :gemsetfile [string] RVM Gemset file
76
+ # * :commit [boolean] Commit the changes NOT YET USED
77
+ ##
78
+ def rvm(dir = Dir.pwd, options = {})
79
+ info "Initialize Ruby Version Manager (RVM)"
80
+ ap options if options[:debug]
81
+ path = normalized_path(dir)
82
+ use_git = FalkorLib::Git.init?(path)
83
+ rootdir = use_git ? FalkorLib::Git.rootdir(path) : path
84
+ files = {}
85
+ exit_status = 1
86
+ [:versionfile, :gemsetfile].each do |type|
87
+ f = options[type.to_sym].nil? ? FalkorLib.config[:rvm][type.to_sym] : options[type.to_sym]
88
+ if File.exists?( File.join( rootdir, f ))
89
+ content = `cat #{File.join( rootdir, f)}`.chomp
90
+ warning "The RVM file '#{f}' already exists (and contains '#{content}')"
91
+ next unless options[:force]
92
+ warning "... and it WILL BE overwritten"
93
+ end
94
+ files[type.to_sym] = f
95
+ end
96
+ # ==== Ruby version ===
97
+ unless files[:versionfile].nil?
98
+ file = File.join(rootdir, files[:versionfile])
99
+ v =
100
+ options[:ruby] ?
101
+ options[:ruby] :
102
+ select_from(FalkorLib.config[:rvm][:rubies],
103
+ "Select RVM ruby to configure for this directory",
104
+ 1)
105
+ info " ==> configuring RVM version file '#{files[:versionfile]}' for ruby version '#{v}'"
106
+ File.open(file, 'w') do |f|
107
+ f.puts v
108
+ end
109
+ exit_status = (File.exists?(file) and `cat #{file}`.chomp == v) ? 0 : 1
110
+ FalkorLib::Git.add(File.join(rootdir, files[:versionfile])) if use_git
111
+ end
112
+ # === Gemset ===
113
+ if files[:gemsetfile]
114
+ file = File.join(rootdir, files[:gemsetfile])
115
+ default_gemset = File.basename(rootdir)
116
+ default_gemset = `cat #{file}`.chomp if File.exists?( file )
117
+ g = options[:gemset] ? options[:gemset] : ask("Enter RVM gemset name for this directory", default_gemset)
118
+ info " ==> configuring RVM gemset file '#{files[:gemsetfile]}' with content '#{g}'"
119
+ File.open( File.join(rootdir, files[:gemsetfile]), 'w') do |f|
120
+ f.puts g
121
+ end
122
+ exit_status = (File.exists?(file) and `cat #{file}`.chomp == g) ? 0 : 1
123
+ FalkorLib::Git.add(File.join(rootdir, files[:gemsetfile])) if use_git
124
+ end
125
+ exit_status
126
+ end # rvm
127
+
128
+ ###### repo ######
129
+ # Initialize a Git repository for a project with my favorite layout
130
+ # Supported options:
131
+ # :interactive [boolean] Confirm Gitflow branch names
132
+ # :master [string] Branch name for production releases
133
+ # :develop [string] Branch name for development commits
134
+ # :make [boolean] Use a Makefile to pilot the repository actions
135
+ # :rake [boolean] Use a Rakefile (and FalkorLib) to pilot the repository action
136
+ # :remote_sync [boolean] Operate a git remote synchronization
137
+ ##
138
+ def repo(name, options = {})
139
+ ap options if options[:debug]
140
+ path = normalized_path(name)
141
+ project = File.basename(path)
142
+ use_git = FalkorLib::Git.init?(path)
143
+ info "Bootstrap a [Git] repository for the project '#{project}'"
144
+ if use_git
145
+ warning "Git is already initialized for the repository '#{name}'"
146
+ really_continue? unless options[:force]
147
+ end
148
+ info " ==> initialize Git flow in #{path}"
149
+ FalkorLib::GitFlow.init(path, options)
150
+ gitflow_branches = {}
151
+ [ :master, :develop ].each do |t|
152
+ gitflow_branches[t.to_sym] = FalkorLib::GitFlow.branches(t, path)
153
+ end
154
+ # === prepare Git submodules ===
155
+ info " ==> prepare the relevant Git submodules"
156
+ submodules = {
157
+ 'gitstats' => { :url => 'https://github.com/hoxu/gitstats.git' }
158
+ }
159
+ if options[:make]
160
+ submodules['Makefiles'] = {
161
+ :url => 'https://github.com/Falkor/Makefiles.git',
162
+ :branch => 'devel'
163
+ }
164
+ end
165
+ FalkorLib::Git.submodule_init(path, submodules)
166
+ # === Prepare root [M|R]akefile ===
167
+ if options[:make]
168
+ info " ==> prepare Root Makefile"
169
+ makefile = File.join(path, "Makefile")
170
+ unless File.exist?( makefile )
171
+ src_makefile = File.join(path, FalkorLib.config.git[:submodulesdir],
172
+ 'Makefiles', 'repo', 'Makefile')
173
+ FileUtils.cp src_makefile, makefile
174
+ info "adapting Makefile to the gitflow branches"
175
+ Dir.chdir( path ) do
176
+ run %{
177
+ sed -i '' \
178
+ -e \"s/^GITFLOW_BR_MASTER=production/GITFLOW_BR_MASTER=#{gitflow_branches[:master]}/\" \
179
+ -e \"s/^GITFLOW_BR_DEVELOP=devel/GITFLOW_BR_DEVELOP=#{gitflow_branches[:develop]}/\" \
180
+ Makefile
181
+ }
182
+ end
183
+ FalkorLib::Git.add(makefile, 'Initialize root Makefile for the repo')
184
+ else
185
+ puts " ... not overwriting the root Makefile which already exists"
186
+ end
187
+ end
188
+ if options[:rake]
189
+ warning "TODO: setup Rakefile"
190
+ end
191
+
192
+ # === VERSION file ===
193
+ FalkorLib::Bootstrap.versionfile(path, :tag => 'v0.0.0')
194
+
195
+ #===== remote synchro ========
196
+ if options[:remote_sync]
197
+ remotes = FalkorLib::Git.remotes(path)
198
+ if remotes.include?( 'origin' )
199
+ info "perform remote synchronization"
200
+ [ :master, :develop ].each do |t|
201
+ FalkorLib::Git.publish(gitflow_branch[t.to_sym], path, 'origin')
202
+ end
203
+ else
204
+ warning "no Git remote 'origin' found, thus no remote synchronization performed"
205
+ end
206
+ end
207
+
208
+ end # repo
209
+
210
+ ###### versionfile ######
211
+ # Bootstrap a VERSION file at the root of a project
212
+ # Supported options:
213
+ # * :file [string] filename
214
+ ##
215
+ def versionfile(dir = Dir.pwd, options = {})
216
+ file = options[:file] ? options[:file] : 'VERSION'
217
+ version = options[:version] ? options[:version] : '0.0.0'
218
+ info " ==> bootstrapping a VERSION file"
219
+ path = normalized_path(dir)
220
+ path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
221
+ unless Dir.exists?( path )
222
+ warning "The directory #{path} does not exists and will be created"
223
+ really_continue?
224
+ FileUtils.mkdir_p path
225
+ end
226
+ versionfile = File.join(path, file)
227
+ unless File.exists?( versionfile )
228
+ run %{ echo "#{version}" > #{versionfile} }
229
+ if FalkorLib::Git.init?(path)
230
+ FalkorLib::Git.add(versionfile, "Initialize #{file} file")
231
+ Dir.chdir( path ) do
232
+ run %{ git tag #{options[:tag]} } if options[:tag]
233
+ end
234
+ end
235
+ else
236
+ puts " ... not overwriting the #{file} file which already exists"
237
+ end
238
+ end # versionfile
239
+
240
+ end # module Bootstrap
241
+ end # module FalkorLib