WatersOfOblivion-burn 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README +21 -0
- data/Rakefile +22 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/app/controllers/burn/burn_controller.rb +34 -0
- data/lib/app/models/burn/crash.rb +5 -0
- data/lib/burn.rb +5 -0
- data/lib/initializer.rb +51 -0
- data/lib/routing_extension.rb +23 -0
- data/rails/init.rb +14 -0
- data/test/burn_test.rb +8 -0
- data/uninstall.rb +1 -0
- metadata +76 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [name of plugin creator]
|
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.
|
data/README
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
=Burn
|
2
|
+
|
3
|
+
Burn is a plugin for simplifying backups with the Crash backup server.
|
4
|
+
|
5
|
+
==Dependencies
|
6
|
+
|
7
|
+
This relies on the FootPedal[http://watersofoblivion.github.com/footpedal/] and
|
8
|
+
ActiveResourceInstanceAuthentication[http://watersofoblivion.github.com/activeresourceinstanceauthentication/]
|
9
|
+
plugins.
|
10
|
+
|
11
|
+
==Gem
|
12
|
+
|
13
|
+
This plugin is available as a Gem. Add the following line to
|
14
|
+
<tt>config/environment.rb</tt> and run <tt>rake gems:install</tt>.
|
15
|
+
|
16
|
+
config.gem "WatersOfOblivion-burn", :lib => "burn", :source => "http://gems.github.com/"
|
17
|
+
|
18
|
+
This will also install the required dependencies if you have
|
19
|
+
<tt>http://gems.github.com/</tt> as a source.
|
20
|
+
|
21
|
+
Copyright (c) 2009 Jonathan Bryant, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the burn plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the burn plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'Burn'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Burn
|
2
|
+
# A simple controller which allows for backups and restores.
|
3
|
+
#
|
4
|
+
# - <tt>GET /burn/backup</tt> gets the latest backup
|
5
|
+
# - <tt>POST /burn/restore</tt> restores to the backup posted as
|
6
|
+
# <tt>params[:backup][:data]</tt>
|
7
|
+
class BurnController < ActionController::Base
|
8
|
+
# Gets the latest backup
|
9
|
+
def backup
|
10
|
+
respond_to do |format|
|
11
|
+
format.html { send_data build_backup }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Restores from a backup
|
16
|
+
def restore
|
17
|
+
load_backup params[:backup][:data].read
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html { head :ok }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This method is overridden by the initializer +build_backup+ method
|
25
|
+
def build_backup
|
26
|
+
end
|
27
|
+
|
28
|
+
# This method is overridden by the initializer +load_backup+ method
|
29
|
+
def load_backup data
|
30
|
+
end
|
31
|
+
|
32
|
+
private :build_backup, :load_backup
|
33
|
+
end
|
34
|
+
end
|
data/lib/burn.rb
ADDED
data/lib/initializer.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Burn
|
2
|
+
# An initializer to be placed in the <tt>config/initializers</tt> directory.
|
3
|
+
# This should be used like <tt>Rails::Initializer</tt>.
|
4
|
+
#
|
5
|
+
# Burn::Initializer.run do |config|
|
6
|
+
# config.crash_server = "http://my.crash.server:1234/"
|
7
|
+
#
|
8
|
+
# # Etc.
|
9
|
+
# end
|
10
|
+
class Initializer
|
11
|
+
# Yields a new initializer to the block
|
12
|
+
def self.run
|
13
|
+
yield new if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
# Sets the default backup server
|
17
|
+
def crash_server= crash_server
|
18
|
+
Burn::Crash.site = crash_server
|
19
|
+
end
|
20
|
+
|
21
|
+
# This takes a block which creates the backup. The block should return the
|
22
|
+
# raw backup data. If the backup creates a tarball, then this method should
|
23
|
+
# return the contents of that tarball.
|
24
|
+
#
|
25
|
+
# # A not terribly effective backup
|
26
|
+
# config.build_backup do
|
27
|
+
# ToplevelModel.find(1).to_xml
|
28
|
+
# end
|
29
|
+
def build_backup &block
|
30
|
+
Burn::BurnController.class_eval do
|
31
|
+
remove_method :build_backup
|
32
|
+
define_method :build_backup, &block
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# This takes a block which restores from the backup. The block will receive
|
37
|
+
# the raw backup data. If the backup created a tarball, then this method
|
38
|
+
# will receive the contents of that tarball.
|
39
|
+
#
|
40
|
+
# # A not terribly effective restore
|
41
|
+
# config.load_backup do |data|
|
42
|
+
# ToplevelModel.new.from_xml(data).save
|
43
|
+
# end
|
44
|
+
def load_backup &block
|
45
|
+
Burn::BurnController.class_eval do
|
46
|
+
remove_method :load_backup
|
47
|
+
define_method :load_backup, &block
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Burn
|
2
|
+
# Adds two simple routes for fetching backups and restoring from backups
|
3
|
+
#
|
4
|
+
# ActionController::Routing::Routes.draw do |map|
|
5
|
+
# map.burn_backup # Creates the backup route 'GET /burn/backup'
|
6
|
+
# map.burn_restore # Creates the restore route 'POST /burn/restore'
|
7
|
+
# map.burn # Creates both of the above routes
|
8
|
+
# end
|
9
|
+
module RoutingExtension
|
10
|
+
def burn_backup
|
11
|
+
@set.add_route '/burn/backup', :controller => 'burn/burn', :action => "backup", :method => :get
|
12
|
+
end
|
13
|
+
|
14
|
+
def burn_restore
|
15
|
+
@set.add_route '/burn/restore', :controller => 'burn/burn', :action => "restore", :method => :post
|
16
|
+
end
|
17
|
+
|
18
|
+
def burn
|
19
|
+
burn_backup
|
20
|
+
burn_restore
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/rails/init.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Load the model and controller
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'burn')
|
3
|
+
require File.join('burn', 'crash')
|
4
|
+
require File.join('burn', 'burn_controller')
|
5
|
+
|
6
|
+
# Load the routing extension
|
7
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'routing_extension')
|
8
|
+
ActionController::Routing::RouteSet::Mapper.send :include, Burn::RoutingExtension
|
9
|
+
ActionController::Routing::Routes.draw do |map|
|
10
|
+
map.burn
|
11
|
+
end
|
12
|
+
|
13
|
+
# Load the initializer
|
14
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'initializer')
|
data/test/burn_test.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: WatersOfOblivion-burn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Bryant
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-05 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: WatersOfOblivion-footpedal
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: ""
|
25
|
+
email: watersofmemory@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
files:
|
33
|
+
- init.rb
|
34
|
+
- install.rb
|
35
|
+
- MIT-LICENSE
|
36
|
+
- Rakefile
|
37
|
+
- README
|
38
|
+
- uninstall.rb
|
39
|
+
- rails/init.rb
|
40
|
+
- test/burn_test.rb
|
41
|
+
- lib/burn.rb
|
42
|
+
- lib/initializer.rb
|
43
|
+
- lib/routing_extension.rb
|
44
|
+
- lib/app/models/burn/crash.rb
|
45
|
+
- lib/app/controllers/burn/burn_controller.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://watersofoblivion.github.com/burn/
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --title
|
51
|
+
- Burn
|
52
|
+
- --line-numbers
|
53
|
+
- --inline-source
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.2.0
|
72
|
+
signing_key:
|
73
|
+
specification_version: 2
|
74
|
+
summary: A Rails plugin for backups using the Crash backup server
|
75
|
+
test_files:
|
76
|
+
- test/burn_test.rb
|