dtask 001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/.gemified +11 -0
  2. data/History.txt +4 -0
  3. data/License.txt +56 -0
  4. data/README.txt +19 -0
  5. data/bin/dtask +22 -0
  6. data/lib/dtask.rb +98 -0
  7. metadata +66 -0
data/.gemified ADDED
@@ -0,0 +1,11 @@
1
+ ---
2
+ :summary: DTask provides easy way to deploy web application.
3
+ :email: keita.yamaguchi@gmail.com
4
+ :has_rdoc: true
5
+ :name: dtask
6
+ :homepage: http://rubyforge.org/projects/dtask/
7
+ :version: "001"
8
+ :dependencies:
9
+ - net-ssh
10
+ :rubyforge_project: dtask
11
+ :author: Keita Yamaguchi
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 001: 2008-04-21
2
+
3
+ * Keita Yamaguchi:
4
+ * first release
data/License.txt ADDED
@@ -0,0 +1,56 @@
1
+ DTask is copyrighted free software by Keita Yamaguchi <keita.yamaguchi@gmail.com>.
2
+ You can redistribute it and/or modify it under either the terms of the GPL
3
+ (see the file GPL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a) distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.txt ADDED
@@ -0,0 +1,19 @@
1
+ = DTask
2
+
3
+ Author:: Keita Yamaguchi(山口 慶太) <keita.yamaguchi@gmail.com>
4
+ Copyright:: © Keita Yamaguchi, 2008. All rights reserved.
5
+ License:: Ruby License
6
+
7
+ RTask provides easy way to release Ruby’s gem packages. This also provides useful Rake tasks for releasing packages and uploading documents.
8
+
9
+ == Usage
10
+
11
+ See {the document}[http://github.com/keita/dtask/wikis] for details.
12
+
13
+ == Links
14
+
15
+ * DTask
16
+ * {RubyForge}[http://rubyforge.org/projects/dtask/]
17
+ * {GitHub}[http://github.com/keita/dtask/tree/master]
18
+ * author's blog(written in Japanese)
19
+ * {¬¬日常日記}[http://d.hatena.ne.jp/keita_yamaguchi/]
data/bin/dtask ADDED
@@ -0,0 +1,22 @@
1
+ require "rubygems"
2
+ require "dtask"
3
+ require "optparse"
4
+
5
+ Option = OptionParser.new do |opt|
6
+ opt.on("--help") do
7
+ puts opt.help
8
+ end
9
+
10
+ opt.parse!(ARGV)
11
+ end
12
+
13
+ name, task = ARGV
14
+
15
+ if name
16
+ DTask.new(name).run(task.to_sym)
17
+ else
18
+ puts "dtask list:"
19
+ Dir.glob(File.expand_path("~/.dtask/*.dtask")) do |path|
20
+ puts " * " + File.basename(path, ".dtask")
21
+ end
22
+ end
data/lib/dtask.rb ADDED
@@ -0,0 +1,98 @@
1
+ require "net/ssh"
2
+ require "singleton"
3
+
4
+ class DTask
5
+ VERSION = "001"
6
+
7
+ class Error < StandardError; end
8
+
9
+ class Config
10
+ include Singleton
11
+
12
+ def initialize; @table = Hash.new; end
13
+ def o(table); table.each {|key, val| @table[key] = val }; end
14
+
15
+ class << self
16
+ def method_missing(name, *args)
17
+ if md = /(.+)=$/.match(name.to_s)
18
+ instance.instance_eval { @table[name] = args.first }
19
+ else
20
+ instance.instance_eval { @table[name] }
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ class Remote
27
+ attr_reader :out
28
+ attr_reader :err
29
+
30
+ def initialize
31
+ options = {
32
+ :username => Config.user,
33
+ :auth_methods => "publickey"
34
+ }
35
+ @session = Net::SSH.start(Config.server, options)
36
+ @shell = @session.shell.sync
37
+ @out = []
38
+ @err = []
39
+ end
40
+
41
+ def pout(msg)
42
+ puts "OUT> #{msg}"
43
+ end
44
+
45
+ def perr(msg)
46
+ puts "ERR> #{msg}"
47
+ end
48
+
49
+ def l(cmd)
50
+ cmd.kind_of?(Symbol) ? DTask.run(cmd) : sh(cmd)
51
+ end
52
+
53
+ def l!(cmd)
54
+ begin l(cmd) rescue Error end
55
+ end
56
+
57
+ def sh(cmd)
58
+ puts "% #{cmd}"
59
+ res = @shell.send_command(cmd)
60
+ pout res.stdout if res.stdout and res.stdout.size > 0
61
+ perr res.stderr if res.stderr and res.stderr.size > 0
62
+ @out << res.stdout
63
+ @err << res.stderr
64
+ res.status == 0 ? res.stdout : raise Error
65
+ end
66
+
67
+ def cd_appdir
68
+ l "cd #{Config.appdir} && pwd"
69
+ end
70
+ end
71
+
72
+ TASK = Hash.new
73
+
74
+ def initialize(name)
75
+ load File.expand_path("~/.dtask/#{name}.dtask")
76
+ @remote = Remote.new
77
+ end
78
+
79
+ def run(task)
80
+ if TASK.key?(task)
81
+ puts "#{Config.server} >>> #{task}"
82
+ @remote.cd_appdir
83
+ @remote.instance_eval &TASK[task]
84
+ else
85
+ puts "No such task: #{task}"
86
+ end
87
+ end
88
+ end
89
+
90
+ module Kernel
91
+ def task(name, &block)
92
+ DTask::TASK[name] = block
93
+ end
94
+
95
+ def setup(&block)
96
+ DTask::Config.instance.instance_eval(&block)
97
+ end
98
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dtask
3
+ version: !ruby/object:Gem::Version
4
+ version: "001"
5
+ platform: ruby
6
+ authors:
7
+ - Keita Yamaguchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-21 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: net-ssh
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: keita.yamaguchi@gmail.com
26
+ executables:
27
+ - dtask
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - .gemified
34
+ - History.txt
35
+ - License.txt
36
+ - README.txt
37
+ - bin/dtask
38
+ - lib/dtask.rb
39
+ has_rdoc: true
40
+ homepage: http://rubyforge.org/projects/dtask/
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project: dtask
61
+ rubygems_version: 1.1.1
62
+ signing_key:
63
+ specification_version: 2
64
+ summary: DTask provides easy way to deploy web application.
65
+ test_files: []
66
+