technomancy-harker 0.0.3
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.txt +12 -0
- data/Manifest.txt +64 -0
- data/README.rdoc +65 -0
- data/Rakefile +16 -0
- data/bin/harker +19 -0
- data/lib/harker/gemify.rb +40 -0
- data/lib/harker/rails_configuration.rb +27 -0
- data/lib/harker/server.rb +119 -0
- data/lib/harker.rb +105 -0
- data/test/sample/Manifest.txt +53 -0
- data/test/sample/README.rdoc +46 -0
- data/test/sample/Rakefile +16 -0
- data/test/sample/app/controllers/application_controller.rb +10 -0
- data/test/sample/app/controllers/harks_controller.rb +6 -0
- data/test/sample/app/helpers/application_helper.rb +3 -0
- data/test/sample/app/helpers/harks_helper.rb +2 -0
- data/test/sample/app/models/hark.rb +2 -0
- data/test/sample/bin/sample_rails +5 -0
- data/test/sample/config/boot.rb +110 -0
- data/test/sample/config/database.yml +22 -0
- data/test/sample/config/environment.rb +41 -0
- data/test/sample/config/environments/development.rb +17 -0
- data/test/sample/config/environments/production.rb +28 -0
- data/test/sample/config/environments/test.rb +28 -0
- data/test/sample/config/initializers/backtrace_silencers.rb +7 -0
- data/test/sample/config/initializers/inflections.rb +10 -0
- data/test/sample/config/initializers/mime_types.rb +5 -0
- data/test/sample/config/initializers/new_rails_defaults.rb +19 -0
- data/test/sample/config/initializers/session_store.rb +15 -0
- data/test/sample/config/locales/en.yml +5 -0
- data/test/sample/config/routes.rb +45 -0
- data/test/sample/db/migrate/20090326050232_create_harks.rb +12 -0
- data/test/sample/lib/sample_rails.rb +2 -0
- data/test/sample/public/404.html +30 -0
- data/test/sample/public/422.html +30 -0
- data/test/sample/public/500.html +30 -0
- data/test/sample/public/favicon.ico +0 -0
- data/test/sample/public/images/rails.png +0 -0
- data/test/sample/public/index.html +275 -0
- data/test/sample/public/javascripts/application.js +2 -0
- data/test/sample/public/javascripts/controls.js +963 -0
- data/test/sample/public/javascripts/dragdrop.js +973 -0
- data/test/sample/public/javascripts/effects.js +1128 -0
- data/test/sample/public/javascripts/prototype.js +4320 -0
- data/test/sample/public/robots.txt +5 -0
- data/test/sample/script/about +4 -0
- data/test/sample/script/console +3 -0
- data/test/sample/script/dbconsole +3 -0
- data/test/sample/script/destroy +3 -0
- data/test/sample/script/generate +3 -0
- data/test/sample/script/performance/benchmarker +3 -0
- data/test/sample/script/performance/profiler +3 -0
- data/test/sample/script/plugin +3 -0
- data/test/sample/script/runner +3 -0
- data/test/sample/script/server +3 -0
- data/test/sample/test/fixtures/harks.yml +7 -0
- data/test/sample/test/functional/harks_controller_test.rb +8 -0
- data/test/sample/test/performance/browsing_test.rb +9 -0
- data/test/sample/test/test_helper.rb +38 -0
- data/test/sample/test/unit/hark_test.rb +8 -0
- data/test/sample/test/unit/helpers/harks_helper_test.rb +4 -0
- data/test/test_harker.rb +83 -0
- metadata +159 -0
data/History.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
=== 0.0.3 / 2009-03-26
|
2
|
+
|
3
|
+
* A release!
|
4
|
+
* First pass at automating gemification of Rails apps with bin/harker.
|
5
|
+
* Swapped order of Harker.launch args; now action then instance dir.
|
6
|
+
* Apps don't need config/environment.rb tweaks to use harker.
|
7
|
+
* Got some docs; yay.
|
8
|
+
|
9
|
+
=== 0.0.1 / 2009-03-25
|
10
|
+
|
11
|
+
* Birthday!
|
12
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
bin/harker
|
6
|
+
lib/harker.rb
|
7
|
+
lib/harker/gemify.rb
|
8
|
+
lib/harker/rails_configuration.rb
|
9
|
+
lib/harker/server.rb
|
10
|
+
test/sample/Manifest.txt
|
11
|
+
test/sample/README.rdoc
|
12
|
+
test/sample/Rakefile
|
13
|
+
test/sample/app/controllers/application_controller.rb
|
14
|
+
test/sample/app/controllers/harks_controller.rb
|
15
|
+
test/sample/app/helpers/application_helper.rb
|
16
|
+
test/sample/app/helpers/harks_helper.rb
|
17
|
+
test/sample/app/models/hark.rb
|
18
|
+
test/sample/bin/sample_rails
|
19
|
+
test/sample/config/boot.rb
|
20
|
+
test/sample/config/database.yml
|
21
|
+
test/sample/config/environment.rb
|
22
|
+
test/sample/config/environments/development.rb
|
23
|
+
test/sample/config/environments/production.rb
|
24
|
+
test/sample/config/environments/test.rb
|
25
|
+
test/sample/config/initializers/backtrace_silencers.rb
|
26
|
+
test/sample/config/initializers/inflections.rb
|
27
|
+
test/sample/config/initializers/mime_types.rb
|
28
|
+
test/sample/config/initializers/new_rails_defaults.rb
|
29
|
+
test/sample/config/initializers/session_store.rb
|
30
|
+
test/sample/config/locales/en.yml
|
31
|
+
test/sample/config/routes.rb
|
32
|
+
test/sample/db/migrate/20090326050232_create_harks.rb
|
33
|
+
test/sample/lib/sample_rails.rb
|
34
|
+
test/sample/log/development.log
|
35
|
+
test/sample/log/test.log
|
36
|
+
test/sample/public/404.html
|
37
|
+
test/sample/public/422.html
|
38
|
+
test/sample/public/500.html
|
39
|
+
test/sample/public/favicon.ico
|
40
|
+
test/sample/public/images/rails.png
|
41
|
+
test/sample/public/index.html
|
42
|
+
test/sample/public/javascripts/application.js
|
43
|
+
test/sample/public/javascripts/controls.js
|
44
|
+
test/sample/public/javascripts/dragdrop.js
|
45
|
+
test/sample/public/javascripts/effects.js
|
46
|
+
test/sample/public/javascripts/prototype.js
|
47
|
+
test/sample/public/robots.txt
|
48
|
+
test/sample/script/about
|
49
|
+
test/sample/script/console
|
50
|
+
test/sample/script/dbconsole
|
51
|
+
test/sample/script/destroy
|
52
|
+
test/sample/script/generate
|
53
|
+
test/sample/script/performance/benchmarker
|
54
|
+
test/sample/script/performance/profiler
|
55
|
+
test/sample/script/plugin
|
56
|
+
test/sample/script/runner
|
57
|
+
test/sample/script/server
|
58
|
+
test/sample/test/fixtures/harks.yml
|
59
|
+
test/sample/test/functional/harks_controller_test.rb
|
60
|
+
test/sample/test/performance/browsing_test.rb
|
61
|
+
test/sample/test/test_helper.rb
|
62
|
+
test/sample/test/unit/hark_test.rb
|
63
|
+
test/sample/test/unit/helpers/harks_helper_test.rb
|
64
|
+
test/test_harker.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
= Harker
|
2
|
+
|
3
|
+
http://github.com/technomancy/harker
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Harker means Rails deployments via RubyGems--because a package manager
|
8
|
+
is a terrible thing to waste.
|
9
|
+
|
10
|
+
== Setup
|
11
|
+
|
12
|
+
Your Rails app will need to be modified a bit to become a gem and work
|
13
|
+
with Harker. Running "harker /path/to/rails/app" will attempt to turn
|
14
|
+
it into a gem that uses Hoe. It probably won't be perfect, but it's a
|
15
|
+
start. See the app in test/sample/ for an example of how this works.
|
16
|
+
|
17
|
+
You don't have to use Hoe if you want to turn your app into a gem
|
18
|
+
manually or using another library, but it helps.
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
|
22
|
+
Once your app is a gem, install it locally with "rake install_gem",
|
23
|
+
and you should be able to use the bin wrapper to generate a new
|
24
|
+
instance:
|
25
|
+
|
26
|
+
$ your_app init /var/myapp
|
27
|
+
|
28
|
+
Then edit /var/myapp/database.yml with your database settings. At that
|
29
|
+
point you should be able to bring up your database:
|
30
|
+
|
31
|
+
$ RAILS_ENV=production your_app migrate /var/myapp
|
32
|
+
|
33
|
+
Test it out by dropping into the console:
|
34
|
+
|
35
|
+
$ RAILS_ENV=production your_app console /var/myapp
|
36
|
+
|
37
|
+
Then you can start and stop your application server via Rack:
|
38
|
+
|
39
|
+
$ RAILS_ENV=production your_app start /var/myapp
|
40
|
+
$ RAILS_ENV=production your_app stop /var/myapp
|
41
|
+
|
42
|
+
If you omit the second argument, it defaults to the current directory.
|
43
|
+
|
44
|
+
For deployment, simply publish your gem to a gem server (public or
|
45
|
+
private), install it on the target server, and launch it via the bin
|
46
|
+
wrappers.
|
47
|
+
|
48
|
+
TODO: automate /etc/init.d scripts?
|
49
|
+
|
50
|
+
== Requirements
|
51
|
+
|
52
|
+
* rails (at least 2.3.2)
|
53
|
+
* a Rails app to use it with
|
54
|
+
* rubygems
|
55
|
+
* hoe (technically optional)
|
56
|
+
|
57
|
+
== Install
|
58
|
+
|
59
|
+
* sudo gem install technomancy-harker --source=http://gems.github.com --source=http://gems.rubyforge.org
|
60
|
+
|
61
|
+
== License
|
62
|
+
|
63
|
+
Copyright (c) 2009 Phil Hagelberg.
|
64
|
+
|
65
|
+
Licensed under the same terms as Ruby.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/harker.rb'
|
6
|
+
|
7
|
+
Hoe.new('harker', Harker::VERSION) do |p|
|
8
|
+
p.readme_file = 'README.rdoc'
|
9
|
+
p.summary = "Concourse is a tool to make planning gatherings easy."
|
10
|
+
p.extra_deps << ["rails", "~> 2.3.2"]
|
11
|
+
p.extra_dev_deps << ["minitest", "~> 1.3.1"]
|
12
|
+
p.extra_dev_deps << ["sqlite3-ruby", "~> 1.2.4"]
|
13
|
+
p.developer('Phil Hagelberg', 'technomancy@gmail.com')
|
14
|
+
end
|
15
|
+
|
16
|
+
# vim: syntax=Ruby
|
data/bin/harker
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'harker/gemify'
|
4
|
+
|
5
|
+
begin
|
6
|
+
gem 'hoe'
|
7
|
+
rescue LoadError
|
8
|
+
abort 'Hoe not found. You can continue without hoe if you gemify
|
9
|
+
your app yourself; see Harker documentation for details.' # TODO: document!
|
10
|
+
end
|
11
|
+
|
12
|
+
if ARGV.include?('-h') or ARGV.include?('--help') or ARGV.size > 1
|
13
|
+
puts "Usage: #{File.dirname($0)} [RAILS_ROOT]"
|
14
|
+
puts
|
15
|
+
puts "Attempts to turn your Rails app into a gem for deployment with harker."
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
Harker.gemify(ARGV.shift || Dir.pwd)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'harker'
|
2
|
+
|
3
|
+
module Harker
|
4
|
+
def self.gemify(rails_root)
|
5
|
+
project_name = File.basename(rails_root)
|
6
|
+
|
7
|
+
if File.exist?(rails_root + "/bin/#{project_name}", 'w') or
|
8
|
+
File.exist?(rails_root + "/lib/#{project_name}.rb", 'w')
|
9
|
+
abort "Can't write gem files without overwriting existing ones.
|
10
|
+
Try manually gemifying."
|
11
|
+
end
|
12
|
+
|
13
|
+
# TODO: can we specify the version better?
|
14
|
+
hoe = "Hoe.new('#{project_name}', '1.0.0') do |p|
|
15
|
+
p.extra_deps << ['rails', '~> 2.3.2']
|
16
|
+
p.extra_deps << ['harker', '~> #{Harker::VERSION}']
|
17
|
+
p.developer('Your Name', 'you@example.com') # FIXME!
|
18
|
+
end"
|
19
|
+
|
20
|
+
bin = "#!/usr/bin/env ruby
|
21
|
+
require 'rubygems'
|
22
|
+
require 'harker'
|
23
|
+
|
24
|
+
Harker.launch(File.basename($0), ARGV)"
|
25
|
+
|
26
|
+
lib = "# Allow rubygems to load this app
|
27
|
+
require File.dirname(__FILE__) + '/../config/environment'"
|
28
|
+
|
29
|
+
File.open(rails_root + '/Rakefile', 'a') { |fp| fp.puts hoe }
|
30
|
+
puts "Added hoe block to Rakefile."
|
31
|
+
File.open(rails_root + "/bin/#{project_name}", 'w') { fp.puts bin }
|
32
|
+
puts "Wrote bin launcher."
|
33
|
+
File.open(rails_root + "/lib/#{project_name}.rb", 'w') { fp.puts lib }
|
34
|
+
puts "Wrote lib file."
|
35
|
+
system "cd #{rails_root}; rake check_manifest | patch"
|
36
|
+
puts "Wrote manifest."
|
37
|
+
|
38
|
+
puts "Done! Try running rake install_gem."
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# TODO: not sure if my Rails patches cover tmp/sessions or tmp/sockets
|
2
|
+
|
3
|
+
class Rails::Configuration
|
4
|
+
attr_accessor :tmp_dir
|
5
|
+
|
6
|
+
def default_tmp_dir
|
7
|
+
File.join(root_path, 'tmp')
|
8
|
+
end
|
9
|
+
|
10
|
+
def default_cache_store
|
11
|
+
if File.exist? File.join(default_tmp_dir, 'cache')
|
12
|
+
[ :file_store, File.join(default_tmp_dir, 'cache') ]
|
13
|
+
else
|
14
|
+
:memory_store
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Rails::Initializer
|
20
|
+
def self.run(command = :process, configuration = Configuration.new)
|
21
|
+
yield configuration if block_given?
|
22
|
+
Harker.configure(configuration)
|
23
|
+
initializer = new configuration
|
24
|
+
initializer.send(command)
|
25
|
+
initializer
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# A patched copy of what Rails' script/server runs.
|
2
|
+
# Only two changes were made, noted below by comments beginning with "Harker"
|
3
|
+
|
4
|
+
require 'active_support'
|
5
|
+
require 'action_controller'
|
6
|
+
|
7
|
+
require 'fileutils'
|
8
|
+
require 'optparse'
|
9
|
+
|
10
|
+
# TODO: Push Thin adapter upstream so we don't need worry about requiring it
|
11
|
+
begin
|
12
|
+
require_library_or_gem 'thin'
|
13
|
+
rescue Exception
|
14
|
+
# Thin not available
|
15
|
+
end
|
16
|
+
|
17
|
+
options = {
|
18
|
+
:Port => 3000,
|
19
|
+
:Host => "0.0.0.0",
|
20
|
+
:environment => (ENV['RAILS_ENV'] || "development").dup,
|
21
|
+
:config => RAILS_ROOT + "/config.ru",
|
22
|
+
:detach => false,
|
23
|
+
:debugger => false,
|
24
|
+
:path => nil
|
25
|
+
}
|
26
|
+
|
27
|
+
ARGV.clone.options do |opts|
|
28
|
+
opts.on("-p", "--port=port", Integer,
|
29
|
+
"Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v }
|
30
|
+
opts.on("-b", "--binding=ip", String,
|
31
|
+
"Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v }
|
32
|
+
opts.on("-c", "--config=file", String,
|
33
|
+
"Use custom rackup configuration file") { |v| options[:config] = v }
|
34
|
+
opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:detach] = true }
|
35
|
+
opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true }
|
36
|
+
opts.on("-e", "--environment=name", String,
|
37
|
+
"Specifies the environment to run this server under (test/development/production).",
|
38
|
+
"Default: development") { |v| options[:environment] = v }
|
39
|
+
opts.on("-P", "--path=/path", String, "Runs Rails app mounted at a specific path.", "Default: /") { |v| options[:path] = v }
|
40
|
+
|
41
|
+
opts.separator ""
|
42
|
+
|
43
|
+
opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
|
44
|
+
|
45
|
+
opts.parse!
|
46
|
+
end
|
47
|
+
|
48
|
+
server = Rack::Handler.get(ARGV.first) rescue nil
|
49
|
+
unless server
|
50
|
+
begin
|
51
|
+
server = Rack::Handler::Mongrel
|
52
|
+
rescue LoadError => e
|
53
|
+
server = Rack::Handler::WEBrick
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
|
58
|
+
puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}#{options[:path]}"
|
59
|
+
|
60
|
+
%w(cache pids sessions sockets).each do |dir_to_make|
|
61
|
+
# Harker: patched to use Rails.configuration.tmp_dir
|
62
|
+
FileUtils.mkdir_p(File.join(Rails.configuration.tmp_dir, dir_to_make))
|
63
|
+
end
|
64
|
+
|
65
|
+
if options[:detach]
|
66
|
+
Process.daemon
|
67
|
+
# Harker: patched to use Rails.configuration.tmp_dir
|
68
|
+
pid = File.join(Rails.configuration.tmp_dir, 'pids', 'server.pid')
|
69
|
+
File.open(pid, 'w'){ |f| f.write(Process.pid) }
|
70
|
+
at_exit { File.delete(pid) if File.exist?(pid) }
|
71
|
+
end
|
72
|
+
|
73
|
+
ENV["RAILS_ENV"] = options[:environment]
|
74
|
+
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
|
75
|
+
|
76
|
+
if File.exist?(options[:config])
|
77
|
+
config = options[:config]
|
78
|
+
if config =~ /\.ru$/
|
79
|
+
cfgfile = File.read(config)
|
80
|
+
if cfgfile[/^#\\(.*)/]
|
81
|
+
opts.parse!($1.split(/\s+/))
|
82
|
+
end
|
83
|
+
inner_app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config)
|
84
|
+
else
|
85
|
+
require config
|
86
|
+
inner_app = Object.const_get(File.basename(config, '.rb').capitalize)
|
87
|
+
end
|
88
|
+
else
|
89
|
+
require RAILS_ROOT + "/config/environment"
|
90
|
+
inner_app = ActionController::Dispatcher.new
|
91
|
+
end
|
92
|
+
|
93
|
+
if options[:path].nil?
|
94
|
+
map_path = "/"
|
95
|
+
else
|
96
|
+
ActionController::Base.relative_url_root = options[:path]
|
97
|
+
map_path = options[:path]
|
98
|
+
end
|
99
|
+
|
100
|
+
app = Rack::Builder.new {
|
101
|
+
use Rails::Rack::LogTailer unless options[:detach]
|
102
|
+
use Rails::Rack::Debugger if options[:debugger]
|
103
|
+
map map_path do
|
104
|
+
use Rails::Rack::Static
|
105
|
+
run inner_app
|
106
|
+
end
|
107
|
+
}.to_app
|
108
|
+
|
109
|
+
puts "=> Call with -d to detach"
|
110
|
+
|
111
|
+
trap(:INT) { exit }
|
112
|
+
|
113
|
+
puts "=> Ctrl-C to shutdown server"
|
114
|
+
|
115
|
+
begin
|
116
|
+
server.run(app, options.merge(:AccessLog => []))
|
117
|
+
ensure
|
118
|
+
puts 'Exiting'
|
119
|
+
end
|
data/lib/harker.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
# Harker lets you deploy Rails apps via RubyGems.
|
4
|
+
module Harker
|
5
|
+
VERSION = '0.0.3'
|
6
|
+
ACTIONS = %w(start stop restart init migrate console foreground)
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
# Dispatch based on user's command
|
11
|
+
def launch(name, args)
|
12
|
+
action = args.shift
|
13
|
+
|
14
|
+
unless ACTIONS.include?(action)
|
15
|
+
abort "Usage: #{@name} INSTANCE_DIR (#{ACTIONS.join('|')})"
|
16
|
+
end
|
17
|
+
|
18
|
+
@root = File.expand_path(args.shift || Dir.pwd)
|
19
|
+
@name = name
|
20
|
+
|
21
|
+
load_app unless action == 'init'
|
22
|
+
self.send(action)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Start the application server in the foreground.
|
26
|
+
def foreground
|
27
|
+
start(false)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Start and daemonize the application server
|
31
|
+
def start(daemonize = true)
|
32
|
+
# can has internal consistency plz, Rails?
|
33
|
+
Rails::Rack::LogTailer::EnvironmentLog.replace(Rails.configuration.log_path)
|
34
|
+
# http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2350
|
35
|
+
# Submitted a patch to Rails, but this lets it work with 2.3.2
|
36
|
+
|
37
|
+
ARGV.replace ["--config=#{@root}/config.ru"]
|
38
|
+
ARGV.push('--daemon') if daemonize
|
39
|
+
|
40
|
+
abort "Can't start; pidfile exists at #{pidfile}." if File.exist? pidfile
|
41
|
+
require 'harker/server'
|
42
|
+
end
|
43
|
+
|
44
|
+
def stop
|
45
|
+
abort "No pid at #{pidfile}." unless File.exist?(pidfile)
|
46
|
+
Process.kill('TERM', File.read(pidfile).to_i)
|
47
|
+
end
|
48
|
+
|
49
|
+
def restart
|
50
|
+
stop
|
51
|
+
start
|
52
|
+
end
|
53
|
+
|
54
|
+
# Initialize a new instance of your application
|
55
|
+
def init
|
56
|
+
FileUtils.mkdir_p(@root)
|
57
|
+
FileUtils.mkdir_p(@root + '/log')
|
58
|
+
FileUtils.mkdir_p(@root + '/tmp')
|
59
|
+
|
60
|
+
# TODO: use the in-gem copy of database.yml as a base for this
|
61
|
+
File.open("#{@root}/database.yml", 'w') do |fp|
|
62
|
+
# TODO: be smart about environments; bleh
|
63
|
+
fp.puts({ 'production' => { 'adapter' => 'sqlite3',
|
64
|
+
'database' => @root + '/db.sqlite3',
|
65
|
+
'pool' => 5, 'timeout' => 5000 }}.to_yaml)
|
66
|
+
end
|
67
|
+
|
68
|
+
# TODO: write a default config.ru?
|
69
|
+
|
70
|
+
puts "Initialized #{@name} instance in #{@root}..."
|
71
|
+
puts
|
72
|
+
puts "Configure your database by editing #{@root}/database.yml."
|
73
|
+
puts "Optionally configure your web server via rack in #{@root}/config.ru."
|
74
|
+
puts
|
75
|
+
puts "Migrate your DB with: #{@name} migrate"
|
76
|
+
puts "Then launch with: #{@name} start"
|
77
|
+
end
|
78
|
+
|
79
|
+
def migrate
|
80
|
+
ActiveRecord::Migrator.migrate(RAILS_ROOT + '/db/migrate',
|
81
|
+
ENV["VERSION"] && ENV["VERSION"].to_i)
|
82
|
+
end
|
83
|
+
|
84
|
+
def console
|
85
|
+
require 'irb'
|
86
|
+
IRB.start
|
87
|
+
end
|
88
|
+
|
89
|
+
def configure(config)
|
90
|
+
config.database_configuration_file = File.join(@root, 'database.yml')
|
91
|
+
config.log_path = File.join(@root, 'log', "#{RAILS_ENV}.log")
|
92
|
+
|
93
|
+
# 2.3.2 doesn't support tmp_dir config option.
|
94
|
+
require 'harker/rails_configuration' unless config.respond_to?(:tmp_dir=)
|
95
|
+
config.tmp_dir = File.join(@root, '/tmp')
|
96
|
+
end
|
97
|
+
|
98
|
+
def load_app
|
99
|
+
require @name
|
100
|
+
end
|
101
|
+
|
102
|
+
def pidfile
|
103
|
+
File.join(@root, 'tmp', 'pids', 'server.pid')
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Manifest.txt
|
2
|
+
README.rdoc
|
3
|
+
Rakefile
|
4
|
+
app/controllers/application_controller.rb
|
5
|
+
app/controllers/harks_controller.rb
|
6
|
+
app/helpers/application_helper.rb
|
7
|
+
app/helpers/harks_helper.rb
|
8
|
+
app/models/hark.rb
|
9
|
+
bin/sample_rails
|
10
|
+
config/boot.rb
|
11
|
+
config/database.yml
|
12
|
+
config/environment.rb
|
13
|
+
config/environments/development.rb
|
14
|
+
config/environments/production.rb
|
15
|
+
config/environments/test.rb
|
16
|
+
config/initializers/backtrace_silencers.rb
|
17
|
+
config/initializers/inflections.rb
|
18
|
+
config/initializers/mime_types.rb
|
19
|
+
config/initializers/new_rails_defaults.rb
|
20
|
+
config/initializers/session_store.rb
|
21
|
+
config/locales/en.yml
|
22
|
+
config/routes.rb
|
23
|
+
db/migrate/20090326050232_create_harks.rb
|
24
|
+
lib/sample_rails.rb
|
25
|
+
public/404.html
|
26
|
+
public/422.html
|
27
|
+
public/500.html
|
28
|
+
public/favicon.ico
|
29
|
+
public/images/rails.png
|
30
|
+
public/index.html
|
31
|
+
public/javascripts/application.js
|
32
|
+
public/javascripts/controls.js
|
33
|
+
public/javascripts/dragdrop.js
|
34
|
+
public/javascripts/effects.js
|
35
|
+
public/javascripts/prototype.js
|
36
|
+
public/robots.txt
|
37
|
+
script/about
|
38
|
+
script/console
|
39
|
+
script/dbconsole
|
40
|
+
script/destroy
|
41
|
+
script/generate
|
42
|
+
script/performance/benchmarker
|
43
|
+
script/performance/profiler
|
44
|
+
script/plugin
|
45
|
+
script/runner
|
46
|
+
script/server
|
47
|
+
test/fixtures/harks.yml
|
48
|
+
test/functional/harks_controller_test.rb
|
49
|
+
test/performance/browsing_test.rb
|
50
|
+
test/test_helper.rb
|
51
|
+
test/unit/hark_test.rb
|
52
|
+
test/unit/helpers/harks_helper_test.rb
|
53
|
+
tmp
|
@@ -0,0 +1,46 @@
|
|
1
|
+
= Harker Sample
|
2
|
+
|
3
|
+
http://github.com/technomancy/harker
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
A sample application.
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
Just for tests.
|
12
|
+
|
13
|
+
== Requirements
|
14
|
+
|
15
|
+
* rails (at least 2.3.2)
|
16
|
+
* rubygems
|
17
|
+
* hoe
|
18
|
+
|
19
|
+
== Install
|
20
|
+
|
21
|
+
* sudo gem install harker
|
22
|
+
|
23
|
+
== License
|
24
|
+
|
25
|
+
(The MIT License)
|
26
|
+
|
27
|
+
Copyright (c) 2009 Phil Hagelberg
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
'Software'), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
43
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
44
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
45
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
46
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'rake/rdoctask'
|
7
|
+
require 'tasks/rails'
|
8
|
+
|
9
|
+
# TODO: Hoe and Rails' test tasks stomp on each other
|
10
|
+
# TODO: specify version sanely
|
11
|
+
Hoe.new('sample_rails', '1.0.0') do |p|
|
12
|
+
p.readme_file = 'README.rdoc'
|
13
|
+
p.extra_deps << ["rails", "~> 2.3.2"]
|
14
|
+
p.extra_deps << ["harker", "~> 0.0.1"]
|
15
|
+
p.developer('Phil Hagelberg', 'technomancy@gmail.com')
|
16
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
+
|
8
|
+
# Scrub sensitive parameters from your log
|
9
|
+
# filter_parameter_logging :password
|
10
|
+
end
|