falsework 0.2.2 → 0.2.3
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 +17 -1
- data/Rakefile +1 -0
- data/bin/falsework +3 -2
- data/doc/NEWS.rdoc +15 -0
- data/doc/README.rdoc +17 -1
- data/lib/falsework/meta.rb +1 -1
- data/lib/falsework/mould.rb +58 -18
- data/lib/falsework/templates/naive/README.rdoc.erb +4 -5
- data/lib/falsework/templates/naive/Rakefile.erb +1 -0
- data/lib/falsework/templates/naive/doc/#util.rdoc.erb +55 -0
- data/lib/falsework/templates/naive/doc/README.rdoc.erb +4 -5
- data/test/test_exe.rb +1 -0
- metadata +5 -4
data/README.rdoc
CHANGED
@@ -43,7 +43,8 @@ new NAME:: Create a new project. It creates a directory
|
|
43
43
|
The following commands works only from the root project directory:
|
44
44
|
|
45
45
|
exe NAME:: Add a new executable to an existing
|
46
|
-
project
|
46
|
+
project and a corresponding <tt>.rdoc</tt>
|
47
|
+
file in <tt>doc</tt> subdirectory.
|
47
48
|
|
48
49
|
test NAME:: Add a new minitest.
|
49
50
|
|
@@ -76,6 +77,7 @@ The options are as follows:
|
|
76
77
|
Version & name of your project can be located at generated
|
77
78
|
<tt>myproject/lib/myproject/meta.rb</tt> file.
|
78
79
|
|
80
|
+
|
79
81
|
==Examples
|
80
82
|
|
81
83
|
Create a new project:
|
@@ -95,3 +97,17 @@ Add another test file:
|
|
95
97
|
% falsework test foo
|
96
98
|
|
97
99
|
(It will appear in <tt>test/</tt> sub-directory.)
|
100
|
+
|
101
|
+
|
102
|
+
==Bugs
|
103
|
+
|
104
|
+
While falsework supports symlinks in templates, rubygems replaces
|
105
|
+
symlinks with its corresponding source files. That is why you'll get 2
|
106
|
+
<tt>README.rdoc</tt> files in generated project when it was intended to
|
107
|
+
have 1 in <tt>doc</tt> subdirectory and the symlink to it in the root
|
108
|
+
project directory.
|
109
|
+
|
110
|
+
If you think that this is pathetic, then just grab the source of
|
111
|
+
falsework, place its directory somewhere, create a symlink to
|
112
|
+
<tt>/where/is/your/clone/falsework/bin/falsework</tt> file in one of
|
113
|
+
your PATH directories and forget about the gem and this bug.
|
data/Rakefile
CHANGED
@@ -35,6 +35,7 @@ spec = Gem::Specification.new {|i|
|
|
35
35
|
i.name = NAME
|
36
36
|
i.version = `bin/#{i.name} -V`
|
37
37
|
i.summary = "A primitive scaffold generator for writing CLI programs in Ruby."
|
38
|
+
i.description = i.summary
|
38
39
|
i.author = 'Alexander Gromnitsky'
|
39
40
|
i.email = 'alexander.gromnitsky@gmail.com'
|
40
41
|
i.homepage = "http://github.com/gromnitsky/#{i.name}"
|
data/bin/falsework
CHANGED
@@ -44,8 +44,9 @@ when 'list'
|
|
44
44
|
when /exe|test/
|
45
45
|
m = Mould.new(File.basename(Dir.pwd), $conf[:user], $conf[:email], $conf[:gecos])
|
46
46
|
ARGV[1..-1].each {|i|
|
47
|
-
u.veputs(1, "Generating #{i}
|
48
|
-
u.veputs(1, m.create($conf[:template], ARGV[0], i) + '... __NNL__')
|
47
|
+
u.veputs(1, "Generating #{i}... __NNL__")
|
48
|
+
# u.veputs(1, m.create($conf[:template], ARGV[0], i) + '... __NNL__')
|
49
|
+
m.add($conf[:template], ARGV[0], i)
|
49
50
|
u.veputs(1, 'OK')
|
50
51
|
}
|
51
52
|
when 'upgrade'
|
data/doc/NEWS.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
=== 0.2.3
|
2
|
+
|
3
|
+
Mon Jan 3 12:41:16 EET 2011
|
4
|
+
|
5
|
+
- 'exe' command will add 2 files: an executable and a corresponding
|
6
|
+
.rdoc file.
|
7
|
+
|
8
|
+
- Fix a small bug in naive template.
|
9
|
+
|
10
|
+
=== 0.2.2
|
11
|
+
|
12
|
+
Sun Dec 26 04:48:46 EET 2010
|
13
|
+
|
14
|
+
- An ability to upgrade a project from a newest template.
|
15
|
+
|
1
16
|
=== 0.1.2
|
2
17
|
|
3
18
|
Wed Dec 22 19:09:01 EET 2010
|
data/doc/README.rdoc
CHANGED
@@ -43,7 +43,8 @@ new NAME:: Create a new project. It creates a directory
|
|
43
43
|
The following commands works only from the root project directory:
|
44
44
|
|
45
45
|
exe NAME:: Add a new executable to an existing
|
46
|
-
project
|
46
|
+
project and a corresponding <tt>.rdoc</tt>
|
47
|
+
file in <tt>doc</tt> subdirectory.
|
47
48
|
|
48
49
|
test NAME:: Add a new minitest.
|
49
50
|
|
@@ -76,6 +77,7 @@ The options are as follows:
|
|
76
77
|
Version & name of your project can be located at generated
|
77
78
|
<tt>myproject/lib/myproject/meta.rb</tt> file.
|
78
79
|
|
80
|
+
|
79
81
|
==Examples
|
80
82
|
|
81
83
|
Create a new project:
|
@@ -95,3 +97,17 @@ Add another test file:
|
|
95
97
|
% falsework test foo
|
96
98
|
|
97
99
|
(It will appear in <tt>test/</tt> sub-directory.)
|
100
|
+
|
101
|
+
|
102
|
+
==Bugs
|
103
|
+
|
104
|
+
While falsework supports symlinks in templates, rubygems replaces
|
105
|
+
symlinks with its corresponding source files. That is why you'll get 2
|
106
|
+
<tt>README.rdoc</tt> files in generated project when it was intended to
|
107
|
+
have 1 in <tt>doc</tt> subdirectory and the symlink to it in the root
|
108
|
+
project directory.
|
109
|
+
|
110
|
+
If you think that this is pathetic, then just grab the source of
|
111
|
+
falsework, place its directory somewhere, create a symlink to
|
112
|
+
<tt>/where/is/your/clone/falsework/bin/falsework</tt> file in one of
|
113
|
+
your PATH directories and forget about the gem and this bug.
|
data/lib/falsework/meta.rb
CHANGED
data/lib/falsework/mould.rb
CHANGED
@@ -4,6 +4,28 @@ require 'digest/md5'
|
|
4
4
|
|
5
5
|
require_relative 'trestle'
|
6
6
|
|
7
|
+
# Class Mould heavily uses 'naive' template. Theoretically it can manage
|
8
|
+
# any template as long as it has files mentioned in #add.
|
9
|
+
#
|
10
|
+
# The directory with template may have files beginning with _#_ char
|
11
|
+
# which will be ignored in #project_seed (a method that creates a shiny
|
12
|
+
# new project form a template).
|
13
|
+
#
|
14
|
+
# If you need to run through erb not only the contents of a file in a
|
15
|
+
# template but it name itself, then use the following convention:
|
16
|
+
#
|
17
|
+
# %%VARIABLE%%
|
18
|
+
#
|
19
|
+
# which is equivalent of erb's: <%= VARIABLE %>. See naive template
|
20
|
+
# directory for examples.
|
21
|
+
#
|
22
|
+
# In the template files you may use any Mould instance variables. The
|
23
|
+
# most usefull are:
|
24
|
+
#
|
25
|
+
# [@project] A project name.
|
26
|
+
# [@user] Github user name.
|
27
|
+
# [@email] User email.
|
28
|
+
# [@gecos] A full user name.
|
7
29
|
module Falsework
|
8
30
|
class Mould
|
9
31
|
GITCONFIG = '~/.gitconfig'
|
@@ -109,37 +131,55 @@ module Falsework
|
|
109
131
|
r
|
110
132
|
end
|
111
133
|
|
112
|
-
#
|
134
|
+
# Add an executable or a test from the _template_.
|
113
135
|
#
|
114
136
|
# [mode] Is either 'exe' or 'test'.
|
115
137
|
# [what] A test/exe file to create.
|
116
138
|
#
|
117
139
|
# Return a name of a created file.
|
118
|
-
def
|
140
|
+
def add(template, mode, what)
|
119
141
|
start = Mould.templates[template || TEMPLATE_DEFAULT] || Trestle.errx(1, "no such template: #{template}")
|
142
|
+
r = []
|
120
143
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
144
|
+
case mode
|
145
|
+
when 'exe'
|
146
|
+
# script
|
147
|
+
f = {}
|
148
|
+
f[:from] = start + '/' + 'bin/%%@project%%.erb'
|
149
|
+
f[:exe] = true
|
150
|
+
f[:to] = "bin/#{what}"
|
151
|
+
r << f
|
152
|
+
|
153
|
+
# doc (reading an 'ignored' file from the template)
|
154
|
+
f = {}
|
155
|
+
f[:from] = start + '/' + 'doc/#util.rdoc.erb'
|
156
|
+
f[:exe] = false
|
157
|
+
f[:to] = "doc/#{what}.rdoc"
|
158
|
+
r << f
|
159
|
+
when 'test'
|
160
|
+
f = {}
|
161
|
+
f[:from] = start + '/' + 'test/test_%%@project%%.rb.erb'
|
162
|
+
f[:exe] = false
|
163
|
+
f[:to] = "#{mode}/test_#{what}.rb"
|
164
|
+
r << f
|
165
|
+
else
|
166
|
+
fail "invalid mode #{mode}"
|
167
|
+
end
|
168
|
+
|
169
|
+
r.each {|i|
|
170
|
+
Mould.extract(i[:from], binding, i[:to])
|
171
|
+
File.chmod(0744, i[:to]) if i[:exe]
|
172
|
+
}
|
134
173
|
end
|
135
174
|
|
136
175
|
# Walk through a directory tree, executing a block for each file or
|
137
|
-
# directory.
|
176
|
+
# directory. Ignores _._, _.._ and files starting with _#_
|
177
|
+
# character.
|
138
178
|
#
|
139
179
|
# [start] The directory to start with.
|
140
180
|
def self.traverse(start, &block)
|
141
|
-
l = Dir.glob(start + '/*', File::FNM_DOTMATCH).delete_if {
|
142
|
-
|
181
|
+
l = Dir.glob(start + '/*', File::FNM_DOTMATCH).delete_if {|i|
|
182
|
+
i.match(/\/?\.\.?$/) || i.match(/^#|\/#/)
|
143
183
|
}
|
144
184
|
# stop if directory is empty (contains only . and ..)
|
145
185
|
return if l.size == 0
|
@@ -1,7 +1,6 @@
|
|
1
1
|
=Name
|
2
2
|
|
3
|
-
<%= @project %>--
|
4
|
-
while yo return.
|
3
|
+
<%= @project %>-- [TODO: write a summary here.]
|
5
4
|
|
6
5
|
|
7
6
|
==Synopsis
|
@@ -11,7 +10,7 @@ while yo return.
|
|
11
10
|
|
12
11
|
==Description
|
13
12
|
|
14
|
-
The <%= @project %> utility
|
13
|
+
The <%= @project %> utility [TODO: write a description here.]
|
15
14
|
|
16
15
|
The options are as follows:
|
17
16
|
|
@@ -22,13 +21,13 @@ The options are as follows:
|
|
22
21
|
it contains <tt>/</tt> in it, the list from
|
23
22
|
<tt>--config-dirs</tt> is ignored.
|
24
23
|
|
25
|
-
-V:: Show
|
24
|
+
-V:: Show version and exit.
|
26
25
|
|
27
26
|
-v:: Be more verbose. You can supply it several
|
28
27
|
times, viz. <tt>-vv</tt> dumps even more
|
29
28
|
debug info.
|
30
29
|
|
31
|
-
--foobar NAME
|
30
|
+
--foobar NAME:: Huh?
|
32
31
|
|
33
32
|
==Configuration
|
34
33
|
|
@@ -12,6 +12,7 @@ spec = Gem::Specification.new {|i|
|
|
12
12
|
i.name = '<%= @project %>'
|
13
13
|
i.version = `bin/#{i.name} -V`
|
14
14
|
i.summary = 'TO DO: fill this variable'
|
15
|
+
i.description = i.summary
|
15
16
|
i.author = '<%= @gecos %>'
|
16
17
|
i.email = '<%= @email %>'
|
17
18
|
i.homepage = "http://github.com/<%= @user %>/#{i.name}"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
=Name
|
2
|
+
|
3
|
+
<%= what %>--[TODO: write a summary here.]
|
4
|
+
|
5
|
+
|
6
|
+
==Synopsis
|
7
|
+
|
8
|
+
<%= what %> [options]
|
9
|
+
|
10
|
+
|
11
|
+
==Description
|
12
|
+
|
13
|
+
The <%= what %> utility [TODO: write a description here.]
|
14
|
+
|
15
|
+
The options are as follows:
|
16
|
+
|
17
|
+
--config-dirs:: List all possible locations for the
|
18
|
+
configuration file. The first found wins.
|
19
|
+
|
20
|
+
--config NAME:: The name of the configuration file. If
|
21
|
+
it contains <tt>/</tt> in it, the list from
|
22
|
+
<tt>--config-dirs</tt> is ignored.
|
23
|
+
|
24
|
+
-V:: Show version and exit.
|
25
|
+
|
26
|
+
-v:: Be more verbose. You can supply it several
|
27
|
+
times, viz. <tt>-vv</tt> dumps even more
|
28
|
+
debug info.
|
29
|
+
|
30
|
+
--foobar NAME:: Huh?
|
31
|
+
|
32
|
+
==Configuration
|
33
|
+
|
34
|
+
<%= what %> looks for its configuration at 3 places at start up.
|
35
|
+
|
36
|
+
1. At <tt><%= @project.upcase %>_CONF</tt> env variable.
|
37
|
+
(Its format is exactly similar to CL options.)
|
38
|
+
|
39
|
+
2. At the configuration file. Its default name is
|
40
|
+
<tt><%= @project %>.yaml</tt> and it can be stored in several
|
41
|
+
system directories which are observable by <tt>--config--dirs</tt> CL
|
42
|
+
option.
|
43
|
+
|
44
|
+
3. At command line.
|
45
|
+
|
46
|
+
Higher number levels overrides the values from lower number levels.
|
47
|
+
|
48
|
+
The configuration file must be in YAML format. Look into <tt>`gem env
|
49
|
+
gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for samples.
|
50
|
+
|
51
|
+
|
52
|
+
==Examples
|
53
|
+
|
54
|
+
% <%= what %> --config-dirs
|
55
|
+
% <%= what %> -V
|
@@ -1,7 +1,6 @@
|
|
1
1
|
=Name
|
2
2
|
|
3
|
-
<%= @project %>--
|
4
|
-
while yo return.
|
3
|
+
<%= @project %>-- [TODO: write a summary here.]
|
5
4
|
|
6
5
|
|
7
6
|
==Synopsis
|
@@ -11,7 +10,7 @@ while yo return.
|
|
11
10
|
|
12
11
|
==Description
|
13
12
|
|
14
|
-
The <%= @project %> utility
|
13
|
+
The <%= @project %> utility [TODO: write a description here.]
|
15
14
|
|
16
15
|
The options are as follows:
|
17
16
|
|
@@ -22,13 +21,13 @@ The options are as follows:
|
|
22
21
|
it contains <tt>/</tt> in it, the list from
|
23
22
|
<tt>--config-dirs</tt> is ignored.
|
24
23
|
|
25
|
-
-V:: Show
|
24
|
+
-V:: Show version and exit.
|
26
25
|
|
27
26
|
-v:: Be more verbose. You can supply it several
|
28
27
|
times, viz. <tt>-vv</tt> dumps even more
|
29
28
|
debug info.
|
30
29
|
|
31
|
-
--foobar NAME
|
30
|
+
--foobar NAME:: Huh?
|
32
31
|
|
33
32
|
==Configuration
|
34
33
|
|
data/test/test_exe.rb
CHANGED
@@ -64,6 +64,7 @@ class TestFalsework < MiniTest::Unit::TestCase
|
|
64
64
|
r = Trestle.cmd_run "../../#{CMD} exe qqq"
|
65
65
|
assert_equal(0, r[0])
|
66
66
|
assert_equal(true, File.executable?('bin/qqq'))
|
67
|
+
assert_equal(true, File.exist?('doc/qqq.rdoc'))
|
67
68
|
|
68
69
|
r = Trestle.cmd_run "../../#{CMD} test qqq"
|
69
70
|
assert_equal(0, r[0])
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexander Gromnitsky
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-03 00:00:00 +02:00
|
18
18
|
default_executable: falsework
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
version: 1.0.1
|
48
48
|
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
|
-
description:
|
50
|
+
description: A primitive scaffold generator for writing CLI programs in Ruby.
|
51
51
|
email: alexander.gromnitsky@gmail.com
|
52
52
|
executables:
|
53
53
|
- falsework
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/falsework/templates/naive/README.rdoc.erb
|
74
74
|
- lib/falsework/templates/naive/Rakefile.erb
|
75
75
|
- lib/falsework/templates/naive/bin/%%@project%%.erb
|
76
|
+
- lib/falsework/templates/naive/doc/#util.rdoc.erb
|
76
77
|
- lib/falsework/templates/naive/doc/LICENSE.erb
|
77
78
|
- lib/falsework/templates/naive/doc/NEWS.rdoc.erb
|
78
79
|
- lib/falsework/templates/naive/doc/README.rdoc.erb
|