sow 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +622 -0
- data/HISTORY +14 -0
- data/MANIFEST +138 -0
- data/NOTES +86 -0
- data/README +157 -0
- data/bin/sow +4 -0
- data/lib/sow.rb +12 -0
- data/lib/sow/command.rb +201 -0
- data/lib/sow/context.rb +29 -0
- data/lib/sow/core_ext.rb +47 -0
- data/lib/sow/generators/base.rb +321 -0
- data/lib/sow/generators/create.rb +111 -0
- data/lib/sow/generators/delete.rb +50 -0
- data/lib/sow/generators/update.rb +47 -0
- data/lib/sow/logger.rb +73 -0
- data/lib/sow/manager.rb +101 -0
- data/lib/sow/metadata.rb +115 -0
- data/lib/sow/plugin.rb +484 -0
- data/lib/sow/script.rb +186 -0
- data/lib/sow/session.rb +150 -0
- data/meta/authors +1 -0
- data/meta/contact +1 -0
- data/meta/description +1 -0
- data/meta/homepage +1 -0
- data/meta/loadpath +2 -0
- data/meta/package +1 -0
- data/meta/project +1 -0
- data/meta/repository +1 -0
- data/meta/requires +2 -0
- data/meta/ruby +2 -0
- data/meta/version +1 -0
- data/plug/sow/seeds/bin/.meta/created +1 -0
- data/plug/sow/seeds/bin/.meta/description +1 -0
- data/plug/sow/seeds/bin/.meta/license +1 -0
- data/plug/sow/seeds/bin/.meta/package +1 -0
- data/plug/sow/seeds/bin/.meta/requires +1 -0
- data/plug/sow/seeds/bin/.meta/title +1 -0
- data/plug/sow/seeds/bin/.meta/version +1 -0
- data/plug/sow/seeds/bin/SCRIPT.rb +22 -0
- data/plug/sow/seeds/bin/template/bin/command.rb +12 -0
- data/plug/sow/seeds/hoe/SCRIPT.rb +28 -0
- data/plug/sow/seeds/hoe/template/History.txt +7 -0
- data/plug/sow/seeds/hoe/template/Manifest.txt +8 -0
- data/plug/sow/seeds/hoe/template/README.txt +49 -0
- data/plug/sow/seeds/hoe/template/Rakefile +13 -0
- data/plug/sow/seeds/hoe/template/bin/__name__ +0 -0
- data/plug/sow/seeds/hoe/template/lib/__name__.rb +4 -0
- data/plug/sow/seeds/hoe/template/test/test___name__.rb +1 -0
- data/plug/sow/seeds/license/SCRIPT.rb +27 -0
- data/plug/sow/seeds/license/template/META/license +1 -0
- data/plug/sow/seeds/license/template/gpl/LICENSE +622 -0
- data/plug/sow/seeds/license/template/lgpl/LICENSE +789 -0
- data/plug/sow/seeds/license/template/mit/LICENSE +22 -0
- data/plug/sow/seeds/ruby/COPY.yml +14 -0
- data/plug/sow/seeds/ruby/DATA.yml +8 -0
- data/plug/sow/seeds/ruby/USAGE.txt +8 -0
- data/plug/sow/seeds/ruby/script.sow.rb +17 -0
- data/plug/sow/seeds/ruby/template/COPYING +622 -0
- data/plug/sow/seeds/ruby/template/History.rdoc +18 -0
- data/plug/sow/seeds/ruby/template/README.rdoc +43 -0
- data/plug/sow/seeds/ruby/template/README.rdoc.till +43 -0
- data/plug/sow/seeds/ruby/template/Rakefile +1 -0
- data/plug/sow/seeds/ruby/template/bin/__package__ +2 -0
- data/plug/sow/seeds/ruby/template/lib/__package__.rb +3 -0
- data/plug/sow/seeds/ruby/template/meta/created +1 -0
- data/plug/sow/seeds/ruby/template/meta/description +1 -0
- data/plug/sow/seeds/ruby/template/meta/license +1 -0
- data/plug/sow/seeds/ruby/template/meta/package +1 -0
- data/plug/sow/seeds/ruby/template/meta/requires +1 -0
- data/plug/sow/seeds/ruby/template/meta/title +1 -0
- data/plug/sow/seeds/ruby/template/meta/version +1 -0
- data/plug/sow/seeds/ruby/template/setup.rb +1467 -0
- data/plug/sow/seeds/ruby/template/test/template.rb +17 -0
- data/plug/sow/seeds/testunit/COPY.yml +12 -0
- data/plug/sow/seeds/testunit/DATA.yml +23 -0
- data/plug/sow/seeds/testunit/USAGE.txt +11 -0
- data/plug/sow/seeds/testunit/_SCRIPT.rb +42 -0
- data/plug/sow/seeds/testunit/template/form/testunit +24 -0
- data/plug/sow/seeds/testunit/template/test/test_template.rb +15 -0
- data/plug/sow/seeds/website/template/assets/styles/color.css +0 -0
- data/plug/sow/seeds/website/template/assets/styles/font.css +0 -0
- data/plug/sow/seeds/website/template/assets/styles/index.css +4 -0
- data/plug/sow/seeds/website/template/assets/styles/reset.css +0 -0
- data/plug/sow/seeds/website/template/assets/styles/struct.css +0 -0
- data/plug/sow/seeds/website/template/index.html +15 -0
- data/test/features/scaffold.feature +13 -0
- data/test/features/step_definitions/cli_steps.rb +0 -0
- data/test/features/step_definitions/fixture_steps.rb +72 -0
- data/test/features/support/env.rb +41 -0
- data/test/unit/fixtures/README +5 -0
- data/test/unit/helper.rb +23 -0
- data/test/unit/test_metadata.rb +17 -0
- data/test/unit/test_scaffold.rb +37 -0
- metadata +178 -0
data/HISTORY
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
= RELEASE HISTORY
|
2
|
+
|
3
|
+
== 1.0.0 // 2009-08-30
|
4
|
+
|
5
|
+
Initial release of brand spanking new system.
|
6
|
+
|
7
|
+
Changes:
|
8
|
+
|
9
|
+
* 3 Major Enhancements
|
10
|
+
|
11
|
+
* Use spiffy new interface design.
|
12
|
+
* Promotes the use of "micro" plugins.
|
13
|
+
* Added new built-in plugins.
|
14
|
+
|
data/MANIFEST
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
#!mast bin lib meta plug test [A-Z]*
|
2
|
+
bin
|
3
|
+
bin/sow
|
4
|
+
lib
|
5
|
+
lib/sow
|
6
|
+
lib/sow/command.rb
|
7
|
+
lib/sow/context.rb
|
8
|
+
lib/sow/core_ext.rb
|
9
|
+
lib/sow/generators
|
10
|
+
lib/sow/generators/base.rb
|
11
|
+
lib/sow/generators/create.rb
|
12
|
+
lib/sow/generators/delete.rb
|
13
|
+
lib/sow/generators/update.rb
|
14
|
+
lib/sow/logger.rb
|
15
|
+
lib/sow/manager.rb
|
16
|
+
lib/sow/metadata.rb
|
17
|
+
lib/sow/plugin.rb
|
18
|
+
lib/sow/script.rb
|
19
|
+
lib/sow/session.rb
|
20
|
+
lib/sow.rb
|
21
|
+
meta
|
22
|
+
meta/authors
|
23
|
+
meta/contact
|
24
|
+
meta/description
|
25
|
+
meta/homepage
|
26
|
+
meta/loadpath
|
27
|
+
meta/package
|
28
|
+
meta/project
|
29
|
+
meta/repository
|
30
|
+
meta/requires
|
31
|
+
meta/ruby
|
32
|
+
meta/version
|
33
|
+
plug
|
34
|
+
plug/sow
|
35
|
+
plug/sow/seeds
|
36
|
+
plug/sow/seeds/bin
|
37
|
+
plug/sow/seeds/bin/.meta
|
38
|
+
plug/sow/seeds/bin/.meta/created
|
39
|
+
plug/sow/seeds/bin/.meta/description
|
40
|
+
plug/sow/seeds/bin/.meta/license
|
41
|
+
plug/sow/seeds/bin/.meta/package
|
42
|
+
plug/sow/seeds/bin/.meta/requires
|
43
|
+
plug/sow/seeds/bin/.meta/title
|
44
|
+
plug/sow/seeds/bin/.meta/version
|
45
|
+
plug/sow/seeds/bin/SCRIPT.rb
|
46
|
+
plug/sow/seeds/bin/template
|
47
|
+
plug/sow/seeds/bin/template/bin
|
48
|
+
plug/sow/seeds/bin/template/bin/command.rb
|
49
|
+
plug/sow/seeds/hoe
|
50
|
+
plug/sow/seeds/hoe/SCRIPT.rb
|
51
|
+
plug/sow/seeds/hoe/template
|
52
|
+
plug/sow/seeds/hoe/template/History.txt
|
53
|
+
plug/sow/seeds/hoe/template/Manifest.txt
|
54
|
+
plug/sow/seeds/hoe/template/README.txt
|
55
|
+
plug/sow/seeds/hoe/template/Rakefile
|
56
|
+
plug/sow/seeds/hoe/template/bin
|
57
|
+
plug/sow/seeds/hoe/template/bin/__name__
|
58
|
+
plug/sow/seeds/hoe/template/lib
|
59
|
+
plug/sow/seeds/hoe/template/lib/__name__.rb
|
60
|
+
plug/sow/seeds/hoe/template/test
|
61
|
+
plug/sow/seeds/hoe/template/test/test___name__.rb
|
62
|
+
plug/sow/seeds/license
|
63
|
+
plug/sow/seeds/license/SCRIPT.rb
|
64
|
+
plug/sow/seeds/license/template
|
65
|
+
plug/sow/seeds/license/template/META
|
66
|
+
plug/sow/seeds/license/template/META/license
|
67
|
+
plug/sow/seeds/license/template/gpl
|
68
|
+
plug/sow/seeds/license/template/gpl/LICENSE
|
69
|
+
plug/sow/seeds/license/template/lgpl
|
70
|
+
plug/sow/seeds/license/template/lgpl/LICENSE
|
71
|
+
plug/sow/seeds/license/template/mit
|
72
|
+
plug/sow/seeds/license/template/mit/LICENSE
|
73
|
+
plug/sow/seeds/ruby
|
74
|
+
plug/sow/seeds/ruby/COPY.yml
|
75
|
+
plug/sow/seeds/ruby/DATA.yml
|
76
|
+
plug/sow/seeds/ruby/USAGE.txt
|
77
|
+
plug/sow/seeds/ruby/script.sow.rb
|
78
|
+
plug/sow/seeds/ruby/template
|
79
|
+
plug/sow/seeds/ruby/template/COPYING
|
80
|
+
plug/sow/seeds/ruby/template/History.rdoc
|
81
|
+
plug/sow/seeds/ruby/template/README.rdoc
|
82
|
+
plug/sow/seeds/ruby/template/README.rdoc.till
|
83
|
+
plug/sow/seeds/ruby/template/Rakefile
|
84
|
+
plug/sow/seeds/ruby/template/bin
|
85
|
+
plug/sow/seeds/ruby/template/bin/__package__
|
86
|
+
plug/sow/seeds/ruby/template/lib
|
87
|
+
plug/sow/seeds/ruby/template/lib/__package__.rb
|
88
|
+
plug/sow/seeds/ruby/template/meta
|
89
|
+
plug/sow/seeds/ruby/template/meta/created
|
90
|
+
plug/sow/seeds/ruby/template/meta/description
|
91
|
+
plug/sow/seeds/ruby/template/meta/license
|
92
|
+
plug/sow/seeds/ruby/template/meta/package
|
93
|
+
plug/sow/seeds/ruby/template/meta/requires
|
94
|
+
plug/sow/seeds/ruby/template/meta/title
|
95
|
+
plug/sow/seeds/ruby/template/meta/version
|
96
|
+
plug/sow/seeds/ruby/template/setup.rb
|
97
|
+
plug/sow/seeds/ruby/template/test
|
98
|
+
plug/sow/seeds/ruby/template/test/template.rb
|
99
|
+
plug/sow/seeds/testunit
|
100
|
+
plug/sow/seeds/testunit/COPY.yml
|
101
|
+
plug/sow/seeds/testunit/DATA.yml
|
102
|
+
plug/sow/seeds/testunit/USAGE.txt
|
103
|
+
plug/sow/seeds/testunit/_SCRIPT.rb
|
104
|
+
plug/sow/seeds/testunit/template
|
105
|
+
plug/sow/seeds/testunit/template/form
|
106
|
+
plug/sow/seeds/testunit/template/form/testunit
|
107
|
+
plug/sow/seeds/testunit/template/test
|
108
|
+
plug/sow/seeds/testunit/template/test/test_template.rb
|
109
|
+
plug/sow/seeds/website
|
110
|
+
plug/sow/seeds/website/template
|
111
|
+
plug/sow/seeds/website/template/assets
|
112
|
+
plug/sow/seeds/website/template/assets/images
|
113
|
+
plug/sow/seeds/website/template/assets/scripts
|
114
|
+
plug/sow/seeds/website/template/assets/styles
|
115
|
+
plug/sow/seeds/website/template/assets/styles/color.css
|
116
|
+
plug/sow/seeds/website/template/assets/styles/font.css
|
117
|
+
plug/sow/seeds/website/template/assets/styles/index.css
|
118
|
+
plug/sow/seeds/website/template/assets/styles/reset.css
|
119
|
+
plug/sow/seeds/website/template/assets/styles/struct.css
|
120
|
+
plug/sow/seeds/website/template/index.html
|
121
|
+
test
|
122
|
+
test/features
|
123
|
+
test/features/scaffold.feature
|
124
|
+
test/features/step_definitions
|
125
|
+
test/features/step_definitions/cli_steps.rb
|
126
|
+
test/features/step_definitions/fixture_steps.rb
|
127
|
+
test/features/support
|
128
|
+
test/features/support/env.rb
|
129
|
+
test/unit
|
130
|
+
test/unit/fixtures
|
131
|
+
test/unit/fixtures/README
|
132
|
+
test/unit/helper.rb
|
133
|
+
test/unit/test_metadata.rb
|
134
|
+
test/unit/test_scaffold.rb
|
135
|
+
NOTES
|
136
|
+
README
|
137
|
+
HISTORY
|
138
|
+
COPYING
|
data/NOTES
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= NOTES ON SOW
|
2
|
+
|
3
|
+
== Commandline Interface of Plugins
|
4
|
+
|
5
|
+
=== Option 1
|
6
|
+
|
7
|
+
The traditional approach is to allow a plugin to specify any commandline
|
8
|
+
arguments and/or options it may want to generate scaffolding.
|
9
|
+
For example, we might see something like:
|
10
|
+
|
11
|
+
sow ruby myapp --no-bin --man
|
12
|
+
|
13
|
+
Which would scaffold a Ruby project named 'myapp' with a manpage
|
14
|
+
entry but no defualt executable. Allowing this flexibility in
|
15
|
+
designatin plugin options, we can make our plugins quite feature
|
16
|
+
rich.
|
17
|
+
|
18
|
+
We wouldn't want to get too crazy though, as in many cases it would
|
19
|
+
just as well to have an additional plugin. For example, we will
|
20
|
+
want to have a cucumber plugin so we can create features, thus
|
21
|
+
adding --cucumber option to the ruby plugin is purely a convenience.
|
22
|
+
One could just as well do:
|
23
|
+
|
24
|
+
$ sow ruby myapp
|
25
|
+
$ sow cucumber myapp
|
26
|
+
|
27
|
+
Instead of
|
28
|
+
|
29
|
+
$ sow ruby --cucumber myapp
|
30
|
+
|
31
|
+
(Note I am ignoring the issue of directory creation for the moment.)
|
32
|
+
|
33
|
+
This has the benifit of saving the ruby plugin from having to
|
34
|
+
support an almost endless steram of possbile options (rcov, flog,
|
35
|
+
rake, testunit, rspec, bacon, setup.rb, and so on.), and of which
|
36
|
+
one could reasonably argue deserves presence.
|
37
|
+
|
38
|
+
=== Option 2
|
39
|
+
|
40
|
+
I've noticed that every *particular* scaffolding I can conceive can
|
41
|
+
generally be accomplished with a single argument. That being the case
|
42
|
+
each plugin could simply be invoked as a commandline switch.
|
43
|
+
|
44
|
+
sow --ruby[=<name>] [pathname]
|
45
|
+
|
46
|
+
To copy ruby scaffolding into subdirectory +name+.
|
47
|
+
|
48
|
+
sow --ruby <pathname>
|
49
|
+
|
50
|
+
In which case the name of the project and the subdirectory would be
|
51
|
+
the same.
|
52
|
+
|
53
|
+
This notation allows for multiple plugins to be invoked in the same
|
54
|
+
command. For instance, lets use our cucumber plugin. We could build
|
55
|
+
a ruby project with a cucumber test in one go.
|
56
|
+
|
57
|
+
sow --ruby --cucumber <pathname>
|
58
|
+
|
59
|
+
The cucumber plugin defaults the name of the feature to the pathname,
|
60
|
+
in the same fashion as the ruby project name. To make it different,
|
61
|
+
|
62
|
+
sow --ruby --cucumber=myfeature <pathname>
|
63
|
+
|
64
|
+
We could even invoke the cucumber plugin multiple times in one line.
|
65
|
+
|
66
|
+
So this brings about the notion of having many small plugins, rather
|
67
|
+
then fewer more complex plugins like Option 1 encourages. For example,
|
68
|
+
we might have a +bin+ plugin.
|
69
|
+
|
70
|
+
sow --bin=foo
|
71
|
+
|
72
|
+
In some respects that is rather nice, in that the units are small and
|
73
|
+
tight. The dwonside however, is that we loose a great deal of flexibility
|
74
|
+
in building "feature rich" scaffolds.
|
75
|
+
|
76
|
+
So the question we must to ask is whether these numerous small scaffolds
|
77
|
+
can cover the same range of usecases that larger more complex scaffolds
|
78
|
+
can? Can we think of a case that would simply be too severly hampered by
|
79
|
+
limited commandline options? Or, on the other hand, is there a way to
|
80
|
+
offer some additional flexibity in options when it required?
|
81
|
+
|
82
|
+
I like this later appraoch and I am going to rewrite Sow to use it, since
|
83
|
+
it certainly will owrk well for most cases. Later I will return to
|
84
|
+
question of offering additional option control and see if we can't add
|
85
|
+
that capability into the system in some fashion.
|
86
|
+
|
data/README
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
= Sow
|
2
|
+
|
3
|
+
* http://proutils.github.com/sow
|
4
|
+
* http://github.com/proutils/sow
|
5
|
+
|
6
|
+
|
7
|
+
== TENDING TO PROJECT ECOLOGY
|
8
|
+
|
9
|
+
Sow is a project scaffolding system. The system is pluggable
|
10
|
+
and utilizes eRuby templating to make it easy to extend. Sow
|
11
|
+
can be used for any kind of file scaffolding, but it is
|
12
|
+
designed largely with Ruby project needs in mind.
|
13
|
+
|
14
|
+
Sow's plugins are called "seeds". Sowing requires seeds.
|
15
|
+
Sow comes with an extra large box of seeds to really get
|
16
|
+
those projects blooming!
|
17
|
+
|
18
|
+
|
19
|
+
== SYNOPSIS
|
20
|
+
|
21
|
+
General usage follws the pattern:
|
22
|
+
|
23
|
+
sow [options] --<plugin>[=arg] --<plugin>.<var>[=arg] ... [destination]
|
24
|
+
|
25
|
+
For instance to scaffold a new, basic ruby project with the
|
26
|
+
name 'myapp' in the directory 'myapp':
|
27
|
+
|
28
|
+
$ sow --ruby myapp/
|
29
|
+
|
30
|
+
By default, Sow's +ruby+ plugin will use the destination path
|
31
|
+
as the project name. If we wished to name the project something
|
32
|
+
other than the destination path, we can supply that as an argument.
|
33
|
+
|
34
|
+
$ sow --ruby=foo myapp/
|
35
|
+
|
36
|
+
Alternately we could make the the directory ourselves and, and
|
37
|
+
scaffold it from within.
|
38
|
+
|
39
|
+
$ mkdir myapp
|
40
|
+
$ cd myapp
|
41
|
+
$ sow --ruby=foo
|
42
|
+
|
43
|
+
Once you have a project, Sow can be used to generate components
|
44
|
+
as well, kind of like script/generate in Rails. For instance,
|
45
|
+
to generate a test/unit starter file.
|
46
|
+
|
47
|
+
$ sow --testunit.name=mytest
|
48
|
+
|
49
|
+
For more details on how to use Sow, what plugins are available and how
|
50
|
+
to build your own cusotm plugins, please see the documentation
|
51
|
+
provided on Sow's website.
|
52
|
+
|
53
|
+
|
54
|
+
== CURRENT STATUS
|
55
|
+
|
56
|
+
Sow is still a little wet behind the ears, and you might come across
|
57
|
+
the ocassional odd behavior. Please report on the Protutils
|
58
|
+
mailing list (http://googlegroups.com/group/proutils). Usually the
|
59
|
+
issue will be some over-looked in a given plugin --since plugins
|
60
|
+
have a lot of flexability in their design. It will take some time
|
61
|
+
and some widespread usage to work out all the corner cases and
|
62
|
+
to bring each plugin to a fine polish.
|
63
|
+
|
64
|
+
|
65
|
+
== HOE USERS
|
66
|
+
|
67
|
+
*IMPORTANT NOTICE FOR HOE USERS!*
|
68
|
+
|
69
|
+
Hoe users will discover that the +sow+ command that comes with Hoe will
|
70
|
+
be overwritten by Sow. This may seem a not-so-nice thing to do, but truth
|
71
|
+
be told Sow is a slightly older project than Hoe (albeit orginally it was
|
72
|
+
a very different program). Since there is no command called +hoe+, I
|
73
|
+
recommend renaming Hoe's +sow+ command.
|
74
|
+
|
75
|
+
sudo mv /usr/bin/sow /usr/bin/hoe
|
76
|
+
|
77
|
+
As an alternative, Sow ships with a Hoe plugin, so there is nothing lost even
|
78
|
+
if Hoe's +sow+ command is overwritten, simply use:
|
79
|
+
|
80
|
+
$ sow --hoe <name>
|
81
|
+
|
82
|
+
Note, that Hoe scaffolding does not support the in-project templating
|
83
|
+
system. To get that you need to add a .meta/ directory to your project.
|
84
|
+
|
85
|
+
|
86
|
+
== INSTALLATION
|
87
|
+
|
88
|
+
=== RubyGems Install
|
89
|
+
|
90
|
+
Install using RubyGems as you would expect:
|
91
|
+
|
92
|
+
$ gem install sow
|
93
|
+
|
94
|
+
This will install Sow, it's Facets dependency if not alreay installed,
|
95
|
+
and a number of built-in plugins. Keep in mind that some plugins
|
96
|
+
come from the packages with which they are associated. For example,
|
97
|
+
the Reap plugin is distributed with the Reap package.
|
98
|
+
|
99
|
+
=== Old School Site Install
|
100
|
+
|
101
|
+
Old-fashion site installs require Ruby Setup (see http://proutils.rubyforge.org/setup).
|
102
|
+
If you don't have Ruby Setup you can install it via Rubygems:
|
103
|
+
|
104
|
+
$ gem install setup
|
105
|
+
|
106
|
+
With Setup in place, download the Sow tarball (.tar.gz) and unpack it,
|
107
|
+
then install by invoking setup.rb.
|
108
|
+
|
109
|
+
$ tar -xvvzf sow-1.0.0.tar.gz
|
110
|
+
$ cd sow-1.0.0
|
111
|
+
$ sudo setup.rb all
|
112
|
+
|
113
|
+
If you use Hoe, please see the the important message below before
|
114
|
+
installing.
|
115
|
+
|
116
|
+
|
117
|
+
== DEVELOPMENT
|
118
|
+
|
119
|
+
Sow is being developed on <a href="http://hithub.com">GitHub</a>, as part of the
|
120
|
+
ProUtils set of project development tools. You can browse the Sow project here:
|
121
|
+
|
122
|
+
http://github.com/proutils/sow/tree/master
|
123
|
+
|
124
|
+
Sow's public repository can be pulled via:
|
125
|
+
|
126
|
+
git://github.com/proutils/sow.git
|
127
|
+
|
128
|
+
Please feel free to fork the project and submit pull requests. Discussion of
|
129
|
+
Sow occurs on the TigerOps Community Mailinglist.
|
130
|
+
|
131
|
+
http://groups.google.com/group/tigerops-community?hl=en
|
132
|
+
|
133
|
+
Happy hacking!
|
134
|
+
|
135
|
+
|
136
|
+
== COPYRIGHT & LICENSE
|
137
|
+
|
138
|
+
Copyright (c) 2007, 2009 Thomas Sawyer
|
139
|
+
|
140
|
+
Unless other premmited by the author, this software is distributed under
|
141
|
+
the terms of the GPL version 3 license.
|
142
|
+
|
143
|
+
This program is free software: you can redistribute it and/or modify
|
144
|
+
it under the terms of the GNU General Public License as published by
|
145
|
+
the Free Software Foundation, either version 3 of the License, or
|
146
|
+
(at your option) any later version.
|
147
|
+
|
148
|
+
This program is distributed in the hope that it will be useful,
|
149
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
150
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
151
|
+
GNU General Public License for more details.
|
152
|
+
|
153
|
+
You should have received a copy of the GNU General Public License
|
154
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
155
|
+
|
156
|
+
Please see COPYING file for details.
|
157
|
+
|
data/bin/sow
ADDED
data/lib/sow.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# = Sow
|
2
|
+
#
|
3
|
+
# Sow namespace in which all Sow comppnents are defined.
|
4
|
+
#
|
5
|
+
# Sow does use a number of core extensions, but these are
|
6
|
+
# all managed by Ruby Facets to help promote standardized
|
7
|
+
# in the area and reduce potential name conflicts.
|
8
|
+
#
|
9
|
+
module Sow
|
10
|
+
VERSION = '1.0.0' #:till: VERSION = '<%= version %>'
|
11
|
+
end
|
12
|
+
|
data/lib/sow/command.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'sow/manager'
|
2
|
+
require 'facets/string/tabto'
|
3
|
+
|
4
|
+
module Sow
|
5
|
+
|
6
|
+
# Sow Commandline Utility.
|
7
|
+
#
|
8
|
+
# TODO: Provide help messages for individual plugins.
|
9
|
+
#
|
10
|
+
# TODO: Move the core logic of execture to either Manger or another class.
|
11
|
+
#
|
12
|
+
class Command
|
13
|
+
|
14
|
+
# Initialize and execute command.
|
15
|
+
def self.execute
|
16
|
+
new.execute
|
17
|
+
end
|
18
|
+
|
19
|
+
# Commandline arguments.
|
20
|
+
attr :argv
|
21
|
+
|
22
|
+
# New Command.
|
23
|
+
def initialize(argv=ARGV)
|
24
|
+
@argv = argv.dup
|
25
|
+
end
|
26
|
+
|
27
|
+
# Plugin manger.
|
28
|
+
def manager
|
29
|
+
@manager ||= Manager.new
|
30
|
+
end
|
31
|
+
|
32
|
+
# Run command.
|
33
|
+
#
|
34
|
+
# TODO: Should we look up the directory tree for a .config/sow.yaml
|
35
|
+
# file to determine if this has been previously sowed and maybe
|
36
|
+
# change directory to that location?
|
37
|
+
#
|
38
|
+
def execute
|
39
|
+
arguments, cooptions = *parse_argv(argv)
|
40
|
+
|
41
|
+
# Extract standard commandline options.
|
42
|
+
options, cooptions = standard_options(cooptions)
|
43
|
+
|
44
|
+
if options.help?
|
45
|
+
puts help
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
# Ensure only one command type selected.
|
50
|
+
if [options.create?, options.delete?, options.update?].compact.size > 1
|
51
|
+
raise "Conflicting commands. Choose one: create, delete or update."
|
52
|
+
end
|
53
|
+
|
54
|
+
# Path to destination is the last argument, if given. Otherwise it is
|
55
|
+
# the current working path.
|
56
|
+
pathname = (arguments.pop || '.').chomp('/')
|
57
|
+
|
58
|
+
options.destination = pathname
|
59
|
+
|
60
|
+
# All options should appear after plugin/scaffold name.
|
61
|
+
# however, it is able to look past purely flag switches.
|
62
|
+
#name = arguments.find{ |e| e !~ /^\-/ }
|
63
|
+
|
64
|
+
session = Session.new(arguments, options)
|
65
|
+
|
66
|
+
#command = session.mode
|
67
|
+
|
68
|
+
# collect plugin options
|
69
|
+
options = Hash.new{ |h,k| h[k] = {} }
|
70
|
+
cooptions.each do |(name, value)|
|
71
|
+
if name.index('.')
|
72
|
+
name, var = *name.split('.')
|
73
|
+
options[name][var] = value
|
74
|
+
else
|
75
|
+
options[name]['argument'] = value
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# collect plugins
|
80
|
+
plugins = options.map do |(name, opts)|
|
81
|
+
# Get plugin by name
|
82
|
+
plugin = manager.plugin(session, name, opts)
|
83
|
+
# Setup the plugin
|
84
|
+
plugin.setup #(command, arguments, options)
|
85
|
+
#
|
86
|
+
plugin
|
87
|
+
end
|
88
|
+
|
89
|
+
# Abort if no scaffold type given.
|
90
|
+
if plugins.empty?
|
91
|
+
$stderr.puts "No scaffold type given."
|
92
|
+
exit
|
93
|
+
end
|
94
|
+
|
95
|
+
# Get copylists from each plugin and combine them into
|
96
|
+
# a single compylist.
|
97
|
+
copylist = plugins.inject([]) do |array, plugin|
|
98
|
+
array.concat(plugin.copylist)
|
99
|
+
end
|
100
|
+
|
101
|
+
begin
|
102
|
+
case session.mode
|
103
|
+
when 'create'
|
104
|
+
generator = Generators::Create.new(session, copylist)
|
105
|
+
generator.generate
|
106
|
+
when 'update'
|
107
|
+
generator = Generators::Update.new(session, copylist)
|
108
|
+
generator.generate
|
109
|
+
when 'delete'
|
110
|
+
generator = Generators::Delete.new(session, copylist)
|
111
|
+
generator.generate
|
112
|
+
else
|
113
|
+
raise "[IMPOSSIBLE] Unknown command type."
|
114
|
+
end
|
115
|
+
rescue => err
|
116
|
+
if options['debug']
|
117
|
+
raise err
|
118
|
+
else
|
119
|
+
puts err
|
120
|
+
puts "try --help or --debug"
|
121
|
+
exit
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Very simply ARGV parser. In the future we may make
|
127
|
+
# this a bit smarter. We do it manually to preserve the
|
128
|
+
# order of plugin options.
|
129
|
+
def parse_argv(argv)
|
130
|
+
args = []
|
131
|
+
opts = []
|
132
|
+
argv.each_with_index do |arg, idx|
|
133
|
+
case arg
|
134
|
+
when /^-/
|
135
|
+
opts << arg
|
136
|
+
else
|
137
|
+
args << arg
|
138
|
+
end
|
139
|
+
end
|
140
|
+
opts = opts.map{ |o| o.sub(/^\-+/, '').split('=') }
|
141
|
+
return args, opts
|
142
|
+
end
|
143
|
+
|
144
|
+
# Return command type based on option.
|
145
|
+
#def command(options)
|
146
|
+
# return 'create' if options['create'] #|| options[:c]
|
147
|
+
# return 'update' if options['update'] #|| options[:u]
|
148
|
+
# return 'delete' if options['delete'] #|| options[:d]
|
149
|
+
# nil
|
150
|
+
#end
|
151
|
+
|
152
|
+
STANDARD_OPTIONS = {
|
153
|
+
'create' => 'create', 'c' => 'create',
|
154
|
+
'update' => 'update', 'u' => 'update',
|
155
|
+
'delete' => 'delete', 'd' => 'delete',
|
156
|
+
'quiet' => 'quiet' , 'q' => 'quiet' ,
|
157
|
+
'prompt' => 'prompt', 'p' => 'prompt',
|
158
|
+
'skip' => 'skip' , 's' => 'skip' ,
|
159
|
+
'force' => 'force' , 'f' => 'force' ,
|
160
|
+
'trial' => 'trial' , 't' => 'trial' ,
|
161
|
+
'help' => 'help' , 'h' => 'help' ,
|
162
|
+
'debug' => 'debug' ,
|
163
|
+
}
|
164
|
+
|
165
|
+
# Returns a hash of standard options and an assoc array
|
166
|
+
# of plugin options.
|
167
|
+
def standard_options(opts)
|
168
|
+
h, o = OpenStruct.new, []
|
169
|
+
opts.each do |(k,v)|
|
170
|
+
if opt = STANDARD_OPTIONS[k]
|
171
|
+
h[opt+'?'] = true
|
172
|
+
else
|
173
|
+
o << [k,v]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
return h, o
|
177
|
+
end
|
178
|
+
|
179
|
+
# General help message.
|
180
|
+
def help
|
181
|
+
<<-END.tabto(0)
|
182
|
+
Usage: sow [options] --<plugin>[=<value>] ... [<path>]
|
183
|
+
|
184
|
+
Options:
|
185
|
+
-c --create Create scaffolding
|
186
|
+
-u --update Update scaffolding
|
187
|
+
-d --delete Delete scaffolding
|
188
|
+
-p --prompt Prompt on overwrites
|
189
|
+
-s --skip Skip overwrites
|
190
|
+
-f --force Force restricted operations
|
191
|
+
-q --quiet Supress output messages
|
192
|
+
-t --trial Trial run (won't write to disk)
|
193
|
+
--debug Provide debuging information
|
194
|
+
-h --help Show this message
|
195
|
+
END
|
196
|
+
end
|
197
|
+
|
198
|
+
end#class Command
|
199
|
+
|
200
|
+
end#module Sow
|
201
|
+
|