brendan-skynet 0.9.33 → 0.9.303
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/License.txt +1 -0
- data/Manifest.txt +19 -112
- data/Rakefile +3 -3
- data/app_generators/skynet_install/templates/skynet_config.rb +1 -1
- data/extras/rails/views/skynet/index.html.erb +137 -0
- data/lib/skynet.rb +15 -15
- data/lib/skynet/{skynet_active_record_extensions.rb → active_record_extensions.rb} +0 -0
- data/lib/skynet/{skynet_config.rb → config.rb} +0 -0
- data/lib/skynet/{skynet_console.rb → console.rb} +1 -1
- data/lib/skynet/{skynet_console_helper.rb → console_helper.rb} +0 -0
- data/lib/skynet/{skynet_debugger.rb → debugger.rb} +0 -0
- data/lib/skynet/{skynet_guid_generator.rb → guid_generator.rb} +0 -0
- data/lib/skynet/{skynet_job.rb → job.rb} +0 -0
- data/lib/skynet/{skynet_launcher.rb → launcher.rb} +0 -0
- data/lib/skynet/{skynet_logger.rb → logger.rb} +0 -0
- data/lib/skynet/{skynet_manager.rb → manager.rb} +0 -0
- data/lib/skynet/{skynet_message.rb → message.rb} +0 -0
- data/lib/skynet/{skynet_message_queue.rb → message_queue.rb} +0 -0
- data/lib/skynet/{skynet_partitioners.rb → partitioners.rb} +0 -0
- data/lib/skynet/{skynet_ruby_extensions.rb → ruby_extensions.rb} +0 -0
- data/lib/skynet/{skynet_task.rb → task.rb} +0 -0
- data/lib/skynet/{skynet_tuplespace_server.rb → tuplespace_server.rb} +0 -0
- data/lib/skynet/version.rb +1 -1
- data/lib/skynet/{skynet_worker.rb → worker.rb} +0 -0
- data/skynet.gemspec +21 -132
- metadata +22 -130
- data/examples/dgrep/README +0 -70
- data/examples/dgrep/config/skynet_config.rb +0 -26
- data/examples/dgrep/data/shakespeare/README +0 -2
- data/examples/dgrep/data/shakespeare/poetry/loverscomplaint +0 -381
- data/examples/dgrep/data/shakespeare/poetry/rapeoflucrece +0 -2199
- data/examples/dgrep/data/shakespeare/poetry/sonnets +0 -2633
- data/examples/dgrep/data/shakespeare/poetry/various +0 -640
- data/examples/dgrep/data/shakespeare/poetry/venusandadonis +0 -1423
- data/examples/dgrep/data/testfile1.txt +0 -1
- data/examples/dgrep/data/testfile2.txt +0 -1
- data/examples/dgrep/data/testfile3.txt +0 -1
- data/examples/dgrep/data/testfile4.txt +0 -1
- data/examples/dgrep/lib/dgrep.rb +0 -59
- data/examples/dgrep/lib/mapreduce_test.rb +0 -32
- data/examples/dgrep/lib/most_common_words.rb +0 -45
- data/examples/dgrep/script/dgrep +0 -75
- data/examples/rails_mysql_example/README +0 -66
- data/examples/rails_mysql_example/Rakefile +0 -10
- data/examples/rails_mysql_example/app/controllers/application.rb +0 -10
- data/examples/rails_mysql_example/app/helpers/application_helper.rb +0 -3
- data/examples/rails_mysql_example/app/models/user.rb +0 -21
- data/examples/rails_mysql_example/app/models/user_favorite.rb +0 -5
- data/examples/rails_mysql_example/app/models/user_mailer.rb +0 -12
- data/examples/rails_mysql_example/app/views/user_mailer/welcome.erb +0 -5
- data/examples/rails_mysql_example/config/boot.rb +0 -109
- data/examples/rails_mysql_example/config/database.yml +0 -42
- data/examples/rails_mysql_example/config/environment.rb +0 -59
- data/examples/rails_mysql_example/config/environments/development.rb +0 -18
- data/examples/rails_mysql_example/config/environments/production.rb +0 -19
- data/examples/rails_mysql_example/config/environments/test.rb +0 -22
- data/examples/rails_mysql_example/config/initializers/inflections.rb +0 -10
- data/examples/rails_mysql_example/config/initializers/mime_types.rb +0 -5
- data/examples/rails_mysql_example/config/initializers/skynet.rb +0 -1
- data/examples/rails_mysql_example/config/routes.rb +0 -35
- data/examples/rails_mysql_example/config/skynet_config.rb +0 -36
- data/examples/rails_mysql_example/db/migrate/001_create_skynet_tables.rb +0 -43
- data/examples/rails_mysql_example/db/migrate/002_create_users.rb +0 -16
- data/examples/rails_mysql_example/db/migrate/003_create_user_favorites.rb +0 -14
- data/examples/rails_mysql_example/db/schema.rb +0 -85
- data/examples/rails_mysql_example/db/skynet_mysql_schema.sql +0 -33
- data/examples/rails_mysql_example/doc/README_FOR_APP +0 -2
- data/examples/rails_mysql_example/lib/tasks/rails_mysql_example.rake +0 -20
- data/examples/rails_mysql_example/public/404.html +0 -30
- data/examples/rails_mysql_example/public/422.html +0 -30
- data/examples/rails_mysql_example/public/500.html +0 -30
- data/examples/rails_mysql_example/public/dispatch.cgi +0 -10
- data/examples/rails_mysql_example/public/dispatch.fcgi +0 -24
- data/examples/rails_mysql_example/public/dispatch.rb +0 -10
- data/examples/rails_mysql_example/public/favicon.ico +0 -0
- data/examples/rails_mysql_example/public/images/rails.png +0 -0
- data/examples/rails_mysql_example/public/index.html +0 -277
- data/examples/rails_mysql_example/public/javascripts/application.js +0 -2
- data/examples/rails_mysql_example/public/javascripts/controls.js +0 -963
- data/examples/rails_mysql_example/public/javascripts/dragdrop.js +0 -972
- data/examples/rails_mysql_example/public/javascripts/effects.js +0 -1120
- data/examples/rails_mysql_example/public/javascripts/prototype.js +0 -4225
- data/examples/rails_mysql_example/public/robots.txt +0 -5
- data/examples/rails_mysql_example/script/about +0 -3
- data/examples/rails_mysql_example/script/console +0 -3
- data/examples/rails_mysql_example/script/destroy +0 -3
- data/examples/rails_mysql_example/script/generate +0 -3
- data/examples/rails_mysql_example/script/performance/benchmarker +0 -3
- data/examples/rails_mysql_example/script/performance/profiler +0 -3
- data/examples/rails_mysql_example/script/performance/request +0 -3
- data/examples/rails_mysql_example/script/plugin +0 -3
- data/examples/rails_mysql_example/script/process/inspector +0 -3
- data/examples/rails_mysql_example/script/process/reaper +0 -3
- data/examples/rails_mysql_example/script/process/spawner +0 -3
- data/examples/rails_mysql_example/script/runner +0 -3
- data/examples/rails_mysql_example/script/server +0 -3
- data/examples/rails_mysql_example/test/fixtures/user_favorites.yml +0 -9
- data/examples/rails_mysql_example/test/fixtures/users.yml +0 -11
- data/examples/rails_mysql_example/test/test_helper.rb +0 -38
- data/examples/rails_mysql_example/test/unit/user_favorite_test.rb +0 -8
- data/examples/rails_mysql_example/test/unit/user_test.rb +0 -8
- data/extras/nagios/check_skynet.sh +0 -121
- data/extras/rails/views/skynet/index.rhtml +0 -137
- data/tasks/website.rake +0 -17
- data/test/test_active_record_extensions.rb +0 -138
- data/test/test_generator_helper.rb +0 -20
- data/test/test_helper.rb +0 -10
- data/test/test_mysql_message_queue_adapter.rb +0 -263
- data/test/test_skynet.rb +0 -19
- data/test/test_skynet_install_generator.rb +0 -49
- data/test/test_skynet_job.rb +0 -717
- data/test/test_skynet_manager.rb +0 -157
- data/test/test_skynet_message.rb +0 -229
- data/test/test_skynet_task.rb +0 -24
- data/test/test_tuplespace_message_queue.rb +0 -174
- data/website/index.html +0 -181
- data/website/index.txt +0 -98
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
@@ -1 +0,0 @@
|
|
1
|
-
This is a test file with some data
|
@@ -1 +0,0 @@
|
|
1
|
-
Another file with more data and more data
|
@@ -1 +0,0 @@
|
|
1
|
-
One more file with no D ata
|
@@ -1 +0,0 @@
|
|
1
|
-
Some thing data
|
data/examples/dgrep/lib/dgrep.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
class Dgrep
|
2
|
-
include SkynetDebugger
|
3
|
-
|
4
|
-
# Takes an array that looks like [ [filename1,["word1","word2"]], [filename2,["word1","word2"]] ]
|
5
|
-
# Returns an array that looks like [ [word1, cnt], [word2,cnt], [word1, cnt] ]
|
6
|
-
# Map gets an array and should return an array
|
7
|
-
def self.map(map_datas)
|
8
|
-
results = []
|
9
|
-
map_datas.each do |filename,words|
|
10
|
-
begin
|
11
|
-
words.each do |word|
|
12
|
-
cnt = File.read(filename).scan(/\W#{word}\W/i).size
|
13
|
-
results << [word,cnt] if cnt and cnt > 0
|
14
|
-
end
|
15
|
-
rescue Errno::EISDIR
|
16
|
-
# skip directories
|
17
|
-
end
|
18
|
-
end
|
19
|
-
return results if results.any?
|
20
|
-
end
|
21
|
-
|
22
|
-
# The chosen reduce partiioner attempts group keys by partition. For example, if you choose 2 words and 2 reducers it will make sure
|
23
|
-
# the first word goes to the first reducer and the second word to the second reducer. If you only have 1 reducer (the defaukt)
|
24
|
-
# It doesn't bother partitioning. You can write as complex a partiioner as you'd like.
|
25
|
-
def self.reduce_partition(post_map_data,new_partitions)
|
26
|
-
Skynet::Partitioners::ArrayDataSplitByFirstEntry.reduce_partition(post_map_data,new_partitions)
|
27
|
-
|
28
|
-
## I've included the contents of the above method so you can see how to write a reduce_partitioner
|
29
|
-
# partitions = []
|
30
|
-
# (0..new_partitions - 1).each { |i| partitions[i] = Array.new }
|
31
|
-
# keys_seen = {}
|
32
|
-
# post_map_data.each do |partition|
|
33
|
-
# partition.each do |array|
|
34
|
-
# next unless array.is_a?(Array) and array.size >= 2
|
35
|
-
# if array[0].kind_of?(Fixnum)
|
36
|
-
# key = array[0]
|
37
|
-
# else
|
38
|
-
# keys_seen[array[0]] ||= keys_seen.keys.size
|
39
|
-
# key = keys_seen[array[0]]
|
40
|
-
# end
|
41
|
-
# partitions[key % new_partitions] << array
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
# partitions
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
# Takes an array that looks like [ [word1, cnt], [word2,cnt], [word1, cnt] ]
|
49
|
-
# reduce also gets an array
|
50
|
-
def self.reduce(reduce_datas)
|
51
|
-
results = {}
|
52
|
-
reduce_datas.each do |reduce_data|
|
53
|
-
results[reduce_data[0]] ||= 0
|
54
|
-
results[reduce_data[0]] += reduce_data[1]
|
55
|
-
end
|
56
|
-
results
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class MapreduceTest
|
2
|
-
|
3
|
-
include SkynetDebugger
|
4
|
-
|
5
|
-
def self.run
|
6
|
-
job = Skynet::Job.new(
|
7
|
-
:mappers => 2,
|
8
|
-
:reducers => 1,
|
9
|
-
:map_reduce_class => self,
|
10
|
-
:map_data => [OpenStruct.new({:created_by => 2}),OpenStruct.new({:created_by => 2}),OpenStruct.new({:created_by => 3})]
|
11
|
-
)
|
12
|
-
results = job.run
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.map(profiles)
|
16
|
-
result = Array.new
|
17
|
-
profiles.each do |profile|
|
18
|
-
result << [profile.created_by, 1] if profile.created_by
|
19
|
-
end
|
20
|
-
result
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.reduce(pairs)
|
24
|
-
totals = Hash.new
|
25
|
-
pairs.each do |pair|
|
26
|
-
created_by, count = pair[0], pair[1]
|
27
|
-
totals[created_by] ||= 0
|
28
|
-
totals[created_by] += count
|
29
|
-
end
|
30
|
-
totals
|
31
|
-
end
|
32
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
class MostCommonWords
|
2
|
-
include SkynetDebugger
|
3
|
-
|
4
|
-
def self.map(map_datas)
|
5
|
-
results = Hash.new(0)
|
6
|
-
map_datas.each do |filename|
|
7
|
-
begin
|
8
|
-
File.open(filename).each_word do |word|
|
9
|
-
next if word.length <= 5
|
10
|
-
results[word.downcase] += 1
|
11
|
-
end
|
12
|
-
rescue Errno::EISDIR
|
13
|
-
# skip directories
|
14
|
-
end
|
15
|
-
end
|
16
|
-
## For efficiency. Not 100% accurate.
|
17
|
-
results.sort{|a,b| a[1]<=>b[1]}.reverse.first(100)
|
18
|
-
end
|
19
|
-
|
20
|
-
# The chosen reduce partiioner attempts group keys by partition. For example, if you choose 2 words and 2 reducers it will make sure
|
21
|
-
# the first word goes to the first reducer and the second word to the second reducer. If you only have 1 reducer (the defaukt)
|
22
|
-
# It doesn't bother partitioning. You can write as complex a partiioner as you'd like.
|
23
|
-
def self.reduce_partition(post_map_data,new_partitions)
|
24
|
-
Skynet::Partitioners::ArrayDataSplitByFirstEntry.reduce_partition(post_map_data,new_partitions)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Takes an array that looks like [ [word1, cnt], [word2,cnt], [word1, cnt] ]
|
28
|
-
# reduce also gets an array
|
29
|
-
def self.reduce(reduce_datas)
|
30
|
-
results = Hash.new(0)
|
31
|
-
reduce_datas.each do |reduce_data|
|
32
|
-
results[reduce_data[0]] += reduce_data[1]
|
33
|
-
end
|
34
|
-
results.sort{|a,b| a[1]<=>b[1]}.reverse.first(10).sort
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
class IO
|
40
|
-
def each_word(&b)
|
41
|
-
each do |line|
|
42
|
-
line.scan(/\w+/, &b)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/examples/dgrep/script/dgrep
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# USAGE:
|
3
|
-
#
|
4
|
-
# You can provide one or more words. The last argument is the directory.
|
5
|
-
#
|
6
|
-
# Eg:
|
7
|
-
#
|
8
|
-
# ruby ./script/dgrep [-r] word1 word2 word3 directory
|
9
|
-
#
|
10
|
-
# Passing -r means search recursively
|
11
|
-
#
|
12
|
-
# Most Common Words
|
13
|
-
# I've included a second demo in the form of:
|
14
|
-
# ruby ./script/dgrep -r -mcw directory
|
15
|
-
# This will return the top 10 most common 5 or more letter words
|
16
|
-
#
|
17
|
-
# You can also choose to distribute the reduce step by passing --reducers=2 (or any other number. 1 is the default)
|
18
|
-
|
19
|
-
require 'rubygems'
|
20
|
-
require 'rdoc/usage'
|
21
|
-
require 'skynet'
|
22
|
-
require File.dirname(__FILE__) + '/../config/skynet_config.rb'
|
23
|
-
|
24
|
-
puts "LOGGING TO #{Skynet.config.logfile_location}"
|
25
|
-
|
26
|
-
RDoc::usage if ARGV.empty? or ARGV.include?("--help")
|
27
|
-
|
28
|
-
reducers = 1
|
29
|
-
if reduce_arg = ARGV.detect {|i| i =~ /--reducers/ }
|
30
|
-
reducers = reduce_arg.split('=').last.to_i
|
31
|
-
ARGV.delete_if {|i| i =~ /--reducers/ }
|
32
|
-
end
|
33
|
-
|
34
|
-
user_dir = ARGV.pop
|
35
|
-
directory = File.expand_path(user_dir)
|
36
|
-
|
37
|
-
mcw = ARGV.delete('-mcw') ? true : false
|
38
|
-
|
39
|
-
files = if ARGV.delete('-r')
|
40
|
-
Dir["#{directory}/**/*"]
|
41
|
-
else
|
42
|
-
Dir["#{directory}/*"]
|
43
|
-
end
|
44
|
-
|
45
|
-
if files.empty?
|
46
|
-
puts "No files in #{user_dir}"
|
47
|
-
exit
|
48
|
-
end
|
49
|
-
|
50
|
-
words = ARGV
|
51
|
-
|
52
|
-
results = []
|
53
|
-
if mcw
|
54
|
-
puts "Looking for the most common words in #{user_dir}"
|
55
|
-
results = files.mapreduce(MostCommonWords, :reducers => reducers, :master_timeout => 60)
|
56
|
-
if results and results.any?
|
57
|
-
puts "RESULTS:"
|
58
|
-
results.sort_by{|a| a[1]}.reverse.each_with_index do |a,ii|
|
59
|
-
puts "#{ii}. #{a[1]} #{a[0]}"
|
60
|
-
end
|
61
|
-
else
|
62
|
-
puts "No results"
|
63
|
-
end
|
64
|
-
else
|
65
|
-
map_data = files.collect{|file| [file,words]}
|
66
|
-
puts "Looking at all the files in #{user_dir} for the word or words '#{words.join(',')}'"
|
67
|
-
results = map_data.mapreduce(Dgrep, :data_debug => true)
|
68
|
-
if results and results.any?
|
69
|
-
results.sort_by{|a| a[1]}.reverse.each_with_index do |a,ii|
|
70
|
-
puts "#{ii}. #{a[1]} #{a[0]}"
|
71
|
-
end
|
72
|
-
else
|
73
|
-
puts "No results"
|
74
|
-
end
|
75
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
========================
|
2
|
-
= Skynet Rails Example =
|
3
|
-
========================
|
4
|
-
|
5
|
-
Below you'll find a few example skynet uses within a rails application.
|
6
|
-
Rails itself is not included in the app so you will need Rails 2 installed locally.
|
7
|
-
You will also need to have mysql running locally. If you have special permissions, please edit config/database.yml.
|
8
|
-
|
9
|
-
SETUP
|
10
|
-
-------------------------------------
|
11
|
-
> rake db:create
|
12
|
-
> rake db:migrate
|
13
|
-
> rake db:initialize_defaults
|
14
|
-
|
15
|
-
|
16
|
-
EXAMPLE 1: Complex Migrations
|
17
|
-
-------------------------------------
|
18
|
-
Lets say we were storing the user's favorites in a single comma separated field in the users table, but want
|
19
|
-
to normalize it into a user_favorites table. This is something that would be difficult to do in straight SQL.
|
20
|
-
We have a method in our User model to migrate a single user. All we have to do is run it on every user.
|
21
|
-
|
22
|
-
I added a rake task to run the skynet migration
|
23
|
-
> rake db:migrate_favorites
|
24
|
-
|
25
|
-
You can also choose to run the command (or other commands) yourself in the skynet console
|
26
|
-
|
27
|
-
> ruby script/skynet console
|
28
|
-
console> User.distributed_find(:all).map(:migrate_favorites)
|
29
|
-
console> u = User.find(:first)
|
30
|
-
console> u.user_favorites.size
|
31
|
-
|
32
|
-
If you want to re-run the example, remember to run rake db:initialize_defaults again.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Example 2: Sending Email Asyncronously
|
37
|
-
-------------------------------------
|
38
|
-
> ruby script/skynet console
|
39
|
-
console> u = User.find(:first)
|
40
|
-
console> u.send_welcome_email
|
41
|
-
# pauses 5 seconds while the user goes to another site and never comes back We don't want that!
|
42
|
-
# try again
|
43
|
-
console> u.send_later(:send_welcome_email)
|
44
|
-
# returns immediately, but sends the email after 5 seconds anyway
|
45
|
-
|
46
|
-
This sample application was created by creating in the following way
|
47
|
-
|
48
|
-
1. Create new rails app
|
49
|
-
> rails -d mysql rails_mysql_example
|
50
|
-
|
51
|
-
2. Install Skynet with rails and mysql support
|
52
|
-
> skynet_install --rails --mysql
|
53
|
-
|
54
|
-
3. Run skynet migrations
|
55
|
-
> rake db:migrate
|
56
|
-
|
57
|
-
4. Create other migrations models
|
58
|
-
> ./script/generate model user name:string password:string favorites:string email:string
|
59
|
-
> ./script/generate model user_favorite user_id:integer favorite:string
|
60
|
-
|
61
|
-
------------------------------------------------------
|
62
|
-
If you'd like get a peak at what Skynet is doing, edit ./script/skynet and set
|
63
|
-
|
64
|
-
Skynet::CONFIG[:SKYNET_LOG_LEVEL] = Logger::INFO # or Logger::INFO
|
65
|
-
|
66
|
-
and tail ./log/skynet_development.log
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
-
|
4
|
-
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
-
|
6
|
-
require 'rake'
|
7
|
-
require 'rake/testtask'
|
8
|
-
require 'rake/rdoctask'
|
9
|
-
|
10
|
-
require 'tasks/rails'
|
@@ -1,10 +0,0 @@
|
|
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
|
-
|
7
|
-
# See ActionController::RequestForgeryProtection for details
|
8
|
-
# Uncomment the :secret if you're not using the cookie session store
|
9
|
-
protect_from_forgery # :secret => '8a54ccda625a3eeb4b2746aaaa094406'
|
10
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class User < ActiveRecord::Base
|
2
|
-
|
3
|
-
has_many :user_favorites, :dependent => :destroy
|
4
|
-
|
5
|
-
# Moves comma seperated column into seperate relationship table
|
6
|
-
def migrate_favorites
|
7
|
-
return unless self.favorites
|
8
|
-
self.favorites.split(",").each do |favorite|
|
9
|
-
self.user_favorites.create(:favorite => favorite)
|
10
|
-
end
|
11
|
-
self.favorites = nil
|
12
|
-
self.save
|
13
|
-
end
|
14
|
-
|
15
|
-
# Slow running welcome email sender
|
16
|
-
def send_welcome_email
|
17
|
-
sleep 5
|
18
|
-
UserMailer.deliver_welcome(self)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class UserMailer < ActionMailer::Base
|
2
|
-
class Error < StandardError; end
|
3
|
-
|
4
|
-
def welcome(user)
|
5
|
-
@recipients = "#{user.email}"
|
6
|
-
@from = "Mycompany <root@localhost>"
|
7
|
-
@sent_on = Time.now
|
8
|
-
@subject = 'Your account has been activated!'
|
9
|
-
@body[:url] = "http://localhost:3000/"
|
10
|
-
@body[:user] = user
|
11
|
-
end
|
12
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# Don't change this file!
|
2
|
-
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
-
|
4
|
-
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
class << self
|
8
|
-
def boot!
|
9
|
-
unless booted?
|
10
|
-
preinitialize
|
11
|
-
pick_boot.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def booted?
|
16
|
-
defined? Rails::Initializer
|
17
|
-
end
|
18
|
-
|
19
|
-
def pick_boot
|
20
|
-
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
-
end
|
22
|
-
|
23
|
-
def vendor_rails?
|
24
|
-
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
-
end
|
26
|
-
|
27
|
-
# FIXME : Ruby 1.9
|
28
|
-
def preinitialize
|
29
|
-
load(preinitializer_path) if File.exists?(preinitializer_path)
|
30
|
-
end
|
31
|
-
|
32
|
-
def preinitializer_path
|
33
|
-
"#{RAILS_ROOT}/config/preinitializer.rb"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class Boot
|
38
|
-
def run
|
39
|
-
load_initializer
|
40
|
-
Rails::Initializer.run(:set_load_path)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class VendorBoot < Boot
|
45
|
-
def load_initializer
|
46
|
-
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class GemBoot < Boot
|
51
|
-
def load_initializer
|
52
|
-
self.class.load_rubygems
|
53
|
-
load_rails_gem
|
54
|
-
require 'initializer'
|
55
|
-
end
|
56
|
-
|
57
|
-
def load_rails_gem
|
58
|
-
if version = self.class.gem_version
|
59
|
-
gem 'rails', version
|
60
|
-
else
|
61
|
-
gem 'rails'
|
62
|
-
end
|
63
|
-
rescue Gem::LoadError => load_error
|
64
|
-
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
65
|
-
exit 1
|
66
|
-
end
|
67
|
-
|
68
|
-
class << self
|
69
|
-
def rubygems_version
|
70
|
-
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
|
71
|
-
end
|
72
|
-
|
73
|
-
def gem_version
|
74
|
-
if defined? RAILS_GEM_VERSION
|
75
|
-
RAILS_GEM_VERSION
|
76
|
-
elsif ENV.include?('RAILS_GEM_VERSION')
|
77
|
-
ENV['RAILS_GEM_VERSION']
|
78
|
-
else
|
79
|
-
parse_gem_version(read_environment_rb)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def load_rubygems
|
84
|
-
require 'rubygems'
|
85
|
-
|
86
|
-
unless rubygems_version >= '0.9.4'
|
87
|
-
$stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
-
exit 1
|
89
|
-
end
|
90
|
-
|
91
|
-
rescue LoadError
|
92
|
-
$stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
93
|
-
exit 1
|
94
|
-
end
|
95
|
-
|
96
|
-
def parse_gem_version(text)
|
97
|
-
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
98
|
-
end
|
99
|
-
|
100
|
-
private
|
101
|
-
def read_environment_rb
|
102
|
-
File.read("#{RAILS_ROOT}/config/environment.rb")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# All that for this:
|
109
|
-
Rails.boot!
|