hen 0.4.8 → 0.4.9
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.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README +1 -1
- data/bin/hen +2 -147
- data/lib/hen/commands.rb +190 -0
- data/lib/hen/version.rb +1 -1
- data/lib/hens/gem.rake +24 -1
- metadata +23 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f082dccc6c68ce2ac6dd82122bc73252f3e56aa
|
4
|
+
data.tar.gz: 577ca2a99cb316c4a654444d819dc330f652a537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12c0385cfc7705247ba458c4cb6b8b3988cf73594167301fd35a529df83f4001826752e8436b889d2b9cebe628ec12809c56657109d2f250767250971c7305cb
|
7
|
+
data.tar.gz: ef0cccbbcaa0bddfc5b15f8d53a52130807003c36882c30e14b23b44f2dfe0b27a9bbfb0ed1db4e373824039dfc4d580b11a098e8920d7f4544d828ad35fae4d
|
data/ChangeLog
CHANGED
data/README
CHANGED
data/bin/hen
CHANGED
@@ -30,150 +30,5 @@
|
|
30
30
|
###############################################################################
|
31
31
|
#++
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
require 'fileutils'
|
36
|
-
require 'nuggets/enumerable/minmax'
|
37
|
-
|
38
|
-
require 'hen/cli'
|
39
|
-
include Hen::CLI
|
40
|
-
|
41
|
-
ACTIONS = {
|
42
|
-
'config' => 'Create a fresh .henrc file',
|
43
|
-
'create' => [
|
44
|
-
'Create a new project directory tree',
|
45
|
-
'Arguments: path [sample-skeleton]',
|
46
|
-
'Options: -g, --git [[remote=]url]'
|
47
|
-
],
|
48
|
-
'help' => 'Print this help and exit',
|
49
|
-
'list' => 'List available hens with their tasks',
|
50
|
-
'version' => 'Display version number'
|
51
|
-
}
|
52
|
-
|
53
|
-
USAGE = <<EOT
|
54
|
-
Usage: #{$0} {#{ACTIONS.keys.sort.join('|')}} [arguments] [options]
|
55
|
-
#{$0} [-h|--help] [--version]
|
56
|
-
EOT
|
57
|
-
|
58
|
-
abort USAGE if ARGV.empty?
|
59
|
-
|
60
|
-
EXAMPLE = File.expand_path('../../example', __FILE__)
|
61
|
-
|
62
|
-
case arg = ARGV.shift
|
63
|
-
when 'help', '-h', '--help'
|
64
|
-
puts USAGE
|
65
|
-
puts
|
66
|
-
puts 'Actions:'
|
67
|
-
|
68
|
-
max = ACTIONS.keys.max(:length)
|
69
|
-
|
70
|
-
ACTIONS.sort.each { |action, description|
|
71
|
-
description = [*description]
|
72
|
-
puts " %-#{max}s - %s" % [action, description.shift]
|
73
|
-
|
74
|
-
description.each { |extra|
|
75
|
-
puts " %#{max}s + %s" % [' ', extra]
|
76
|
-
}
|
77
|
-
}
|
78
|
-
when 'version', '--version'
|
79
|
-
puts "hen v#{Hen::VERSION}"
|
80
|
-
when 'config'
|
81
|
-
render(File.join(EXAMPLE, '_henrc'), henrc = Hen.default_henrc)
|
82
|
-
|
83
|
-
puts
|
84
|
-
puts "Your .henrc has been created: #{henrc}. Now adjust it to your needs."
|
85
|
-
when 'create'
|
86
|
-
path = File.expand_path(ARGV.shift)
|
87
|
-
abort 'Path argument missing!' unless path
|
88
|
-
|
89
|
-
skel = ARGV.first !~ /\A-/ && ARGV.shift || File.join(EXAMPLE, 'project')
|
90
|
-
abort "Sample project tree not found: #{skel}" unless File.directory?(skel)
|
91
|
-
|
92
|
-
# Keep track of what's been created
|
93
|
-
created = []
|
94
|
-
|
95
|
-
if File.directory?(path)
|
96
|
-
abort "Target directory already exists: #{path}. Won't touch."
|
97
|
-
else
|
98
|
-
Dir.mkdir(path)
|
99
|
-
created << path
|
100
|
-
end
|
101
|
-
|
102
|
-
if git = ARGV.index('-g') || ARGV.index('--git')
|
103
|
-
ARGV.delete_at(git)
|
104
|
-
remote = ARGV.delete_at(git)
|
105
|
-
|
106
|
-
Dir.chdir(path) {
|
107
|
-
if system('git', 'init')
|
108
|
-
created << File.join(path, '.git')
|
109
|
-
|
110
|
-
if remote
|
111
|
-
url, label = remote.split('=', 2).reverse
|
112
|
-
system('git', 'remote', 'add', label ||= 'origin', url)
|
113
|
-
|
114
|
-
system('git', 'config', 'branch.master.remote', label)
|
115
|
-
system('git', 'config', 'branch.master.merge', 'refs/heads/master')
|
116
|
-
end
|
117
|
-
end
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
# Parts to be replaced by the user
|
122
|
-
replace = {}
|
123
|
-
|
124
|
-
begin
|
125
|
-
# We need the name here, so ask for it already.
|
126
|
-
progname = progname(File.basename(path))
|
127
|
-
|
128
|
-
Dir.chdir(skel) {
|
129
|
-
Dir['**/*'].each { |sample|
|
130
|
-
target = File.join(path, sample.gsub(/__progname__/, progname))
|
131
|
-
|
132
|
-
next if target.sub!(%r{(\A|/)[._](git[^/]+)\z}, '\1.\2') && !git
|
133
|
-
|
134
|
-
created << target
|
135
|
-
|
136
|
-
if File.directory?(sample)
|
137
|
-
FileUtils.mkdir_p(target)
|
138
|
-
else
|
139
|
-
replace[target] = render(sample, target).scan(/### .+ ###/)
|
140
|
-
end
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
# If we got here, everything went fine...
|
145
|
-
created.clear
|
146
|
-
ensure
|
147
|
-
# In case of an exception or premature program exit: Clean up!
|
148
|
-
created.reverse.each { |item|
|
149
|
-
next unless File.exist?(item)
|
150
|
-
|
151
|
-
begin
|
152
|
-
(File.directory?(item) ? Dir : File).unlink(item)
|
153
|
-
rescue Errno::ENOTEMPTY => err
|
154
|
-
File.basename(item) == '.git' ? FileUtils.rm_rf(item) : raise(err)
|
155
|
-
end
|
156
|
-
}
|
157
|
-
end
|
158
|
-
|
159
|
-
puts
|
160
|
-
puts "Your new project directory has been created: #{path}. Have fun!"
|
161
|
-
|
162
|
-
replace.each { |target, details|
|
163
|
-
next if details.empty?
|
164
|
-
|
165
|
-
puts
|
166
|
-
puts "#{target}:"
|
167
|
-
|
168
|
-
details.each { |detail|
|
169
|
-
puts " #{detail}"
|
170
|
-
}
|
171
|
-
}
|
172
|
-
when 'list'
|
173
|
-
# How to achieve? Has to list *all* hens and tasks made available therein,
|
174
|
-
# *regardless* of any missing prerequisites (preferably indicating whether
|
175
|
-
# a particular hen/task is currently available).
|
176
|
-
abort 'Sorry, not yet available...'
|
177
|
-
else
|
178
|
-
abort "Illegal action: #{arg}\n#{USAGE}"
|
179
|
-
end
|
33
|
+
require 'hen/commands'
|
34
|
+
Hen::Commands[ARGV.shift || 'usage']
|
data/lib/hen/commands.rb
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# hen -- Just a Rake helper #
|
5
|
+
# #
|
6
|
+
# Copyright (C) 2013 Jens Wille #
|
7
|
+
# #
|
8
|
+
# Authors: #
|
9
|
+
# Jens Wille <jens.wille@gmail.com> #
|
10
|
+
# #
|
11
|
+
# hen is free software; you can redistribute it and/or modify it under the #
|
12
|
+
# terms of the GNU Affero General Public License as published by the Free #
|
13
|
+
# Software Foundation; either version 3 of the License, or (at your option) #
|
14
|
+
# any later version. #
|
15
|
+
# #
|
16
|
+
# hen is distributed in the hope that it will be useful, but WITHOUT ANY #
|
17
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
18
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
|
19
|
+
# more details. #
|
20
|
+
# #
|
21
|
+
# You should have received a copy of the GNU Affero General Public License #
|
22
|
+
# along with hen. If not, see <http://www.gnu.org/licenses/>. #
|
23
|
+
# #
|
24
|
+
###############################################################################
|
25
|
+
#++
|
26
|
+
|
27
|
+
# TODO: Implement 'list' command -- List available hens with their tasks (?)
|
28
|
+
|
29
|
+
require 'nuggets/argv/option'
|
30
|
+
require 'nuggets/enumerable/minmax'
|
31
|
+
|
32
|
+
require 'hen/cli'
|
33
|
+
|
34
|
+
class Hen
|
35
|
+
|
36
|
+
module Commands
|
37
|
+
|
38
|
+
extend self
|
39
|
+
|
40
|
+
extend CLI
|
41
|
+
|
42
|
+
COMMANDS = {
|
43
|
+
'config' => 'Create a fresh .henrc file',
|
44
|
+
'create' => [
|
45
|
+
'Create a new project directory tree',
|
46
|
+
'Arguments: path [sample-skeleton]',
|
47
|
+
'Options: -g, --git [[remote=]url]'
|
48
|
+
],
|
49
|
+
'help' => 'Print this help and exit',
|
50
|
+
#'list' => 'List available hens with their tasks',
|
51
|
+
'version' => 'Display version number'
|
52
|
+
}
|
53
|
+
|
54
|
+
USAGE = <<-EOT
|
55
|
+
Usage: #{$0} {#{COMMANDS.keys.sort.join('|')}} [arguments] [options]
|
56
|
+
#{$0} [-h|--help] [--version]
|
57
|
+
EOT
|
58
|
+
|
59
|
+
SKELETON = File.expand_path('../../../example', __FILE__)
|
60
|
+
|
61
|
+
GIT_RE = %r{(\A|/)[._](git[^/]+)\z}
|
62
|
+
|
63
|
+
def [](arg)
|
64
|
+
arg = arg.sub(/\A-+/, '')
|
65
|
+
arg !~ /\W/ && public_method_defined?(arg) ? send(arg) : method_missing(arg)
|
66
|
+
end
|
67
|
+
|
68
|
+
def usage
|
69
|
+
abort USAGE
|
70
|
+
end
|
71
|
+
|
72
|
+
def help
|
73
|
+
puts USAGE
|
74
|
+
puts
|
75
|
+
puts 'Commands:'
|
76
|
+
|
77
|
+
max = COMMANDS.keys.max(:length)
|
78
|
+
|
79
|
+
COMMANDS.sort.each { |cmd, desc|
|
80
|
+
puts " %-#{max}s - %s" % [cmd, (desc = [*desc]).shift]
|
81
|
+
desc.each { |extra| puts " %#{max}s + %s" % [' ', extra] }
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
alias_method :h, :help
|
86
|
+
|
87
|
+
def list
|
88
|
+
# How to achieve? Has to list *all* hens and tasks made available therein,
|
89
|
+
# *regardless* of any missing prerequisites (preferably indicating whether
|
90
|
+
# a particular hen/task is currently available).
|
91
|
+
abort 'Sorry, not yet available...'
|
92
|
+
end
|
93
|
+
|
94
|
+
def version
|
95
|
+
puts "hen v#{VERSION}"
|
96
|
+
end
|
97
|
+
|
98
|
+
def config
|
99
|
+
render(File.join(SKELETON, '_henrc'), henrc = Hen.default_henrc)
|
100
|
+
|
101
|
+
puts
|
102
|
+
puts "Your .henrc has been created: #{henrc}. Now adjust it to your needs."
|
103
|
+
end
|
104
|
+
|
105
|
+
def create
|
106
|
+
abort 'Path argument missing!' unless path = ARGV.shift
|
107
|
+
|
108
|
+
skel = ARGV.first !~ /^-/ && ARGV.shift || File.join(SKELETON, 'project')
|
109
|
+
abort "Project skeleton not found: #{skel}" unless File.directory?(skel)
|
110
|
+
|
111
|
+
create_path(path = File.expand_path(path), created = [])
|
112
|
+
create_skel(path, skel = File.expand_path(skel), created, replace = {})
|
113
|
+
|
114
|
+
puts
|
115
|
+
puts "Your new project directory has been created: #{path}. Have fun!"
|
116
|
+
|
117
|
+
replace.each { |target, details|
|
118
|
+
puts ["\n#{target}:", *details].join("\n ") unless details.empty?
|
119
|
+
}.clear
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def method_missing(method, *)
|
125
|
+
abort "Illegal command: #{method}\n#{USAGE}"
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_path(path, created)
|
129
|
+
if File.directory?(path)
|
130
|
+
abort "Target directory already exists: #{path}. Won't touch."
|
131
|
+
else
|
132
|
+
Dir.mkdir(path)
|
133
|
+
created << path
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def create_skel(path, skel, created, replace)
|
138
|
+
git = create_git(path, created)
|
139
|
+
|
140
|
+
progname = progname(File.basename(path))
|
141
|
+
|
142
|
+
Dir.chdir(skel) {
|
143
|
+
Dir['**/*'].each { |sample|
|
144
|
+
target = File.join(path, sample.gsub(/__progname__/, progname))
|
145
|
+
|
146
|
+
unless target.sub!(GIT_RE, '\1.\2') && !git
|
147
|
+
created << target
|
148
|
+
|
149
|
+
File.directory?(sample) ? FileUtils.mkdir_p(target) :
|
150
|
+
replace[target] = render(sample, target).scan(/### .+ ###/)
|
151
|
+
end
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
created.clear
|
156
|
+
ensure
|
157
|
+
created.reverse_each { |item|
|
158
|
+
if File.exist?(item)
|
159
|
+
begin
|
160
|
+
(File.directory?(item) ? Dir : File).unlink(item)
|
161
|
+
rescue Errno::ENOTEMPTY
|
162
|
+
File.basename(item) == '.git' ? FileUtils.rm_rf(item) : raise
|
163
|
+
end
|
164
|
+
end
|
165
|
+
}.clear
|
166
|
+
end
|
167
|
+
|
168
|
+
def create_git(path, created)
|
169
|
+
ARGV.option!(:g, :git) { |remote|
|
170
|
+
Dir.chdir(path) {
|
171
|
+
if system('git', 'init')
|
172
|
+
created << File.join(path, '.git')
|
173
|
+
|
174
|
+
if remote
|
175
|
+
url, label = remote.split('=', 2).reverse
|
176
|
+
system('git', 'remote', 'add', label ||= 'origin', url)
|
177
|
+
|
178
|
+
system('git', 'config', 'branch.master.remote', label)
|
179
|
+
system('git', 'config', 'branch.master.merge', 'refs/heads/master')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
}
|
183
|
+
|
184
|
+
true
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
data/lib/hen/version.rb
CHANGED
data/lib/hens/gem.rake
CHANGED
@@ -63,10 +63,33 @@ Hen :gem => :rdoc do
|
|
63
63
|
|
64
64
|
warn 'Gem author(s) missing' if authors.empty?
|
65
65
|
|
66
|
-
### description
|
66
|
+
### description, post_install_message
|
67
67
|
|
68
68
|
gem_options[:description] ||= gem_options[:summary]
|
69
69
|
|
70
|
+
post_install_message = gem_options[:post_install_message]
|
71
|
+
|
72
|
+
gem_options[:post_install_message] = case post_install_message
|
73
|
+
when nil, true
|
74
|
+
msg, ver = [], gem_options[:version].sub(/\.?[^\d.].*/, '')
|
75
|
+
|
76
|
+
heading, found = /\A== (#{Regexp.escape(ver)}\D.*)/o, false
|
77
|
+
|
78
|
+
File.foreach(ENV['HEN_CHANGELOG'] || 'ChangeLog') { |line|
|
79
|
+
line.chomp!
|
80
|
+
|
81
|
+
case line
|
82
|
+
when heading then msg << "#{gem_name}-#{found = $1}:"
|
83
|
+
when /\A== / then break if found
|
84
|
+
else msg << line if found
|
85
|
+
end
|
86
|
+
}
|
87
|
+
|
88
|
+
"\n#{msg.join("\n").strip}\n\n" unless msg.empty?
|
89
|
+
when false
|
90
|
+
else post_install_message
|
91
|
+
end
|
92
|
+
|
70
93
|
### rubyforge project, homepage
|
71
94
|
|
72
95
|
gem_options[:rubyforge_project] ||= rf_config[:project]
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-nuggets
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.8.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.8.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: highline
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Hoe or Echoe? No, thanks! Just a Rake helper that fits my own personal
|
@@ -51,6 +51,7 @@ extra_rdoc_files:
|
|
51
51
|
files:
|
52
52
|
- lib/hen.rb
|
53
53
|
- lib/hen/cli.rb
|
54
|
+
- lib/hen/commands.rb
|
54
55
|
- lib/hen/dsl.rb
|
55
56
|
- lib/hen/version.rb
|
56
57
|
- bin/hen
|
@@ -75,31 +76,37 @@ homepage: http://github.com/blackwinter/hen
|
|
75
76
|
licenses:
|
76
77
|
- AGPL
|
77
78
|
metadata: {}
|
78
|
-
post_install_message:
|
79
|
+
post_install_message: |2+
|
80
|
+
|
81
|
+
hen-0.4.9 [2013-10-25]:
|
82
|
+
|
83
|
+
* Added post install message to gem spec.
|
84
|
+
* Refactored +hen+ executable into Hen::Command module.
|
85
|
+
|
79
86
|
rdoc_options:
|
80
|
-
- --charset
|
87
|
+
- "--charset"
|
81
88
|
- UTF-8
|
82
|
-
- --line-numbers
|
83
|
-
- --all
|
84
|
-
- --title
|
85
|
-
- hen Application documentation (v0.4.
|
86
|
-
- --main
|
89
|
+
- "--line-numbers"
|
90
|
+
- "--all"
|
91
|
+
- "--title"
|
92
|
+
- hen Application documentation (v0.4.9)
|
93
|
+
- "--main"
|
87
94
|
- README
|
88
95
|
require_paths:
|
89
96
|
- lib
|
90
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
98
|
requirements:
|
92
|
-
- -
|
99
|
+
- - ">="
|
93
100
|
- !ruby/object:Gem::Version
|
94
101
|
version: '0'
|
95
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
103
|
requirements:
|
97
|
-
- -
|
104
|
+
- - ">="
|
98
105
|
- !ruby/object:Gem::Version
|
99
106
|
version: '0'
|
100
107
|
requirements: []
|
101
108
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.1.10
|
103
110
|
signing_key:
|
104
111
|
specification_version: 4
|
105
112
|
summary: Hoe or Echoe? No, thanks! Just a Rake helper that fits my own personal style.
|