falsework 0.0.1 → 0.1.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.
- data/README.rdoc +11 -6
- data/Rakefile +25 -24
- data/bin/falsework +9 -1
- data/doc/NEWS.rdoc +7 -0
- data/doc/README.rdoc +11 -6
- data/doc/TODO.rdoc +8 -2
- data/lib/falsework/meta.rb +1 -1
- data/lib/falsework/templates/naive/Rakefile.erb +3 -2
- data/lib/falsework/templates/naive/doc/NEWS.rdoc.erb +5 -0
- data/lib/falsework/templates/naive/lib/.@project./utils.rb.erb +1 -1
- data/lib/falsework/templates/naive/test/helper.rb.erb +1 -1
- data/lib/falsework/templates/naive/test/rake_git.rb.erb +23 -0
- data/test/rake_git.rb +21 -0
- data/test/test_exe.rb +73 -0
- metadata +23 -18
- data/test/test_utils.rb +0 -47
- /data/test/{find_erb_templates.rb → rake_erb_templates.rb} +0 -0
data/README.rdoc
CHANGED
@@ -13,16 +13,21 @@ Ruby.
|
|
13
13
|
|
14
14
|
The falsework utility generates a scaffold which have:
|
15
15
|
|
16
|
-
*
|
16
|
+
* auto-created git (but not github) project;
|
17
17
|
|
18
|
-
*
|
18
|
+
* <tt>gem</tt> (a file list is pulled from the git repository, no more
|
19
|
+
missing files in gems!), <tt>doc</tt>, <tt>test</tt> targers;
|
19
20
|
|
20
|
-
|
21
|
+
* easy to use configuraton parser/loader. This includes scanning for:
|
22
|
+
|
23
|
+
* env variable(s);
|
21
24
|
* the flat YAML configuration file;
|
22
25
|
* the command line.
|
23
26
|
|
24
27
|
* an ability to pick up a user name & an email for a github project.
|
25
28
|
|
29
|
+
The generated project <b>is not dependent</b> on falsework.
|
30
|
+
|
26
31
|
The utility can also add skeletons for tests end executables
|
27
32
|
<i>after</i> the project generation.
|
28
33
|
|
@@ -39,7 +44,7 @@ exe NAME:: Add a new executable to an existing
|
|
39
44
|
project. You may use this command only in
|
40
45
|
the root project directory.
|
41
46
|
|
42
|
-
test NAME:: Add a new
|
47
|
+
test NAME:: Add a new minitest to an existing
|
43
48
|
project. You may use this command only in
|
44
49
|
the root project directory.
|
45
50
|
|
@@ -77,10 +82,10 @@ Add another CL util to the existing project:
|
|
77
82
|
.../foobar
|
78
83
|
% falsework exe foo
|
79
84
|
|
80
|
-
(It will appear in bin
|
85
|
+
(It will appear in <tt>bin/</tt> sub-directory.)
|
81
86
|
|
82
87
|
Add another test file:
|
83
88
|
|
84
89
|
% falsework test foo
|
85
90
|
|
86
|
-
(It will appear in test
|
91
|
+
(It will appear in <tt>test/</tt> sub-directory.)
|
data/Rakefile
CHANGED
@@ -1,14 +1,36 @@
|
|
1
1
|
# -*-ruby-*-
|
2
2
|
|
3
|
-
require 'erb'
|
4
3
|
require 'rake'
|
5
4
|
require 'rake/gempackagetask'
|
6
5
|
require 'rake/clean'
|
7
6
|
require 'rake/rdoctask'
|
8
7
|
require 'rake/testtask'
|
9
8
|
|
9
|
+
require_relative 'test/rake_git'
|
10
10
|
NAME = 'falsework'
|
11
11
|
|
12
|
+
#
|
13
|
+
# Generate dynamic targets
|
14
|
+
#
|
15
|
+
require_relative 'test/rake_erb_templates'
|
16
|
+
|
17
|
+
ERB_DYN_SKELETON = erb_skeletons(NAME, 'naive')
|
18
|
+
ERB_DYN_SKELETON.each {|k, v|
|
19
|
+
file k => [v] do |t|
|
20
|
+
erb_make(NAME, t.name, t.prerequisites[0])
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
desc "Generate some erb templates for naive template"
|
25
|
+
task naive: ERB_DYN_SKELETON.keys
|
26
|
+
|
27
|
+
CLOBBER.concat ERB_DYN_SKELETON.keys
|
28
|
+
#pp CLOBBER
|
29
|
+
|
30
|
+
#
|
31
|
+
# Gem staff
|
32
|
+
#
|
33
|
+
|
12
34
|
spec = Gem::Specification.new {|i|
|
13
35
|
i.name = NAME
|
14
36
|
i.version = `bin/#{i.name} -V`
|
@@ -18,13 +40,8 @@ spec = Gem::Specification.new {|i|
|
|
18
40
|
i.homepage = "http://github.com/gromnitsky/#{i.name}"
|
19
41
|
i.platform = Gem::Platform::RUBY
|
20
42
|
i.required_ruby_version = '>= 1.9.2'
|
21
|
-
i.files =
|
22
|
-
|
23
|
-
f.exclude('test/templates/*')
|
24
|
-
f.include('test/templates/.keep_me')
|
25
|
-
f.include(Dir.glob('lib/**/*', File::FNM_DOTMATCH))
|
26
|
-
f.exclude('lib/**/{.*,*}/.gitignore')
|
27
|
-
}
|
43
|
+
i.files = git_ls('.')
|
44
|
+
i.files.concat ERB_DYN_SKELETON.keys.map {|i| i.sub(/#{Dir.pwd}\//, '') }
|
28
45
|
|
29
46
|
i.executables = FileList['bin/*'].gsub(/^bin\//, '')
|
30
47
|
i.default_executable = i.name
|
@@ -51,19 +68,3 @@ end
|
|
51
68
|
Rake::TestTask.new do |i|
|
52
69
|
i.test_files = FileList['test/test_*.rb']
|
53
70
|
end
|
54
|
-
|
55
|
-
|
56
|
-
#
|
57
|
-
# Generate dynamic targets
|
58
|
-
#
|
59
|
-
require_relative 'test/find_erb_templates'
|
60
|
-
|
61
|
-
ERB_DYN_SKELETON = erb_skeletons(NAME, 'naive')
|
62
|
-
ERB_DYN_SKELETON.each {|k, v|
|
63
|
-
file k => [v] do |t|
|
64
|
-
erb_make(NAME, t.name, t.prerequisites[0])
|
65
|
-
end
|
66
|
-
}
|
67
|
-
|
68
|
-
desc "Generate some erb templates for naive template"
|
69
|
-
task naive: ERB_DYN_SKELETON.keys
|
data/bin/falsework
CHANGED
@@ -47,15 +47,23 @@ when /exe|test/
|
|
47
47
|
u.veputs(1, 'OK')
|
48
48
|
}
|
49
49
|
when 'new'
|
50
|
-
Utils.errx(1, 'project name cannot start with a digit') if ARGV[1].strip[0] =~ /\d/
|
51
50
|
if File.dirname(ARGV[1]) != '.'
|
52
51
|
Dir.chdir(File.dirname(ARGV[1])) rescue Utils.errx(1, "cannot chdir to '#{File.dirname(ARGV[1])}'")
|
53
52
|
ARGV[1] = File.basename ARGV[1]
|
54
53
|
end
|
54
|
+
Utils.errx(1, 'project name cannot start with a digit') if ARGV[1].strip[0] =~ /\d/
|
55
55
|
|
56
56
|
m = Mould.new(ARGV[1], $conf[:user], $conf[:email], $conf[:gecos])
|
57
57
|
m.verbose = true if $conf[:verbose] > 0
|
58
58
|
m.project_seed($conf[:template], nil)
|
59
|
+
|
60
|
+
# create a git repository
|
61
|
+
Dir.chdir ARGV[1]
|
62
|
+
u.veputs(1, "Creating a git repository in #{Dir.pwd}... __NNL__")
|
63
|
+
g = Git.init
|
64
|
+
g.add('.')
|
65
|
+
g.commit("Initial import from #{Falsework::Meta::NAME} #{Falsework::Meta::VERSION}.")
|
66
|
+
u.veputs(1, 'OK')
|
59
67
|
else
|
60
68
|
Utils.errx(1, "unknown command: " + ARGV[0])
|
61
69
|
end
|
data/doc/NEWS.rdoc
ADDED
data/doc/README.rdoc
CHANGED
@@ -13,16 +13,21 @@ Ruby.
|
|
13
13
|
|
14
14
|
The falsework utility generates a scaffold which have:
|
15
15
|
|
16
|
-
*
|
16
|
+
* auto-created git (but not github) project;
|
17
17
|
|
18
|
-
*
|
18
|
+
* <tt>gem</tt> (a file list is pulled from the git repository, no more
|
19
|
+
missing files in gems!), <tt>doc</tt>, <tt>test</tt> targers;
|
19
20
|
|
20
|
-
|
21
|
+
* easy to use configuraton parser/loader. This includes scanning for:
|
22
|
+
|
23
|
+
* env variable(s);
|
21
24
|
* the flat YAML configuration file;
|
22
25
|
* the command line.
|
23
26
|
|
24
27
|
* an ability to pick up a user name & an email for a github project.
|
25
28
|
|
29
|
+
The generated project <b>is not dependent</b> on falsework.
|
30
|
+
|
26
31
|
The utility can also add skeletons for tests end executables
|
27
32
|
<i>after</i> the project generation.
|
28
33
|
|
@@ -39,7 +44,7 @@ exe NAME:: Add a new executable to an existing
|
|
39
44
|
project. You may use this command only in
|
40
45
|
the root project directory.
|
41
46
|
|
42
|
-
test NAME:: Add a new
|
47
|
+
test NAME:: Add a new minitest to an existing
|
43
48
|
project. You may use this command only in
|
44
49
|
the root project directory.
|
45
50
|
|
@@ -77,10 +82,10 @@ Add another CL util to the existing project:
|
|
77
82
|
.../foobar
|
78
83
|
% falsework exe foo
|
79
84
|
|
80
|
-
(It will appear in bin
|
85
|
+
(It will appear in <tt>bin/</tt> sub-directory.)
|
81
86
|
|
82
87
|
Add another test file:
|
83
88
|
|
84
89
|
% falsework test foo
|
85
90
|
|
86
|
-
(It will appear in test
|
91
|
+
(It will appear in <tt>test/</tt> sub-directory.)
|
data/doc/TODO.rdoc
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
+ create a git repository automatically for a new project
|
2
|
+
+ generate a gem file list from git ls-tree
|
3
|
+
+ check for every generated file in naive test template generation
|
4
|
+
- an ability to upgrade project to a newest template
|
5
|
+
- more templates (a light one?)
|
6
|
+
- write a small tutorial 'how to write a template'
|
7
|
+
- release to rubygems.org (it must run test, pull to github, tag, create
|
8
|
+
gem & upload it)
|
3
9
|
+ generate utils.rb.erb from the current falsework utils.rb
|
4
10
|
+ the config in home dir
|
data/lib/falsework/meta.rb
CHANGED
@@ -6,6 +6,8 @@ require 'rake/clean'
|
|
6
6
|
require 'rake/rdoctask'
|
7
7
|
require 'rake/testtask'
|
8
8
|
|
9
|
+
require_relative 'test/rake_git'
|
10
|
+
|
9
11
|
spec = Gem::Specification.new {|i|
|
10
12
|
i.name = '<%= @project %>'
|
11
13
|
i.version = `bin/#{i.name} -V`
|
@@ -15,8 +17,7 @@ spec = Gem::Specification.new {|i|
|
|
15
17
|
i.homepage = "http://github.com/<%= @user %>/#{i.name}"
|
16
18
|
i.platform = Gem::Platform::RUBY
|
17
19
|
i.required_ruby_version = '>= <%= RUBY_VERSION %>'
|
18
|
-
i.files =
|
19
|
-
'etc/*', '[A-Z]*', 'test/**/*']
|
20
|
+
i.files = git_ls('.')
|
20
21
|
|
21
22
|
i.executables = FileList['bin/*'].gsub(/^bin\//, '')
|
22
23
|
i.default_executable = i.name
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*-ruby-*-
|
3
|
+
# :erb:
|
4
|
+
|
5
|
+
require 'git'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
# Return a list of files in a git repository _repdir_
|
9
|
+
def git_ls(repdir, ignore_some = true)
|
10
|
+
ignore = ['/?\.gitignore$']
|
11
|
+
|
12
|
+
r = []
|
13
|
+
g = Git.open repdir
|
14
|
+
g.ls_files.each {|i, v|
|
15
|
+
next if ignore_some && ignore.index {|ign| i.match(/#{ign}/) }
|
16
|
+
r << i
|
17
|
+
}
|
18
|
+
r
|
19
|
+
end
|
20
|
+
|
21
|
+
pp git_ls('.') if __FILE__ == $0
|
22
|
+
|
23
|
+
# Don't remove this: 2010-12-22T19:42:32+02:00 falsework 0.1.2
|
data/test/rake_git.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*-ruby-*-
|
3
|
+
# :erb:
|
4
|
+
|
5
|
+
require 'git'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
# Return a list of files in a git repository _repdir_
|
9
|
+
def git_ls(repdir, ignore_some = true)
|
10
|
+
ignore = ['/?\.gitignore$']
|
11
|
+
|
12
|
+
r = []
|
13
|
+
g = Git.open repdir
|
14
|
+
g.ls_files.each {|i, v|
|
15
|
+
next if ignore_some && ignore.index {|ign| i.match(/#{ign}/) }
|
16
|
+
r << i
|
17
|
+
}
|
18
|
+
r
|
19
|
+
end
|
20
|
+
|
21
|
+
pp git_ls('.') if __FILE__ == $0
|
data/test/test_exe.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestFalsework < MiniTest::Unit::TestCase
|
4
|
+
CMD = cmd('falsework') # get path to the exe & cd to tests directory
|
5
|
+
|
6
|
+
def setup
|
7
|
+
# this runs every time before test_*
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_project_list
|
11
|
+
r = cmd_run "#{CMD} list"
|
12
|
+
assert_equal(0, r[0])
|
13
|
+
assert_match(/naive\n/, r[2])
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_project_new
|
17
|
+
rm_rf 'templates/foo'
|
18
|
+
r = cmd_run "#{CMD} new templates/foo -v"
|
19
|
+
# pp r
|
20
|
+
assert_equal(0, r[0], r)
|
21
|
+
|
22
|
+
out = r[2].split("\n")
|
23
|
+
assert_match(/^Project path: \//, out[0])
|
24
|
+
assert_equal("L: README.rdoc => doc/README.rdoc", out[-2])
|
25
|
+
assert_match(/Creating a git repository in .+... OK/, out[-1])
|
26
|
+
|
27
|
+
tree = ["templates/foo/.git",
|
28
|
+
"templates/foo/.gitignore",
|
29
|
+
"templates/foo/README.rdoc",
|
30
|
+
"templates/foo/Rakefile",
|
31
|
+
"templates/foo/bin",
|
32
|
+
"templates/foo/bin/foo",
|
33
|
+
"templates/foo/doc",
|
34
|
+
"templates/foo/doc/LICENSE",
|
35
|
+
"templates/foo/doc/NEWS.rdoc",
|
36
|
+
"templates/foo/doc/README.rdoc",
|
37
|
+
"templates/foo/etc",
|
38
|
+
"templates/foo/etc/foo.yaml",
|
39
|
+
"templates/foo/lib",
|
40
|
+
"templates/foo/lib/foo",
|
41
|
+
"templates/foo/lib/foo/meta.rb",
|
42
|
+
"templates/foo/lib/foo/utils.rb",
|
43
|
+
"templates/foo/test",
|
44
|
+
"templates/foo/test/helper.rb",
|
45
|
+
"templates/foo/test/rake_git.rb",
|
46
|
+
"templates/foo/test/test_foo.rb"]
|
47
|
+
|
48
|
+
assert_equal(tree,
|
49
|
+
Dir.glob('templates/foo/**/*', File::FNM_DOTMATCH).sort.delete_if {|i|
|
50
|
+
i.match(/\.\.?$/) || i.match(/\.git[^i]/)
|
51
|
+
})
|
52
|
+
|
53
|
+
# add files
|
54
|
+
origdir = pwd
|
55
|
+
cd 'templates/foo'
|
56
|
+
|
57
|
+
r = cmd_run "../../#{CMD} exe qqq"
|
58
|
+
assert_equal(0, r[0])
|
59
|
+
assert_equal(true, File.executable?('bin/qqq'))
|
60
|
+
|
61
|
+
r = cmd_run "../../#{CMD} test qqq"
|
62
|
+
assert_equal(0, r[0])
|
63
|
+
assert_equal(true, File.exist?('test/test_qqq.rb'))
|
64
|
+
|
65
|
+
cd origdir
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_project_invalid_name
|
69
|
+
r = cmd_run "#{CMD} new 123"
|
70
|
+
assert_equal(1, r[0])
|
71
|
+
assert_match(/project name cannot start with a digit/, r[1])
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 0
|
8
7
|
- 1
|
9
|
-
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexander Gromnitsky
|
@@ -57,32 +57,37 @@ extra_rdoc_files:
|
|
57
57
|
- doc/LICENSE
|
58
58
|
- doc/README.rdoc
|
59
59
|
- doc/TODO.rdoc
|
60
|
+
- doc/NEWS.rdoc
|
60
61
|
files:
|
62
|
+
- README.rdoc
|
63
|
+
- Rakefile
|
61
64
|
- bin/falsework
|
62
65
|
- doc/LICENSE
|
66
|
+
- doc/NEWS.rdoc
|
63
67
|
- doc/README.rdoc
|
64
68
|
- doc/TODO.rdoc
|
65
69
|
- etc/falsework.yaml
|
66
|
-
- Rakefile
|
67
|
-
- README.rdoc
|
68
|
-
- test/helper.rb
|
69
|
-
- test/test_utils.rb
|
70
|
-
- test/find_erb_templates.rb
|
71
|
-
- test/templates/.keep_me
|
72
70
|
- lib/falsework/meta.rb
|
73
|
-
- lib/falsework/
|
71
|
+
- lib/falsework/mould.rb
|
72
|
+
- lib/falsework/templates/naive/.gitignore.erb
|
73
|
+
- lib/falsework/templates/naive/README.rdoc.erb
|
74
|
+
- lib/falsework/templates/naive/Rakefile.erb
|
75
|
+
- lib/falsework/templates/naive/bin/.@project..erb
|
74
76
|
- lib/falsework/templates/naive/doc/LICENSE.erb
|
77
|
+
- lib/falsework/templates/naive/doc/NEWS.rdoc.erb
|
75
78
|
- lib/falsework/templates/naive/doc/README.rdoc.erb
|
76
|
-
- lib/falsework/templates/naive/
|
77
|
-
- lib/falsework/templates/naive/
|
79
|
+
- lib/falsework/templates/naive/etc/.@project..yaml.erb
|
80
|
+
- lib/falsework/templates/naive/lib/.@project./meta.rb.erb
|
78
81
|
- lib/falsework/templates/naive/test/test_.@project..rb.erb
|
82
|
+
- lib/falsework/utils.rb
|
83
|
+
- test/helper.rb
|
84
|
+
- test/rake_erb_templates.rb
|
85
|
+
- test/rake_git.rb
|
86
|
+
- test/templates/.keep_me
|
87
|
+
- test/test_exe.rb
|
79
88
|
- lib/falsework/templates/naive/lib/.@project./utils.rb.erb
|
80
|
-
- lib/falsework/templates/naive/
|
81
|
-
- lib/falsework/templates/naive/
|
82
|
-
- lib/falsework/templates/naive/bin/.@project..erb
|
83
|
-
- lib/falsework/templates/naive/README.rdoc.erb
|
84
|
-
- lib/falsework/templates/naive/.gitignore.erb
|
85
|
-
- lib/falsework/mould.rb
|
89
|
+
- lib/falsework/templates/naive/test/helper.rb.erb
|
90
|
+
- lib/falsework/templates/naive/test/rake_git.rb.erb
|
86
91
|
has_rdoc: true
|
87
92
|
homepage: http://github.com/gromnitsky/falsework
|
88
93
|
licenses: []
|
@@ -119,4 +124,4 @@ signing_key:
|
|
119
124
|
specification_version: 3
|
120
125
|
summary: A primitive scaffold generator for writing CLI programs in Ruby.
|
121
126
|
test_files:
|
122
|
-
- test/
|
127
|
+
- test/test_exe.rb
|
data/test/test_utils.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
|
3
|
-
class TestFalsework < MiniTest::Unit::TestCase
|
4
|
-
CMD = cmd('falsework') # get path to the exe & cd to tests directory
|
5
|
-
|
6
|
-
def setup
|
7
|
-
# this runs every time before test_*
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_project_list
|
11
|
-
r = cmd_run "#{CMD} list"
|
12
|
-
assert_equal(0, r[0])
|
13
|
-
assert_match(/naive\n/, r[2])
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_project_new
|
17
|
-
rm_rf 'templates/foo'
|
18
|
-
r = cmd_run "#{CMD} new templates/foo -v"
|
19
|
-
# pp r
|
20
|
-
assert_equal(0, r[0], r)
|
21
|
-
|
22
|
-
# check for first & last lines only
|
23
|
-
out = r[2].split("\n")
|
24
|
-
assert_match(/^Project path: \//, out.first)
|
25
|
-
assert_equal("L: README.rdoc => doc/README.rdoc", out.last)
|
26
|
-
|
27
|
-
# add files
|
28
|
-
origdir = pwd
|
29
|
-
cd 'templates/foo'
|
30
|
-
|
31
|
-
r = cmd_run "../../#{CMD} exe qqq"
|
32
|
-
assert_equal(0, r[0])
|
33
|
-
assert_equal(true, File.executable?('bin/qqq'))
|
34
|
-
|
35
|
-
r = cmd_run "../../#{CMD} test qqq"
|
36
|
-
assert_equal(0, r[0])
|
37
|
-
assert_equal(true, File.exist?('test/test_qqq.rb'))
|
38
|
-
|
39
|
-
cd origdir
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_project_invalid_name
|
43
|
-
r = cmd_run "#{CMD} new 123"
|
44
|
-
assert_equal(1, r[0])
|
45
|
-
assert_match(/project name cannot start with a digit/, r[1])
|
46
|
-
end
|
47
|
-
end
|
File without changes
|