auto-hyde 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "rcov", ">= 0"
13
+ end
14
+
15
+ gem "sinatra", ">= 1.1.0"
16
+ gem "systemu", ">= 1.2.0"
17
+ gem "pony", ">= 1.1"
@@ -0,0 +1,42 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.3)
5
+ git (1.2.5)
6
+ i18n (0.5.0)
7
+ jeweler (1.5.1)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ mail (2.2.12)
12
+ activesupport (>= 2.3.6)
13
+ i18n (>= 0.4.0)
14
+ mime-types (~> 1.16)
15
+ treetop (~> 1.4.8)
16
+ mime-types (1.16)
17
+ polyglot (0.3.1)
18
+ pony (1.1)
19
+ mail (> 2.0)
20
+ rack (1.2.1)
21
+ rake (0.8.7)
22
+ rcov (0.9.9)
23
+ shoulda (2.11.3)
24
+ sinatra (1.1.0)
25
+ rack (~> 1.1)
26
+ tilt (~> 1.1)
27
+ systemu (1.2.0)
28
+ tilt (1.1)
29
+ treetop (1.4.9)
30
+ polyglot (>= 0.3.1)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.0.0)
37
+ jeweler (~> 1.5.1)
38
+ pony (>= 1.1)
39
+ rcov
40
+ shoulda
41
+ sinatra (>= 1.1.0)
42
+ systemu (>= 1.2.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Mike Mayo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ h1. AutoHyde
2
+
3
+ h2. Description
4
+
5
+ AutoHyde is a simple Sinatra application that exposes a single route, /auto-hyde. The purpose is to easily allow you to create
6
+ a GitHub post-receive hook that rebuilds your Jekyll blog or application.
7
+
8
+ h2. Requirements
9
+
10
+ Gems
11
+ * sinatra, >= 1.1.0
12
+ * systemu, >= 1.2.0
13
+ * pony, >= 1.1
14
+
15
+ You obviously will also need jekyll installed, though the only thing required by this app is access to the jekyll binary.
16
+
17
+ h2. Installation
18
+
19
+ <pre>
20
+ git clone git@github.com:gotmayonase/auto-hyde.git
21
+ rake install
22
+
23
+ OR
24
+
25
+ gem install auto-hyde
26
+ </pre>
27
+
28
+ h2. Running AutoHyde
29
+
30
+ <pre>
31
+ Usage: auto-hyde [options]
32
+ -e, --email EMAIL_ADDRESS Send email notification of failures to this email address
33
+ -d, --jekyll-dir DIR Location of your Jekyll project directory, defaults to this directory
34
+ -b, --build-dir DIR Location Jekyll will build your site to, defaults to './_site'
35
+ -p, --port PORT Port for Sinatra to run on, defaults to 4567
36
+ --pygments Turn on Pygment syntax highlighting for Jekyll, defaults to off
37
+ -h, --help Show this message
38
+ </pre>
39
+
40
+ h2. Contributors
41
+
42
+ * Mike Mayo
43
+
44
+ h2. Copyright
45
+
46
+ Copyright (c) 2010 Mike Mayo. See LICENSE.txt for further details.
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "auto-hyde"
16
+ gem.homepage = "http://github.com/gotmayonase/auto-hyde"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{A simple sinatra app exposing a url for github post-receive hooks to hit and trigger a rebuild of a Jekyll site.}
19
+ gem.description = %Q{}
20
+ gem.email = "gotmayonase@gmail.com"
21
+ gem.authors = ["Mike Mayo"]
22
+ gem.add_dependency 'sinatra', '>= 1.1.0'
23
+ gem.add_dependency 'systemu', '>= 1.2.0'
24
+ gem.add_dependency 'pony', '>= 1.1'
25
+ gem.executables << 'auto-hyde'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "auto-hyde #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+ require 'pathname'
5
+ require 'daemons'
6
+ require Pathname(__FILE__).dirname + '../lib/auto-hyde'
7
+
8
+ jekyll_bin = `which jekyll`.chomp
9
+ if jekyll_bin.empty? || jekyll_bin.nil?
10
+ puts('No Jekyll binary found, exiting...')
11
+ exit(1)
12
+ end
13
+
14
+ # =====================================================================================================================
15
+ # Parse Command Line Options
16
+ # =====================================================================================================================
17
+
18
+ options = {
19
+ :build_dir => './_site',
20
+ :jekyll_dir => './',
21
+ :pygments => false,
22
+ :email => nil,
23
+ :jekyll_bin => jekyll_bin
24
+ }
25
+
26
+ option_parser = OptionParser.new do |opts|
27
+ opts.banner = "Usage: auto-hyde [options]"
28
+ # opts.on('-c', '--config-file PATH', 'Path to a YAML config file') { |config_file| options[:config_file] = config_file}
29
+ opts.on('-e', '--email EMAIL_ADDRESS', 'Send email notification of failures to this email address') { |email| options[:email] = email }
30
+ opts.on('-d', '--jekyll-dir DIR', 'Location of your Jekyll project directory, defaults to this directory') { |jekyll_dir| options[:jekyll_dir] = jekyll_dir }
31
+ opts.on('-b', '--build-dir DIR', "Location Jekyll will build your site to, defaults to './_site'") { |build_dir| options[:build_dir] = build_dir }
32
+ opts.on('-p', '--port PORT', 'Port for Sinatra to run on, defaults to 4567') { |port| options[:port] = port }
33
+ opts.on(nil, '--pygments', 'Turn on Pygment syntax highlighting for Jekyll, defaults to off') { options[:pygments] = true }
34
+ opts.on("-h", "--help", "Show this message") { puts opts; exit; }
35
+ end
36
+ option_parser.parse!
37
+
38
+ options.each do |key, value|
39
+ AutoHyde.set key, value
40
+ end
41
+
42
+ pid = fork do
43
+ Signal.trap('HUP', 'IGNORE') # Don't die upon logout
44
+ STDOUT.reopen "/dev/null"
45
+ STDERR.reopen "/dev/null"
46
+ at_exit {
47
+ File.unlink('auto-hyde.pid')
48
+ }
49
+ AutoHyde.run!
50
+ end
51
+
52
+ File.open('auto-hyde.pid','w') { |f| f << pid }
53
+ puts "AutoHyde starting up with pid #{pid}."
54
+
55
+ Process.detach(pid)
@@ -0,0 +1,31 @@
1
+ require 'systemu'
2
+ require 'sinatra/base'
3
+
4
+ # =====================================================================================================================
5
+ # Setup Github Post-Receive route and action
6
+ # =====================================================================================================================
7
+
8
+ class AutoHyde < Sinatra::Base
9
+
10
+ EMAIL_TEMPLATE = <<-EMAIL
11
+ Your Jekyll rebuild failed at #{Time.now} with the following error:
12
+ #{@error}
13
+ EMAIL
14
+
15
+ post '/auto-hyde' do
16
+ cmd = "cd #{settings.jekyll_dir} && git pull && #{settings.jekyll_bin}#{' --pygments' if settings.pygments} #{settings.build_dir}"
17
+ result = systemu(cmd)
18
+ if result[0] == 0
19
+ "Rebuild Failed:\n" + result[2]
20
+ if settings.email
21
+ require 'pony'
22
+ @error = result[2];
23
+ Pony.mail :to => settings.email,
24
+ :from => "no-reply@#{`hostname`.strip}",
25
+ :subject => 'Jekyll Rebuild Failed',
26
+ :body => erb(EMAIL_TEMPLATE)
27
+ end
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'auto-hyde'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestAutoHyde < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,233 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto-hyde
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Mike Mayo
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-10 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ name: sinatra
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 19
31
+ segments:
32
+ - 1
33
+ - 1
34
+ - 0
35
+ version: 1.1.0
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ type: :runtime
40
+ name: systemu
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 31
47
+ segments:
48
+ - 1
49
+ - 2
50
+ - 0
51
+ version: 1.2.0
52
+ requirement: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ prerelease: false
55
+ type: :runtime
56
+ name: pony
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 13
63
+ segments:
64
+ - 1
65
+ - 1
66
+ version: "1.1"
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ prerelease: false
70
+ type: :development
71
+ name: shoulda
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirement: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ prerelease: false
84
+ type: :development
85
+ name: bundler
86
+ version_requirements: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ hash: 23
92
+ segments:
93
+ - 1
94
+ - 0
95
+ - 0
96
+ version: 1.0.0
97
+ requirement: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ prerelease: false
100
+ type: :development
101
+ name: jeweler
102
+ version_requirements: &id006 !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ~>
106
+ - !ruby/object:Gem::Version
107
+ hash: 1
108
+ segments:
109
+ - 1
110
+ - 5
111
+ - 1
112
+ version: 1.5.1
113
+ requirement: *id006
114
+ - !ruby/object:Gem::Dependency
115
+ prerelease: false
116
+ type: :development
117
+ name: rcov
118
+ version_requirements: &id007 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ requirement: *id007
128
+ - !ruby/object:Gem::Dependency
129
+ prerelease: false
130
+ type: :runtime
131
+ name: sinatra
132
+ version_requirements: &id008 !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ hash: 19
138
+ segments:
139
+ - 1
140
+ - 1
141
+ - 0
142
+ version: 1.1.0
143
+ requirement: *id008
144
+ - !ruby/object:Gem::Dependency
145
+ prerelease: false
146
+ type: :runtime
147
+ name: systemu
148
+ version_requirements: &id009 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ hash: 31
154
+ segments:
155
+ - 1
156
+ - 2
157
+ - 0
158
+ version: 1.2.0
159
+ requirement: *id009
160
+ - !ruby/object:Gem::Dependency
161
+ prerelease: false
162
+ type: :runtime
163
+ name: pony
164
+ version_requirements: &id010 !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: 13
170
+ segments:
171
+ - 1
172
+ - 1
173
+ version: "1.1"
174
+ requirement: *id010
175
+ description: ""
176
+ email: gotmayonase@gmail.com
177
+ executables:
178
+ - auto-hyde
179
+ - auto-hyde
180
+ extensions: []
181
+
182
+ extra_rdoc_files:
183
+ - LICENSE.txt
184
+ - README.textile
185
+ files:
186
+ - .document
187
+ - Gemfile
188
+ - Gemfile.lock
189
+ - LICENSE.txt
190
+ - README.textile
191
+ - Rakefile
192
+ - VERSION
193
+ - bin/auto-hyde
194
+ - lib/auto-hyde.rb
195
+ - test/helper.rb
196
+ - test/test_auto-hyde.rb
197
+ has_rdoc: true
198
+ homepage: http://github.com/gotmayonase/auto-hyde
199
+ licenses:
200
+ - MIT
201
+ post_install_message:
202
+ rdoc_options: []
203
+
204
+ require_paths:
205
+ - lib
206
+ required_ruby_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ hash: 3
212
+ segments:
213
+ - 0
214
+ version: "0"
215
+ required_rubygems_version: !ruby/object:Gem::Requirement
216
+ none: false
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ hash: 3
221
+ segments:
222
+ - 0
223
+ version: "0"
224
+ requirements: []
225
+
226
+ rubyforge_project:
227
+ rubygems_version: 1.3.7
228
+ signing_key:
229
+ specification_version: 3
230
+ summary: A simple sinatra app exposing a url for github post-receive hooks to hit and trigger a rebuild of a Jekyll site.
231
+ test_files:
232
+ - test/helper.rb
233
+ - test/test_auto-hyde.rb