falkorlib 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.falkorlib.noespec +321 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +47 -0
- data/LICENCE.md +22 -0
- data/README.md +118 -0
- data/Rakefile +45 -0
- data/falkorlib.gemspec +207 -0
- data/lib/falkorlib.rb +10 -0
- data/lib/falkorlib/common.rb +130 -0
- data/lib/falkorlib/gitflow.rb +71 -0
- data/lib/falkorlib/loader.rb +3 -0
- data/lib/falkorlib/version.rb +65 -0
- data/spec/falkorlib/common_spec.rb +137 -0
- data/spec/falkorlib/gitflow_spec.rb +64 -0
- data/spec/falkorlib_spec.rb +8 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/debug_mail.rake +75 -0
- data/tasks/debug_mail.txt +13 -0
- data/tasks/gem.rake +73 -0
- data/tasks/spec_test.rake +73 -0
- data/tasks/unit_test.rake +77 -0
- data/tasks/yard.rake +51 -0
- data/test/test_gitflow.rb +16 -0
- metadata +227 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
module FalkorLib
|
2
|
+
module Version
|
3
|
+
|
4
|
+
##
|
5
|
+
# Change the MAJOR, MINOR and PATCH constants below
|
6
|
+
# to adjust the version of the FalkorLib gem
|
7
|
+
#
|
8
|
+
# MAJOR:
|
9
|
+
# Defines the major version
|
10
|
+
# MINOR:
|
11
|
+
# Defines the minor version
|
12
|
+
# PATCH:
|
13
|
+
# Defines the patch version
|
14
|
+
MAJOR, MINOR, PATCH = 0, 1, 0
|
15
|
+
|
16
|
+
##
|
17
|
+
# Returns the major version ( big release based off of multiple minor releases )
|
18
|
+
def self.major
|
19
|
+
MAJOR
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# Returns the minor version ( small release based off of multiple patches )
|
24
|
+
def self.minor
|
25
|
+
MINOR
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Returns the patch version ( updates, features and (crucial) bug fixes )
|
30
|
+
def self.patch
|
31
|
+
PATCH
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Returns the full version
|
36
|
+
def self.to_s
|
37
|
+
[ MAJOR, MINOR, PATCH ].join('.')
|
38
|
+
end
|
39
|
+
|
40
|
+
## Return a new version number based on
|
41
|
+
# - the old version (format: x.y.z)
|
42
|
+
# - the level of bumping (either :major, :minor, :patch)
|
43
|
+
def bump_version(oldversion, level)
|
44
|
+
if oldversion =~ /^(\d+)\.(\d+)\.(\d+)$/
|
45
|
+
major = $1.to_i
|
46
|
+
minor = $2.to_i
|
47
|
+
patch = $3.to_i
|
48
|
+
end
|
49
|
+
case level
|
50
|
+
when ':major'
|
51
|
+
major += 1
|
52
|
+
minor = 0
|
53
|
+
patch = 0
|
54
|
+
when ':minor'
|
55
|
+
minor += 1
|
56
|
+
patch = 0
|
57
|
+
when ':patch'
|
58
|
+
patch += 1
|
59
|
+
end
|
60
|
+
version = [major, minor, patch].compact.join('.')
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
VERSION = Version.to_s
|
65
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
describe FalkorLib do
|
5
|
+
|
6
|
+
include FalkorLib::Common
|
7
|
+
|
8
|
+
#############################################
|
9
|
+
context "Test (common) printing functions" do
|
10
|
+
|
11
|
+
@print_test_conf = {
|
12
|
+
:info => {
|
13
|
+
:color => :green,
|
14
|
+
:prefix => "[INFO]",
|
15
|
+
},
|
16
|
+
:warning => {
|
17
|
+
:color => :cyan,
|
18
|
+
:prefix => "/!\\ WARNING:",
|
19
|
+
},
|
20
|
+
:error => {
|
21
|
+
:color => :red,
|
22
|
+
:prefix => "*** ERROR ***",
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
# Check the color functions
|
27
|
+
@print_test_conf.values.collect{ |e| e[:color] }.each do |color|
|
28
|
+
it "should check a #{color} text" do
|
29
|
+
STDOUT.should_receive(:puts).with(send("#{color}", "#{color} text"))
|
30
|
+
puts send("#{color}", "#{color} text")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Check the prining messages
|
35
|
+
@print_test_conf.each do |method,conf|
|
36
|
+
it "should put a #{method} message" do
|
37
|
+
((method == :error) ? STDERR : STDOUT).should_receive(:puts).with(send("#{conf[:color]}", "#{conf[:prefix]} #{method} text"))
|
38
|
+
if (method == :error)
|
39
|
+
lambda {
|
40
|
+
send("#{method}", "#{method} text")
|
41
|
+
}.should raise_error #(SystemExit)
|
42
|
+
else
|
43
|
+
send("#{method}", "#{method} text")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Check the ask function
|
49
|
+
['', 'default'].each do |default_answer|
|
50
|
+
@query = "Am I a query"
|
51
|
+
it "should ask '#{@query}' with default answer '#{default_answer}' and no answer" do
|
52
|
+
STDIN.should_receive(:gets).and_return('')
|
53
|
+
results = capture(:stdout) {
|
54
|
+
answer = ask(@query, default_answer)
|
55
|
+
if default_answer.empty?
|
56
|
+
answer.should be_empty
|
57
|
+
else
|
58
|
+
answer.should == default_answer
|
59
|
+
end
|
60
|
+
}
|
61
|
+
results.should =~ /#{@query}/;
|
62
|
+
unless default_answer.empty?
|
63
|
+
results.should =~ /Default: #{default_answer}/;
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check the really_continue? function
|
69
|
+
[ '', 'Yes', 'y', 'Y', 'yes' ].each do |answer|
|
70
|
+
it "should really continue after answer '#{answer}'" do
|
71
|
+
STDIN.should_receive(:gets).and_return(answer)
|
72
|
+
results = capture(:stdout) { really_continue? }
|
73
|
+
results.should =~ /=> Do you really want to continue/;
|
74
|
+
results.should =~ /Default: Yes/;
|
75
|
+
end
|
76
|
+
next if answer.empty?
|
77
|
+
it "should really continue (despite default answer 'No') after answer '#{answer}'" do
|
78
|
+
STDIN.should_receive(:gets).and_return(answer)
|
79
|
+
results = capture(:stdout) { really_continue?('No') }
|
80
|
+
results.should =~ /=> Do you really want to continue/;
|
81
|
+
results.should =~ /Default: No/;
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
[ '', 'No', 'n', 'N', 'no' ].each do |answer|
|
86
|
+
it "should not continue (despite default answer 'No') and exit after answer '#{answer}'" do
|
87
|
+
STDIN.should_receive(:gets).and_return(answer)
|
88
|
+
results = capture(:stdout) {
|
89
|
+
lambda{
|
90
|
+
really_continue?('No')
|
91
|
+
}.should raise_error (SystemExit)
|
92
|
+
}
|
93
|
+
results.should =~ /=> Do you really want to continue/;
|
94
|
+
results.should =~ /Default: No/;
|
95
|
+
end
|
96
|
+
next if answer.empty?
|
97
|
+
it "should not continue and exit after answer '#{answer}'" do
|
98
|
+
STDIN.should_receive(:gets).and_return(answer)
|
99
|
+
results = capture(:stdout) {
|
100
|
+
lambda{
|
101
|
+
really_continue?
|
102
|
+
}.should raise_error (SystemExit)
|
103
|
+
}
|
104
|
+
results.should =~ /=> Do you really want to continue/;
|
105
|
+
results.should =~ /Default: Yes/;
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Check the command? function
|
110
|
+
[ 'sqgfyueztruyjf', 'ruby' ].each do |command|
|
111
|
+
it "should check the command '#{command}'" do
|
112
|
+
command?(command).should ((command == 'ruby') ? be_true : be_false)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
#############################################
|
118
|
+
context "Test (common) YAML functions" do
|
119
|
+
|
120
|
+
it "should load the correct hash from YAML" do
|
121
|
+
file_config = {:domain => "foo.com", :nested => { 'a1' => 2 }}
|
122
|
+
YAML.stub(:load_file).and_return(file_config)
|
123
|
+
loaded = load_config('toto')
|
124
|
+
loaded.should == file_config
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should store the correct hash to YAML" do
|
128
|
+
file_config = {:domain => "foo.com", :nested => { 'a1' => 2 }}
|
129
|
+
f = Tempfile.new('toto')
|
130
|
+
store_config(f.path, file_config)
|
131
|
+
copy_file_config = YAML::load_file(f.path)
|
132
|
+
copy_file_config.should == file_config
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#########################################
|
3
|
+
# gitflow_spec.rb
|
4
|
+
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
+
# Time-stamp: <Jeu 2013-01-31 23:22 svarrette>
|
6
|
+
#
|
7
|
+
# @description Check the
|
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
|
+
|
16
|
+
describe FalkorLib do
|
17
|
+
|
18
|
+
include FalkorLib::Common
|
19
|
+
|
20
|
+
# it "test default initialization of a git-flow dir" do
|
21
|
+
# tempdir = Dir.tmpdir
|
22
|
+
# #puts "tempdir = #{tempdir}"
|
23
|
+
|
24
|
+
# FalkorLib::GitFlow::init(tempdir)
|
25
|
+
|
26
|
+
# File.directory?(File.join(tempdir, '.git')).should be_true
|
27
|
+
|
28
|
+
# g = Git.open(tempdir)
|
29
|
+
# g.config['gitflow.branch.master'].should == FalkorLib::GitFlow::global_config(:master)
|
30
|
+
# g.config['gitflow.branch.develop'].should == FalkorLib::GitFlow::global_config(:develop)
|
31
|
+
# [ :feature, :release, :hotfix, :support, :versiontag ].each do |e|
|
32
|
+
# g.config["gitflow.prefix.#{e}"].should == FalkorLib::GitFlow::global_config(e.to_sym)
|
33
|
+
# end
|
34
|
+
# FileUtils.rm_rf(tempdir)
|
35
|
+
# end
|
36
|
+
|
37
|
+
# [ :master, :develop, :feature, :release, :hotfix, :support, :versiontag ].each do |elem|
|
38
|
+
# specialvalue = 'uncommonvalue'
|
39
|
+
|
40
|
+
# it "test specialized initialization of a git-flow dir (alter '#{elem}' option with special value #{specialvalue})" do
|
41
|
+
# tempdir = Dir.tmpdir
|
42
|
+
# #puts "tempdir = #{tempdir}"
|
43
|
+
|
44
|
+
# FalkorLib::GitFlow::init(tempdir, { elem.to_sym => "#{specialvalue}"})
|
45
|
+
|
46
|
+
# File.directory?(File.join(tempdir, '.git')).should be_true
|
47
|
+
|
48
|
+
# g = Git.open(tempdir)
|
49
|
+
# [ :master, :develop].each do |e|
|
50
|
+
# #puts "elem = #{elem}, e = #{e}, ", g.config["gitflow.branch.#{e}"]
|
51
|
+
# g.config["gitflow.branch.#{e}"].should == ((elem == e) ? specialvalue : FalkorLib::GitFlow::global_config(e.to_sym))
|
52
|
+
# end
|
53
|
+
# [ :feature, :release, :hotfix, :support, :versiontag ].each do |e|
|
54
|
+
# g.config["gitflow.prefix.#{e}"].should == ((elem == e) ? specialvalue : FalkorLib::GitFlow::global_config(e.to_sym))
|
55
|
+
# end
|
56
|
+
# FileUtils.rm_rf(tempdir)
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'falkorlib'
|
3
|
+
require 'falkorlib/common'
|
4
|
+
require 'falkorlib/gitflow'
|
5
|
+
|
6
|
+
def capture(stream)
|
7
|
+
begin
|
8
|
+
stream = stream.to_s
|
9
|
+
eval "$#{stream} = StringIO.new"
|
10
|
+
yield
|
11
|
+
result = eval("$#{stream}").string
|
12
|
+
ensure
|
13
|
+
eval("$#{stream} = #{stream.upcase}")
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Installs a rake task for debuging the announcement mail.
|
2
|
+
#
|
3
|
+
# This file installs the 'rake debug_mail' that flushes an announcement mail
|
4
|
+
# for your library on the standard output. It is automatically generated
|
5
|
+
# by Noe from your .noespec file, and should therefore be configured there,
|
6
|
+
# under the variables/rake_tasks/debug_mail entry, as illustrated below:
|
7
|
+
#
|
8
|
+
# variables:
|
9
|
+
# rake_tasks:
|
10
|
+
# debug_mail:
|
11
|
+
# rx_changelog_sections: /^#/
|
12
|
+
# nb_changelog_sections: 1
|
13
|
+
# ...
|
14
|
+
#
|
15
|
+
# If you have specific needs requiring manual intervention on this file,
|
16
|
+
# don't forget to set safe-override to false in your noe specification:
|
17
|
+
#
|
18
|
+
# template-info:
|
19
|
+
# manifest:
|
20
|
+
# tasks/debug_mail.rake:
|
21
|
+
# safe-override: false
|
22
|
+
#
|
23
|
+
# The mail template used can be found in debug_mail.txt. That file may be
|
24
|
+
# changed to tune the mail you want to send. If you do so, don't forget to
|
25
|
+
# add a manifest entry in your .noespec file to avoid overriding you
|
26
|
+
# changes. The mail template uses wlang, with parentheses for block
|
27
|
+
# delimiters.
|
28
|
+
#
|
29
|
+
# template-info:
|
30
|
+
# manifest:
|
31
|
+
# tasks/debug_mail.txt:
|
32
|
+
# safe-override: false
|
33
|
+
#
|
34
|
+
desc "Debug the release announcement mail"
|
35
|
+
task :debug_mail do
|
36
|
+
begin
|
37
|
+
require 'wlang'
|
38
|
+
rescue LoadError
|
39
|
+
abort "wlang is not available. Try 'gem install wlang'"
|
40
|
+
end
|
41
|
+
require 'yaml'
|
42
|
+
|
43
|
+
# Check that a .noespec file exists
|
44
|
+
noespec_file = File.expand_path('../../.falkorlib.noespec', __FILE__)
|
45
|
+
unless File.exists?(noespec_file)
|
46
|
+
raise "Unable to find .noespec project file, sorry."
|
47
|
+
end
|
48
|
+
|
49
|
+
# Load it as well as variables and options
|
50
|
+
noespec = YAML::load(File.read(noespec_file))
|
51
|
+
vars = noespec['variables'] || {}
|
52
|
+
|
53
|
+
# Changes are taken from CHANGELOG
|
54
|
+
logs = Dir[File.expand_path("../../CHANGELOG.*", __FILE__)]
|
55
|
+
unless logs.size == 1
|
56
|
+
abort "Unable to find a changelog file"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Load interesting changesets
|
60
|
+
changes, end_found = [], 0
|
61
|
+
File.readlines(logs.first).select{|line|
|
62
|
+
if line =~ /^# /
|
63
|
+
break if end_found >= 1
|
64
|
+
end_found += 1
|
65
|
+
end
|
66
|
+
changes << line
|
67
|
+
}
|
68
|
+
vars['changes'] = changes.join
|
69
|
+
|
70
|
+
# WLang template
|
71
|
+
template = File.expand_path('../debug_mail.txt', __FILE__)
|
72
|
+
|
73
|
+
# Let's go!
|
74
|
+
$stdout << WLang::file_instantiate(template, vars, "wlang/active-text")
|
75
|
+
end
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Installs rake tasks for gemming and packaging
|
2
|
+
#
|
3
|
+
# This file installs the 'rake package', 'rake gem' tasks and associates
|
4
|
+
# (clobber_package, repackage, ...). It is automatically generated by Noe
|
5
|
+
# from your .noespec file, and should therefore be configured there, under
|
6
|
+
# the variables/rake_tasks/gem entry, as illustrated below:
|
7
|
+
#
|
8
|
+
# variables:
|
9
|
+
# rake_tasks:
|
10
|
+
# gem:
|
11
|
+
# package_dir: pkg
|
12
|
+
# need_tar: false
|
13
|
+
# need_tar_gz: false
|
14
|
+
# need_tar_bz2: false
|
15
|
+
# need_zip: false
|
16
|
+
# ...
|
17
|
+
#
|
18
|
+
# If you have specific needs requiring manual intervention on this file,
|
19
|
+
# don't forget to set safe-override to false in your noe specification:
|
20
|
+
#
|
21
|
+
# template-info:
|
22
|
+
# manifest:
|
23
|
+
# tasks/gem.rake:
|
24
|
+
# safe-override: false
|
25
|
+
#
|
26
|
+
begin
|
27
|
+
require 'rubygems/package_task'
|
28
|
+
|
29
|
+
# Dynamically load the gem spec
|
30
|
+
gemspec_file = File.expand_path('../../falkorlib.gemspec', __FILE__)
|
31
|
+
gemspec = Kernel.eval(File.read(gemspec_file))
|
32
|
+
|
33
|
+
Gem::PackageTask.new(gemspec) do |t|
|
34
|
+
|
35
|
+
# Name of the package
|
36
|
+
t.name = gemspec.name
|
37
|
+
|
38
|
+
# Version of the package
|
39
|
+
t.version = gemspec.version
|
40
|
+
|
41
|
+
# Directory used to store the package files
|
42
|
+
t.package_dir = "pkg"
|
43
|
+
|
44
|
+
# True if a gzipped tar file (tgz) should be produced
|
45
|
+
t.need_tar = false
|
46
|
+
|
47
|
+
# True if a gzipped tar file (tar.gz) should be produced
|
48
|
+
t.need_tar_gz = false
|
49
|
+
|
50
|
+
# True if a bzip2'd tar file (tar.bz2) should be produced
|
51
|
+
t.need_tar_bz2 = false
|
52
|
+
|
53
|
+
# True if a zip file should be produced (default is false)
|
54
|
+
t.need_zip = false
|
55
|
+
|
56
|
+
# List of files to be included in the package.
|
57
|
+
t.package_files = gemspec.files
|
58
|
+
|
59
|
+
# Tar command for gzipped or bzip2ed archives.
|
60
|
+
t.tar_command = "tar"
|
61
|
+
|
62
|
+
# Zip command for zipped archives.
|
63
|
+
t.zip_command = "zip"
|
64
|
+
|
65
|
+
end
|
66
|
+
rescue LoadError
|
67
|
+
task :gem do
|
68
|
+
abort 'rubygems/package_task is not available. You should verify your rubygems installation'
|
69
|
+
end
|
70
|
+
task :package do
|
71
|
+
abort 'rubygems/package_task is not available. You should verify your rubygems installation'
|
72
|
+
end
|
73
|
+
end
|