hen 0.1.7 → 0.1.8
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 +1 -1
- data/lib/hen/dsl.rb +49 -0
- data/lib/hen/version.rb +1 -1
- data/lib/hens/rdoc.rake +57 -0
- metadata +2 -2
data/README
CHANGED
data/lib/hen/dsl.rb
CHANGED
@@ -134,6 +134,55 @@ class Hen
|
|
134
134
|
block[*block_args]
|
135
135
|
end
|
136
136
|
|
137
|
+
def git
|
138
|
+
raise 'Skipping Git tasks' unless File.directory?('.git')
|
139
|
+
|
140
|
+
yield init_git
|
141
|
+
end
|
142
|
+
|
143
|
+
def init_git
|
144
|
+
class << git = Object.new
|
145
|
+
|
146
|
+
def method_missing(cmd, *args)
|
147
|
+
sh 'git', cmd.to_s.tr('_', '-'), *args
|
148
|
+
end
|
149
|
+
|
150
|
+
#alias_method :sh, :system
|
151
|
+
|
152
|
+
def run(*args)
|
153
|
+
%x{#{args.unshift('git').join(' ')}}
|
154
|
+
end
|
155
|
+
|
156
|
+
def remote_for_branch(branch)
|
157
|
+
run(:branch, '-r')[/(\S+)\/#{Regexp.escape(branch)}$/, 1]
|
158
|
+
end
|
159
|
+
|
160
|
+
def url_for_remote(remote)
|
161
|
+
run(:remote, '-v')[/\A#{Regexp.escape(remote)}\s+(.*)/, 1]
|
162
|
+
end
|
163
|
+
|
164
|
+
def find_remote(regexp)
|
165
|
+
run(:remote, '-v').split($/).grep(regexp).first
|
166
|
+
end
|
167
|
+
|
168
|
+
def easy_clone(url, dir = '.', remote = 'origin')
|
169
|
+
clone '-n', '-o', remote, url, dir
|
170
|
+
end
|
171
|
+
|
172
|
+
def checkout_remote_branch(remote, branch = 'master')
|
173
|
+
checkout '-b', branch, "#{remote}/#{branch}"
|
174
|
+
end
|
175
|
+
|
176
|
+
def add_and_commit(msg)
|
177
|
+
add '.'
|
178
|
+
commit '-m', msg
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
git
|
184
|
+
end
|
185
|
+
|
137
186
|
private
|
138
187
|
|
139
188
|
# Loads the Rubyforge library, giving a
|
data/lib/hen/version.rb
CHANGED
data/lib/hens/rdoc.rake
CHANGED
@@ -78,6 +78,63 @@ begin
|
|
78
78
|
end
|
79
79
|
rescue RuntimeError => err
|
80
80
|
raise unless err.to_s == 'Skipping Rubyforge tasks'
|
81
|
+
|
82
|
+
git do |git|
|
83
|
+
|
84
|
+
git_branch = 'gh-pages'
|
85
|
+
|
86
|
+
if git_remote = git.remote_for_branch(git_branch)
|
87
|
+
pages_url = git.url_for_remote(git_remote)
|
88
|
+
clone_dir = ".#{git_branch}"
|
89
|
+
elsif git_remote = git.find_remote(/git@github\.com:/)
|
90
|
+
git_remote, clone_url = git_remote.split(nil, 2)
|
91
|
+
clone_dir = ".clone-#{$$}-#{rand(100)}"
|
92
|
+
end
|
93
|
+
|
94
|
+
if pages_url # inside git repo and found gh-pages branch
|
95
|
+
|
96
|
+
desc "Publish RDoc to GitHub pages"
|
97
|
+
task :publish_docs => :doc do
|
98
|
+
rm_rf clone_dir
|
99
|
+
|
100
|
+
git.easy_clone pages_url, clone_dir, git_remote
|
101
|
+
|
102
|
+
Dir.chdir(clone_dir) {
|
103
|
+
git.checkout_remote_branch git_remote, git_branch
|
104
|
+
|
105
|
+
cp_r Dir["../#{rdoc_task.rdoc_dir}/*"], '.'
|
106
|
+
|
107
|
+
git.add_and_commit 'Updated documentation.'
|
108
|
+
git.push git_remote, git_branch
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
elsif clone_url # still git repo, but no gh-pages branch
|
113
|
+
|
114
|
+
desc "Create #{git_branch} branch on #{git_remote}"
|
115
|
+
task :make_ghpages do
|
116
|
+
git.easy_clone clone_url, clone_dir, git_remote
|
117
|
+
|
118
|
+
Dir.chdir(clone_dir) {
|
119
|
+
git.symbolic_ref 'HEAD', "refs/heads/#{git_branch}"
|
120
|
+
|
121
|
+
rm_f '.git/index'
|
122
|
+
git.clean '-fdx'
|
123
|
+
|
124
|
+
File.open('index.html', 'w') { |f| f.puts 'My GitHub Page' }
|
125
|
+
|
126
|
+
git.add_and_commit 'First pages commit.'
|
127
|
+
git.push git_remote, git_branch
|
128
|
+
}
|
129
|
+
|
130
|
+
rm_rf clone_dir
|
131
|
+
|
132
|
+
git.fetch git_remote
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
81
138
|
end
|
82
139
|
|
83
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-29 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|