lu-tze 0.1.0

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.
Files changed (4) hide show
  1. data/LICENCE +20 -0
  2. data/README.textile +15 -0
  3. data/lib/lu_tze.rb +57 -0
  4. metadata +130 -0
data/LICENCE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Pat Allan
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,15 @@
1
+ h1. Lu-Tze
2
+
3
+ h2. Note on Patches/Pull Requests
4
+
5
+ The process is (ideally):
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so things don't break in future versions.
10
+ * When committing, please don't mess with Rakefile or VERSION file. Unless, of course, you want your own version, but it'd be nice if you keep custom changes in a branch to be easily merged in.
11
+ * Send a pull request. Bonus points for topic branches.
12
+
13
+ h2. Copyright
14
+
15
+ Copyright (c) 2010 Pat Allan, released under an MIT licence.
@@ -0,0 +1,57 @@
1
+ require 'rest_client'
2
+
3
+ class LuTze
4
+ attr_accessor :app_name
5
+
6
+ def self.gather_and_send(app_name)
7
+ LuTze.new(app_name).upload
8
+ end
9
+
10
+ def initialize(app_name)
11
+ @app_name = app_name
12
+ save && compress
13
+ end
14
+
15
+ def save
16
+ system dump_command
17
+ end
18
+
19
+ def compress
20
+ system compress_command
21
+ end
22
+
23
+ def upload
24
+ file = File.new(compressed_file_name, 'rw')
25
+ RestClient.post 'http://historian.heroku.com/api/data_backups',
26
+ :site_name => app_name,
27
+ :backup => file
28
+ end
29
+
30
+ private
31
+
32
+ def config
33
+ @config ||= ActiveRecord::Base.connection.instance_variable_get(:@config)
34
+ end
35
+
36
+ def dump_command
37
+ cmd = ""
38
+ cmd += "echo #{config[:password]} | " if config[:password].present?
39
+ cmd += "pg_dump --format=p --file=#{file_name}"
40
+ cmd += " --host=#{config[:host]}" if config[:host].present?
41
+ cmd += " --port=#{config[:port]}" if config[:port].present?
42
+ cmd += " --username=#{config[:username]}" if config[:username].present?
43
+ cmd += " #{config[:database]}"
44
+ end
45
+
46
+ def compress_command
47
+ "tar -czvf #{compressed_file_name} #{file_name}"
48
+ end
49
+
50
+ def file_name
51
+ "#{RAILS_ROOT}/tmp/database.sql"
52
+ end
53
+
54
+ def compressed_file_name
55
+ "#{RAILS_ROOT}/tmp/database.tar.gz"
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lu-tze
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
+ - Pat Allan
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-27 00:00:00 +10:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activerecord
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 2
32
+ - 3
33
+ - 5
34
+ version: 2.3.5
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rest-client
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 1
48
+ - 4
49
+ - 2
50
+ version: 1.4.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 27
62
+ segments:
63
+ - 1
64
+ - 3
65
+ - 0
66
+ version: 1.3.0
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ prerelease: false
72
+ requirement: &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
+ type: :development
82
+ version_requirements: *id004
83
+ description: ""
84
+ email: pat@freelancing-gods.com
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files:
90
+ - README.textile
91
+ files:
92
+ - LICENCE
93
+ - README.textile
94
+ - lib/lu_tze.rb
95
+ has_rdoc: true
96
+ homepage: http://github.com/freelancing-god/lu-tze
97
+ licenses: []
98
+
99
+ post_install_message:
100
+ rdoc_options:
101
+ - --charset=UTF-8
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirements: []
123
+
124
+ rubyforge_project:
125
+ rubygems_version: 1.3.7
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: Sends backups to Historian
129
+ test_files: []
130
+