linecook 1.0.0 → 1.1.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.
- data/History +9 -0
- data/HowTo/Generate Scripts +12 -7
- data/bin/linecook +1 -1
- data/lib/linecook/commands/build.rb +5 -0
- data/lib/linecook/cookbook.rb +1 -1
- data/lib/linecook/recipe.rb +1 -1
- data/lib/linecook/test.rb +4 -3
- data/lib/linecook/version.rb +1 -1
- data/templates/Gemfile +1 -0
- data/templates/Rakefile +1 -1
- data/templates/_gitignore +0 -1
- data/templates/attributes/project_name.rb +3 -4
- data/templates/config/ssh +3 -4
- data/templates/cookbook +3 -2
- data/templates/files/example.txt +1 -0
- data/templates/helpers/project_name/echo.erb +4 -0
- data/templates/packages/abox.yml +2 -4
- data/templates/project_name.gemspec +6 -6
- data/templates/recipes/abox.rb +8 -14
- data/templates/templates/example.erb +1 -0
- data/templates/test/project_name_test.rb +6 -1
- metadata +19 -11
- data/templates/files/help.txt +0 -1
- data/templates/helpers/project_name/assert_content_equal.erb +0 -15
- data/templates/helpers/project_name/create_dir.erb +0 -9
- data/templates/helpers/project_name/create_file.erb +0 -8
- data/templates/helpers/project_name/install_file.erb +0 -8
- data/templates/recipes/abox_test.rb +0 -14
- data/templates/templates/todo.txt.erb +0 -3
data/History
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.1.0 2011/05/02
|
2
|
+
|
3
|
+
* updated scaffold generated by 'linecook init' to be current and simpler
|
4
|
+
* fixed template_path to accept full path (with .erb extname) as source and to
|
5
|
+
set the default target as source minus .erb extension, if present
|
6
|
+
* updated 'linecook build' to allow setting a load path
|
7
|
+
* added LINECOOK_USE_BUNDLER to turn off Bundler.setup in linecook executable
|
8
|
+
* minor documentation fixes
|
9
|
+
|
1
10
|
== 1.0.0 2011/04/26
|
2
11
|
|
3
12
|
First major release. Significant work on documentation and various bug fixes.
|
data/HowTo/Generate Scripts
CHANGED
@@ -12,6 +12,10 @@ the script is reproduced.
|
|
12
12
|
|
13
13
|
The command to rebuild a package is:
|
14
14
|
|
15
|
+
linecook build -Ilib
|
16
|
+
|
17
|
+
Or if you have a proper Gemfile in your project dir:
|
18
|
+
|
15
19
|
linecook build
|
16
20
|
|
17
21
|
This tutorial is designed such that if you make the files as specified, you
|
@@ -158,7 +162,7 @@ attribute and package files from above):
|
|
158
162
|
Sets a global git config.
|
159
163
|
(key, value)
|
160
164
|
--
|
161
|
-
git config --global <%= key %> <%= value %>
|
165
|
+
git config --global <%= key %> "<%= value %>"
|
162
166
|
|
163
167
|
|
164
168
|
[recipes/demo.rb]
|
@@ -168,8 +172,8 @@ attribute and package files from above):
|
|
168
172
|
#########################################################################
|
169
173
|
install attrs['ruby']['package']
|
170
174
|
install attrs['git']['package']
|
171
|
-
|
172
|
-
set_git_config key,
|
175
|
+
['user.name', 'user.email'].each do |key|
|
176
|
+
set_git_config key, attrs['git']['config'][key]
|
173
177
|
end
|
174
178
|
|
175
179
|
When you define a helper, you're literally defining a method in a module that
|
@@ -237,7 +241,7 @@ is local by default.
|
|
237
241
|
target.puts <<-SCRIPT
|
238
242
|
sudo apt-get -y install ruby1.8
|
239
243
|
sudo apt-get -y install git
|
240
|
-
cp "#{ template_path "gitconfig" }" ~/.gitconfig
|
244
|
+
cp "#{ template_path "gitconfig.erb" }" ~/.gitconfig
|
241
245
|
SCRIPT
|
242
246
|
|
243
247
|
== {Linebook}[http://rubygems.org/gems/linebook/]
|
@@ -245,10 +249,11 @@ is local by default.
|
|
245
249
|
The techniques presented here are sufficient to work with many scripts in many
|
246
250
|
situations but they are quite bare. Eventually, or perhaps immediately, you
|
247
251
|
will want a suite of standard helpers. The canonical helper library is
|
248
|
-
Linebook
|
252
|
+
{Linebook}[http://rubygems.org/gems/linebook/].
|
249
253
|
|
250
|
-
See the {Linebook
|
251
|
-
|
254
|
+
See the {Linebook
|
255
|
+
documentation}[http://rubydoc.info/gems/linebook/file/README] to learn helpers
|
256
|
+
for flow control, file system tests, commands, chaining, redirection,
|
252
257
|
heredocs, and other convenience methods.
|
253
258
|
|
254
259
|
[recipes/demo.rb]
|
data/bin/linecook
CHANGED
@@ -10,6 +10,7 @@ module Linecook
|
|
10
10
|
#
|
11
11
|
class Build < Command
|
12
12
|
config :project_dir, '.', :short => :d # the project directory
|
13
|
+
config :load_path, [], :short => :I, &c.list # set load paths
|
13
14
|
config :force, false, :short => :f, &c.flag # force creation
|
14
15
|
config :quiet, false, &c.flag # silence output
|
15
16
|
|
@@ -43,6 +44,10 @@ module Linecook
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def process(*package_names)
|
47
|
+
load_path.each do |path|
|
48
|
+
$:.unshift(path)
|
49
|
+
end
|
50
|
+
|
46
51
|
helper = Helper.new(
|
47
52
|
:project_dir => project_dir,
|
48
53
|
:force => force,
|
data/lib/linecook/cookbook.rb
CHANGED
data/lib/linecook/recipe.rb
CHANGED
@@ -146,7 +146,7 @@ module Linecook
|
|
146
146
|
|
147
147
|
# Looks up, builds, and registers the specified template and returns the
|
148
148
|
# target_path to the resulting file.
|
149
|
-
def template_path(template_name, target_name=template_name, mode=0600, locals={'attrs' => attrs})
|
149
|
+
def template_path(template_name, target_name=template_name.chomp('.erb'), mode=0600, locals={'attrs' => attrs})
|
150
150
|
_package_.build_template(target_name, template_name, mode, locals)
|
151
151
|
target_path target_name
|
152
152
|
end
|
data/lib/linecook/test.rb
CHANGED
@@ -207,14 +207,15 @@ module Linecook
|
|
207
207
|
def linecook_cmd(cmd, options={}, *args)
|
208
208
|
opts = []
|
209
209
|
options.each_pair do |key, value|
|
210
|
-
key = key.gsub('_', '-')
|
210
|
+
key = key.to_s.gsub('_', '-')
|
211
|
+
key = key.length == 1 ? "-#{key}" : "--#{key}"
|
211
212
|
|
212
213
|
case value
|
213
214
|
when true
|
214
|
-
opts <<
|
215
|
+
opts << key
|
215
216
|
when nil, false
|
216
217
|
else
|
217
|
-
opts << "
|
218
|
+
opts << "#{key} '#{value}'"
|
218
219
|
end
|
219
220
|
end
|
220
221
|
|
data/lib/linecook/version.rb
CHANGED
data/templates/Gemfile
CHANGED
data/templates/Rakefile
CHANGED
data/templates/_gitignore
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# Define default
|
2
|
-
# (note string keys are usually better than symbols)
|
3
|
-
attrs['<%= project_name %>']['
|
4
|
-
attrs['<%= project_name %>']['resolutions'] = []
|
1
|
+
# Define default attributes here. The attrs object is a self-nesting Hash
|
2
|
+
# (note string keys are usually better than symbols).
|
3
|
+
attrs['<%= project_name %>']['message'] = 'Hello World'
|
data/templates/config/ssh
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
# Declare
|
2
|
-
|
3
|
-
Host abox # [abox]
|
1
|
+
# Declare a Host for each package.
|
2
|
+
Host abox
|
4
3
|
Port 2220
|
5
4
|
|
6
|
-
# Define
|
5
|
+
# Define defaults here.
|
7
6
|
Host *
|
8
7
|
HostName localhost
|
9
8
|
User linecook
|
data/templates/cookbook
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Configure the cookbook here.
|
2
|
-
# Adding this file to a gem marks it as a cookbook gem
|
3
|
-
# (note that in a gem the contents of this file are ignored)
|
4
2
|
|
5
3
|
# Define directories searched for attributes/recipes/etc.
|
6
4
|
# paths: ['.']
|
7
5
|
|
8
6
|
# Name the gems added to path - defaults to all marked gems.
|
9
7
|
# gems: []
|
8
|
+
|
9
|
+
# Adding this file to a gem marks it as a cookbook gem
|
10
|
+
# (within a gem the contents of this file are ignored)
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello World (from a file)
|
data/templates/packages/abox.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version =
|
4
|
+
s.name = '<%= project_name %>'
|
5
|
+
s.version = '0.0.1'
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
|
-
s.authors =
|
8
|
-
s.email =
|
9
|
-
s.homepage =
|
7
|
+
s.authors = 'TODO: Write your name'
|
8
|
+
s.email = 'TODO: Write your email address'
|
9
|
+
s.homepage = ''
|
10
10
|
s.summary = %q{TODO: Write a gem summary}
|
11
11
|
s.description = %q{TODO: Write a gem description}
|
12
12
|
s.rubyforge_project = ''
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rdoc_options.concat %W{--main README -S -N --title <%= project_name.capitalize %>}
|
16
16
|
|
17
17
|
# add dependencies
|
18
|
-
s.add_dependency('linecook', '~> <%= Linecook::
|
18
|
+
s.add_dependency('linecook', '~> <%= Linecook::MAJOR %>.<%= Linecook::MINOR %>')
|
19
19
|
|
20
20
|
# list extra rdoc files here.
|
21
21
|
s.extra_rdoc_files = %W{
|
data/templates/recipes/abox.rb
CHANGED
@@ -1,22 +1,16 @@
|
|
1
1
|
#############################################################################
|
2
|
-
helpers '<%= project_name %>'
|
3
2
|
attributes '<%= project_name %>'
|
3
|
+
helpers '<%= project_name %>'
|
4
4
|
#############################################################################
|
5
5
|
|
6
6
|
# Write to the script using write/writeln
|
7
7
|
writeln '# An example script.'
|
8
8
|
|
9
|
-
# Attributes are available
|
10
|
-
|
11
|
-
|
12
|
-
create_file file, content
|
13
|
-
|
14
|
-
# Use file_path to add a file to the package and return a path to it.
|
15
|
-
source = file_path('help.txt')
|
16
|
-
target = "~/#{attrs['<%= project_name %>']['year']}/help.txt"
|
17
|
-
install_file source, target
|
9
|
+
# Attributes are available via attrs.
|
10
|
+
# Helpers are available as methods.
|
11
|
+
echo attrs['<%= project_name %>']['message']
|
18
12
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
# Use file_path and template_path to add files to the package; the return
|
14
|
+
# value can be treated as a path to the file. For example:
|
15
|
+
writeln "cat #{file_path('example.txt', 'example_file')}"
|
16
|
+
writeln "cat #{template_path('example.erb', 'example_template')}"
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= '<' %>%= attrs['<%= project_name %>']['message'] %<%= '>' %> (from a template)
|
@@ -4,7 +4,7 @@ class <%= const_name %>Test < Test::Unit::TestCase
|
|
4
4
|
include Linecook::Test
|
5
5
|
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# project test (build and run project as written)
|
8
8
|
#
|
9
9
|
|
10
10
|
no_cleanup
|
@@ -14,6 +14,11 @@ class <%= const_name %>Test < Test::Unit::TestCase
|
|
14
14
|
assert_equal 0, $?.exitstatus, cmd
|
15
15
|
|
16
16
|
result, cmd = run_project
|
17
|
+
assert_output_equal %q{
|
18
|
+
Hello World (from a helper)
|
19
|
+
Hello World (from a file)
|
20
|
+
Hello World (from a template)
|
21
|
+
}, result, cmd
|
17
22
|
assert_equal 0, $?.exitstatus, cmd
|
18
23
|
end
|
19
24
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linecook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 1.0.0
|
10
|
+
version: 1.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Simon Chiang
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-05-02 00:00:00 -06:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rake
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ~>
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 49
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 8
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: configurable
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ~>
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
- 7
|
@@ -49,9 +54,11 @@ dependencies:
|
|
49
54
|
name: bundler
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ~>
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 15
|
55
62
|
segments:
|
56
63
|
- 1
|
57
64
|
- 0
|
@@ -110,18 +117,15 @@ files:
|
|
110
117
|
- templates/attributes/project_name.rb
|
111
118
|
- templates/config/ssh
|
112
119
|
- templates/cookbook
|
113
|
-
- templates/files/
|
114
|
-
- templates/helpers/project_name/
|
115
|
-
- templates/helpers/project_name/create_dir.erb
|
116
|
-
- templates/helpers/project_name/create_file.erb
|
117
|
-
- templates/helpers/project_name/install_file.erb
|
120
|
+
- templates/files/example.txt
|
121
|
+
- templates/helpers/project_name/echo.erb
|
118
122
|
- templates/packages/abox.yml
|
119
123
|
- templates/project_name.gemspec
|
120
124
|
- templates/recipes/abox.rb
|
121
|
-
- templates/
|
122
|
-
- templates/templates/todo.txt.erb
|
125
|
+
- templates/templates/example.erb
|
123
126
|
- templates/test/project_name_test.rb
|
124
127
|
- templates/test/test_helper.rb
|
128
|
+
- bin/linecook
|
125
129
|
- History
|
126
130
|
- README
|
127
131
|
- License.txt
|
@@ -144,23 +148,27 @@ rdoc_options:
|
|
144
148
|
require_paths:
|
145
149
|
- lib
|
146
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
147
152
|
requirements:
|
148
153
|
- - ">="
|
149
154
|
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
150
156
|
segments:
|
151
157
|
- 0
|
152
158
|
version: "0"
|
153
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
154
161
|
requirements:
|
155
162
|
- - ">="
|
156
163
|
- !ruby/object:Gem::Version
|
164
|
+
hash: 3
|
157
165
|
segments:
|
158
166
|
- 0
|
159
167
|
version: "0"
|
160
168
|
requirements: []
|
161
169
|
|
162
170
|
rubyforge_project:
|
163
|
-
rubygems_version: 1.3.
|
171
|
+
rubygems_version: 1.3.7
|
164
172
|
signing_key:
|
165
173
|
specification_version: 3
|
166
174
|
summary: A shell script generator.
|
data/templates/files/help.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
* https://github.com/pinnacol/linecook
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Asserts the content of the file is as expected. Prints a diff and exits 1 if
|
2
|
-
the content is not as expected.
|
3
|
-
(expected, file)
|
4
|
-
--
|
5
|
-
expected='<%= '<' %>%= expected.rstrip %<%= '>' %>'
|
6
|
-
actual=$(cat <%= '<' %>%= file %<%= '>' %>)
|
7
|
-
|
8
|
-
echo "Check file: <%= '<' %>%= file %<%= '>' %>"
|
9
|
-
if [ "$actual" != "$expected" ]
|
10
|
-
then
|
11
|
-
echo "[$0] unequal output: <%= '<' %>%= file %<%= '>' %>" >&2
|
12
|
-
diff <(cat <<< "$expected") <(cat <<< "$actual") >&2
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#############################################################################
|
2
|
-
helpers '<%= project_name %>'
|
3
|
-
attributes '<%= project_name %>'
|
4
|
-
#############################################################################
|
5
|
-
|
6
|
-
# Validations can be using the same techniques as in run.
|
7
|
-
assert_content_equal %{
|
8
|
-
I will automate configuration of my servers.
|
9
|
-
}.lstrip, '~/2011/resolutions.txt'
|
10
|
-
|
11
|
-
assert_content_equal %{
|
12
|
-
# TODO
|
13
|
-
* automate configuration of my servers
|
14
|
-
}.lstrip, '~/2011/todo.txt'
|