daps 0.0.1.a.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 Simon Menke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ daps(7) -- semi automatic deployment of rails applications
2
+ ===============================================================
3
+
4
+ ## INSTALL
5
+
6
+ Install with Rubygems:
7
+
8
+ $ [sudo] gem install daps
9
+ $ dapsd
data/bin/daps ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'daps'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ $:.unshift(File.expand_path('../../lib', __FILE__))
8
+ require 'daps'
9
+ end
10
+
11
+ Daps::Application.start
@@ -0,0 +1,26 @@
1
+ class Daps::Application < Thor
2
+
3
+ desc "server DIR [TOKEN]", "Start the daps server"
4
+ method_option :port, :type => :numeric, :default => 5001
5
+ def server(dir, token=nil)
6
+ token ||= Digest::SHA1.hexdigest([Time.now, rand(1<<100)].join('--'))
7
+ puts "Token: #{token}"
8
+ server = Daps::Server.new(dir, token, options.port)
9
+ server.start!
10
+ end
11
+
12
+ desc "pull REMOTE DIR", "Pull file from a remote"
13
+ def pull(remote, dir)
14
+ remote = remote.sub(/^http[s]?[:]\/\//, 'daps://')
15
+ remote = "daps://#{remote}" unless remote[0,7] == 'daps://'
16
+ remote = URI.parse(remote)
17
+
18
+ port = remote.port || 5001
19
+ token = File.basename(remote.path)
20
+ remote = remote.host
21
+
22
+ client = Daps::Client.new(dir, remote, token, port)
23
+ client.start!
24
+ end
25
+
26
+ end
@@ -0,0 +1,15 @@
1
+ class Daps::Client
2
+
3
+ def initialize(dir, remote, token, port)
4
+ @dir, @remote, @token, @port = File.expand_path(dir), remote, token, port
5
+ end
6
+
7
+ def start!
8
+ system(%{
9
+ wget -O /tmp/daps-#{@token}-client.tar.gz http://#{@remote}:#{@port}/#{@token} &&
10
+ tar --directory=#{@dir} -xzf /tmp/daps-#{@token}-client.tar.gz ;
11
+ rm -f /tmp/daps-#{@token}-client.tar.gz
12
+ })
13
+ end
14
+
15
+ end
@@ -0,0 +1,50 @@
1
+ class Daps::Server
2
+
3
+ def initialize(dir, token, port)
4
+ @dir, @token, @port = File.expand_path(dir), token, port.to_i
5
+ Dir.chdir(@dir)
6
+ end
7
+
8
+ def start!
9
+ Rack::Handler::Thin.run self, :Port => @port
10
+ end
11
+
12
+ def call(env)
13
+ env['daps.token'] = @token
14
+ env['daps.dir'] = @dir
15
+ Http.call(env)
16
+ end
17
+
18
+ class Http < Sinatra::Base
19
+
20
+ get '/:token' do
21
+ token = params[:token]
22
+ if @env['daps.token'] != token
23
+ halt(403, {'Content-type' => 'text/plain'}, 'back off!')
24
+ end
25
+
26
+ puts "Compressing files..."
27
+ system(%{
28
+ cd #{@env['daps.dir']} ;
29
+ tar -czf /tmp/daps-#{token}-server.tar.gz . ;
30
+ })
31
+
32
+ puts "Transfering archive..."
33
+ send_file "/tmp/daps-#{token}-server.tar.gz"
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ class Sinatra::Helpers::StaticFile < ::File
41
+ alias_method :other_each, :each
42
+ def each(&block)
43
+ other_each(&block)
44
+ ensure
45
+ EM.next_tick do
46
+ File.unlink(self.path)
47
+ EM.stop_event_loop
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module Daps
2
+ VERSION = '0.0.1.a.2'
3
+ end
data/lib/daps.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Daps
2
+
3
+ require 'uri'
4
+ require 'digest/sha1'
5
+ require 'thor'
6
+ require 'sinatra'
7
+
8
+ require 'daps/version'
9
+ require 'daps/application'
10
+ require 'daps/server'
11
+ require 'daps/client'
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daps
3
+ version: !ruby/object:Gem::Version
4
+ hash: 121
5
+ prerelease: true
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ - a
11
+ - 2
12
+ version: 0.0.1.a.2
13
+ platform: ruby
14
+ authors:
15
+ - Simon Menke
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-06-15 00:00:00 +02:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: eventmachine
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - "="
30
+ - !ruby/object:Gem::Version
31
+ hash: 59
32
+ segments:
33
+ - 0
34
+ - 12
35
+ - 10
36
+ version: 0.12.10
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: thor
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - "="
46
+ - !ruby/object:Gem::Version
47
+ hash: 39
48
+ segments:
49
+ - 0
50
+ - 13
51
+ - 6
52
+ version: 0.13.6
53
+ type: :runtime
54
+ version_requirements: *id002
55
+ description: Ad hoc rsync server.
56
+ email:
57
+ - simon.menke@gmail.com
58
+ executables:
59
+ - daps
60
+ extensions: []
61
+
62
+ extra_rdoc_files: []
63
+
64
+ files:
65
+ - lib/daps/application.rb
66
+ - lib/daps/client.rb
67
+ - lib/daps/server.rb
68
+ - lib/daps/version.rb
69
+ - lib/daps.rb
70
+ - LICENSE
71
+ - README.md
72
+ - bin/daps
73
+ has_rdoc: true
74
+ homepage: http://github.com/fd/daps
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 23
97
+ segments:
98
+ - 1
99
+ - 3
100
+ - 6
101
+ version: 1.3.6
102
+ requirements: []
103
+
104
+ rubyforge_project: daps
105
+ rubygems_version: 1.3.7
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Ad hoc rsync server
109
+ test_files: []
110
+