phper 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'highline', '> 1.6'
8
8
  gem 'command-line-utils' , '>= 0.0.1'
9
9
  gem 'launchy'
10
10
  gem 'json'
11
+ gem 'rdoc'
11
12
 
12
13
  # Add dependencies to develop your gem here.
13
14
  # Include everything needed to run rake, tests, features, etc.
@@ -16,4 +17,5 @@ group :development do
16
17
  gem "bundler", "~> 1.0.0"
17
18
  gem "jeweler", "~> 1.5.2"
18
19
  gem "rcov", ">= 0"
20
+ gem 'mocha'
19
21
  end
data/Rakefile CHANGED
@@ -38,12 +38,14 @@ Rcov::RcovTask.new do |test|
38
38
  test.libs << 'test'
39
39
  test.pattern = 'test/**/test_*.rb'
40
40
  test.verbose = true
41
+ test.rcov_opts << '-x /usr -x .rvm -x rvm -x vendor'
41
42
  end
42
43
 
43
44
  task :default => :test
44
45
 
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
46
+ require 'rdoc/task'
47
+
48
+ RDoc::Task.new do |rdoc|
47
49
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
50
 
49
51
  rdoc.rdoc_dir = 'rdoc'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.4
1
+ 0.6.0
data/bin/phper CHANGED
@@ -4,85 +4,3 @@ $:.unshift(File.join(File.dirname(__FILE__),'..','lib'))
4
4
  require 'phper'
5
5
  Phper::CLI::run(ARGV)
6
6
  exit
7
-
8
-
9
- def urlroot
10
- "http://tumf:hogehoge@localhost:3000"
11
- end
12
-
13
- def url res
14
- format = "json"
15
- urlroot + res + "." + format
16
- end
17
-
18
- # RestClient.get(url("/projects"))
19
- # puts RestClient.post url("/projects"),:project => {:name => "fuga6"}
20
- # puts RestClient.delete url("/projects/tumf-fuga6")
21
-
22
-
23
-
24
-
25
-
26
-
27
- =begin
28
-
29
- phper register
30
-
31
- $ phper login [<username>]
32
-
33
- $ phper logout
34
-
35
- $ phper keys
36
- $ phper keys:add <file>
37
- $ phper keys:remove <name>
38
- $ phper keys:clear
39
-
40
- == git リポジトリを作る
41
-
42
- $ phper create <project>
43
- --> gitosis@git.phper.jp:<user>/<project>.git
44
-
45
- == coding
46
-
47
- $ git clone gitosis@git.phper.jp:tumf/<project>.git
48
-
49
- == deploy
50
-
51
- $ git push phper master
52
-
53
- * hostが未割り当てならhostを割り当て
54
- * hostにデプロイ
55
- --> /var/phper/project
56
- --> cap
57
-
58
- == server
59
-
60
- $ phper server [<docroot>] [--port=<port>] []
61
-
62
-
63
- * <docroot>をドキュメントルートにしてサーバを構築
64
- --> /var/phper/project/<docroot>
65
-
66
- $ phper server [<docroot>] [--name=<fqdn>]
67
-
68
- * proxyの`/etc/hosts`を更新
69
- * proxyのnginx設定を更新
70
- * Apache VirtualHostを設定
71
- * nameが指定されていなかったら適当に決められる
72
-
73
- == サーバの設定
74
-
75
- $ phper server:config
76
- $ phper server:config:add
77
- $ phper server:config:clear
78
-
79
-
80
-
81
- == メンテナンス
82
-
83
- $ phper server:maintenance <on|off>
84
-
85
- $ phper server:stop
86
- $ phper server:start
87
- $ phper server:restart
88
- =end
data/lib/phper/agent.rb CHANGED
@@ -49,6 +49,14 @@ class Phper::Agent
49
49
  get("/keys")
50
50
  end
51
51
 
52
+ def logs project, server
53
+ get("/projects/%s/servers/%s/logs" % [project,server["server"]["id"]])
54
+ end
55
+
56
+ def logs_tail project,server,name
57
+ get("/projects/%s/servers/%s/logs/%s" %
58
+ [project,server["server"]["id"],name])
59
+ end
52
60
 
53
61
  def projects_deploy project
54
62
  get("/projects/%s/deploy" % project)
data/lib/phper/cli.rb CHANGED
@@ -3,8 +3,10 @@
3
3
  require 'phper'
4
4
  class Phper::CLI < CommandLineUtils::CLI
5
5
  include Phper
6
+ attr_accessor :out
6
7
  def initialize
7
8
  super
9
+ @out=STDOUT
8
10
  @commands = Commands.new
9
11
  yield self if block_given?
10
12
  end
@@ -15,7 +17,7 @@ class Phper::CLI < CommandLineUtils::CLI
15
17
  def version
16
18
  File.open(File.join(File.dirname(__FILE__) ,
17
19
  "..","..","VERSION"),"r") { |file|
18
- puts file.gets
20
+ @out.puts file.gets
19
21
  }
20
22
  end
21
23
  end
@@ -17,6 +17,7 @@ class Phper::Commands < CommandLineUtils::Commands
17
17
  @commands += ["hosts"]
18
18
  @commands += ["files","files:dump","files:get"]
19
19
  @commands += ["files:modified","files:modified:get"]
20
+ @commands += ["logs","logs:tail"]
20
21
 
21
22
  @agent = Agent.new
22
23
  # @cache_file = homedir + "/.phper.cache"
@@ -591,5 +592,66 @@ EOF
591
592
  end
592
593
  end
593
594
 
595
+ def logs
596
+ project = nil
597
+ server = nil
598
+ OptionParser.new { |opt|
599
+ opt.on('-s SERVER','--server=SERVER', 'server') { |v|
600
+ server = v
601
+ }
602
+ @summery = "list logs"
603
+ @banner = ""
604
+ project = extract_project(opt)
605
+ return opt if @help
606
+ }
607
+
608
+ raise "project is not specified." unless project
609
+ start
610
+ servers = @agent.servers(project)
611
+ raise "project #{project} has no servers." if servers.length == 0
612
+
613
+ if server
614
+ servers.find { |s| s["server"]["name"] =~ /^#{server}/ }
615
+ else
616
+ server = servers.first if servers.length == 1
617
+ end
618
+ raise "server is not specified." unless server
619
+
620
+ puts "-----> #{server['server']['name']}"
621
+ @agent.logs(project,server).each { |log|
622
+ puts log
623
+ }
624
+ end
625
+
626
+ def logs_tail
627
+ project = nil
628
+ server = nil
629
+ OptionParser.new { |opt|
630
+ opt.on('-s SERVER','--server=SERVER', 'server') { |v|
631
+ server = v
632
+ }
633
+ @summery = "list logs"
634
+ @banner = ""
635
+ project = extract_project(opt)
636
+ return opt if @help
637
+ }
638
+
639
+ raise "project is not specified." unless project
640
+ start
641
+ servers = @agent.servers(project)
642
+ raise "project #{project} has no servers." if servers.length == 0
643
+
644
+ if server
645
+ servers.find { |s| s["server"]["name"] =~ /^#{server}/ }
646
+ else
647
+ server = servers.first if servers.length == 1
648
+ end
649
+ raise "server is not specified." unless server
650
+ name = @command_options.shift
651
+ name ||= "access"
652
+
653
+ puts "-----> #{server['server']['name']}"
654
+ puts @agent.logs_tail(project,server,name)["log"]
655
+ end
594
656
 
595
657
  end
data/phper.gemspec CHANGED
@@ -5,22 +5,21 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{phper}
8
- s.version = "0.5.4"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Yoshihiro TAKAHARA"]
12
- s.date = %q{2011-03-01}
13
- s.default_executable = %q{phper}
11
+ s.authors = [%q{Yoshihiro TAKAHARA}]
12
+ s.date = %q{2011-10-15}
14
13
  s.description = %q{phper}
15
14
  s.email = %q{y.takahara@gmail.com}
16
- s.executables = ["phper"]
15
+ s.executables = [%q{phper}]
17
16
  s.extra_rdoc_files = [
18
17
  "LICENSE.txt",
19
18
  "README.md"
20
19
  ]
21
20
  s.files = [
21
+ ".document",
22
22
  "Gemfile",
23
- "Gemfile.lock",
24
23
  "LICENSE.txt",
25
24
  "README.md",
26
25
  "Rakefile",
@@ -35,9 +34,9 @@ Gem::Specification.new do |s|
35
34
  "test/test_phper.rb"
36
35
  ]
37
36
  s.homepage = %q{http://github.com/tumf/phper}
38
- s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.5.0}
37
+ s.licenses = [%q{MIT}]
38
+ s.require_paths = [%q{lib}]
39
+ s.rubygems_version = %q{1.8.6}
41
40
  s.summary = %q{phper}
42
41
  s.test_files = [
43
42
  "test/helper.rb",
@@ -54,10 +53,12 @@ Gem::Specification.new do |s|
54
53
  s.add_runtime_dependency(%q<command-line-utils>, [">= 0.0.1"])
55
54
  s.add_runtime_dependency(%q<launchy>, [">= 0"])
56
55
  s.add_runtime_dependency(%q<json>, [">= 0"])
56
+ s.add_runtime_dependency(%q<rdoc>, [">= 0"])
57
57
  s.add_development_dependency(%q<shoulda>, [">= 0"])
58
58
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
59
59
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
60
60
  s.add_development_dependency(%q<rcov>, [">= 0"])
61
+ s.add_development_dependency(%q<mocha>, [">= 0"])
61
62
  else
62
63
  s.add_dependency(%q<rest-client>, [">= 0"])
63
64
  s.add_dependency(%q<keystorage>, ["> 0.1"])
@@ -65,10 +66,12 @@ Gem::Specification.new do |s|
65
66
  s.add_dependency(%q<command-line-utils>, [">= 0.0.1"])
66
67
  s.add_dependency(%q<launchy>, [">= 0"])
67
68
  s.add_dependency(%q<json>, [">= 0"])
69
+ s.add_dependency(%q<rdoc>, [">= 0"])
68
70
  s.add_dependency(%q<shoulda>, [">= 0"])
69
71
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
70
72
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
71
73
  s.add_dependency(%q<rcov>, [">= 0"])
74
+ s.add_dependency(%q<mocha>, [">= 0"])
72
75
  end
73
76
  else
74
77
  s.add_dependency(%q<rest-client>, [">= 0"])
@@ -77,10 +80,12 @@ Gem::Specification.new do |s|
77
80
  s.add_dependency(%q<command-line-utils>, [">= 0.0.1"])
78
81
  s.add_dependency(%q<launchy>, [">= 0"])
79
82
  s.add_dependency(%q<json>, [">= 0"])
83
+ s.add_dependency(%q<rdoc>, [">= 0"])
80
84
  s.add_dependency(%q<shoulda>, [">= 0"])
81
85
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
82
86
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
83
87
  s.add_dependency(%q<rcov>, [">= 0"])
88
+ s.add_dependency(%q<mocha>, [">= 0"])
84
89
  end
85
90
  end
86
91
 
data/test/helper.rb CHANGED
@@ -9,6 +9,7 @@ rescue Bundler::BundlerError => e
9
9
  end
10
10
  require 'test/unit'
11
11
  require 'shoulda'
12
+ require 'mocha'
12
13
 
13
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
data/test/test_phper.rb CHANGED
@@ -1,7 +1,25 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestPhper < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
4
+ def command commands
5
+ Phper::CLI::run(commands)
6
+ end
7
+ context "commands" do
8
+ setup do
9
+ require "stringio"
10
+ @cli = Phper::CLI.new
11
+ @cli.out = StringIO.new
12
+ end
13
+
14
+ should "version shows version" do
15
+ @cli.version
16
+ assert @cli.out.string =~ /\d+\.\d+.\d+/
17
+ end
18
+
19
+ should "help shows help" do
20
+ command ["help"]
21
+ # assert_equal(@cli.out.string.length,481)
22
+ end
23
+
6
24
  end
7
25
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 4
10
- version: 0.5.4
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-01 00:00:00 +09:00
19
- default_executable: phper
18
+ date: 2011-10-15 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
21
+ type: :runtime
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
@@ -31,8 +31,8 @@ dependencies:
31
31
  version_requirements: *id001
32
32
  name: rest-client
33
33
  prerelease: false
34
- type: :runtime
35
34
  - !ruby/object:Gem::Dependency
35
+ type: :runtime
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
38
38
  requirements:
@@ -46,8 +46,8 @@ dependencies:
46
46
  version_requirements: *id002
47
47
  name: keystorage
48
48
  prerelease: false
49
- type: :runtime
50
49
  - !ruby/object:Gem::Dependency
50
+ type: :runtime
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
@@ -61,8 +61,8 @@ dependencies:
61
61
  version_requirements: *id003
62
62
  name: highline
63
63
  prerelease: false
64
- type: :runtime
65
64
  - !ruby/object:Gem::Dependency
65
+ type: :runtime
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
@@ -77,8 +77,8 @@ dependencies:
77
77
  version_requirements: *id004
78
78
  name: command-line-utils
79
79
  prerelease: false
80
- type: :runtime
81
80
  - !ruby/object:Gem::Dependency
81
+ type: :runtime
82
82
  requirement: &id005 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
@@ -91,8 +91,8 @@ dependencies:
91
91
  version_requirements: *id005
92
92
  name: launchy
93
93
  prerelease: false
94
- type: :runtime
95
94
  - !ruby/object:Gem::Dependency
95
+ type: :runtime
96
96
  requirement: &id006 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
@@ -105,8 +105,8 @@ dependencies:
105
105
  version_requirements: *id006
106
106
  name: json
107
107
  prerelease: false
108
- type: :runtime
109
108
  - !ruby/object:Gem::Dependency
109
+ type: :runtime
110
110
  requirement: &id007 !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
@@ -117,11 +117,25 @@ dependencies:
117
117
  - 0
118
118
  version: "0"
119
119
  version_requirements: *id007
120
- name: shoulda
120
+ name: rdoc
121
121
  prerelease: false
122
- type: :development
123
122
  - !ruby/object:Gem::Dependency
123
+ type: :development
124
124
  requirement: &id008 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ version_requirements: *id008
134
+ name: shoulda
135
+ prerelease: false
136
+ - !ruby/object:Gem::Dependency
137
+ type: :development
138
+ requirement: &id009 !ruby/object:Gem::Requirement
125
139
  none: false
126
140
  requirements:
127
141
  - - ~>
@@ -132,12 +146,12 @@ dependencies:
132
146
  - 0
133
147
  - 0
134
148
  version: 1.0.0
135
- version_requirements: *id008
149
+ version_requirements: *id009
136
150
  name: bundler
137
151
  prerelease: false
138
- type: :development
139
152
  - !ruby/object:Gem::Dependency
140
- requirement: &id009 !ruby/object:Gem::Requirement
153
+ type: :development
154
+ requirement: &id010 !ruby/object:Gem::Requirement
141
155
  none: false
142
156
  requirements:
143
157
  - - ~>
@@ -148,12 +162,12 @@ dependencies:
148
162
  - 5
149
163
  - 2
150
164
  version: 1.5.2
151
- version_requirements: *id009
165
+ version_requirements: *id010
152
166
  name: jeweler
153
167
  prerelease: false
154
- type: :development
155
168
  - !ruby/object:Gem::Dependency
156
- requirement: &id010 !ruby/object:Gem::Requirement
169
+ type: :development
170
+ requirement: &id011 !ruby/object:Gem::Requirement
157
171
  none: false
158
172
  requirements:
159
173
  - - ">="
@@ -162,10 +176,23 @@ dependencies:
162
176
  segments:
163
177
  - 0
164
178
  version: "0"
165
- version_requirements: *id010
179
+ version_requirements: *id011
166
180
  name: rcov
167
181
  prerelease: false
182
+ - !ruby/object:Gem::Dependency
168
183
  type: :development
184
+ requirement: &id012 !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ hash: 3
190
+ segments:
191
+ - 0
192
+ version: "0"
193
+ version_requirements: *id012
194
+ name: mocha
195
+ prerelease: false
169
196
  description: phper
170
197
  email: y.takahara@gmail.com
171
198
  executables:
@@ -176,8 +203,8 @@ extra_rdoc_files:
176
203
  - LICENSE.txt
177
204
  - README.md
178
205
  files:
206
+ - .document
179
207
  - Gemfile
180
- - Gemfile.lock
181
208
  - LICENSE.txt
182
209
  - README.md
183
210
  - Rakefile
@@ -190,7 +217,6 @@ files:
190
217
  - phper.gemspec
191
218
  - test/helper.rb
192
219
  - test/test_phper.rb
193
- has_rdoc: true
194
220
  homepage: http://github.com/tumf/phper
195
221
  licenses:
196
222
  - MIT
@@ -220,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
246
  requirements: []
221
247
 
222
248
  rubyforge_project:
223
- rubygems_version: 1.5.0
249
+ rubygems_version: 1.8.6
224
250
  signing_key:
225
251
  specification_version: 3
226
252
  summary: phper
data/Gemfile.lock DELETED
@@ -1,37 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- command-line-utils (0.0.2)
5
- configuration (1.2.0)
6
- git (1.2.5)
7
- highline (1.6.1)
8
- jeweler (1.5.2)
9
- bundler (~> 1.0.0)
10
- git (>= 1.2.5)
11
- rake
12
- json (1.5.1)
13
- keystorage (0.4.3)
14
- launchy (0.3.7)
15
- configuration (>= 0.0.5)
16
- rake (>= 0.8.1)
17
- mime-types (1.16)
18
- rake (0.8.7)
19
- rcov (0.9.9)
20
- rest-client (1.6.1)
21
- mime-types (>= 1.16)
22
- shoulda (2.11.3)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- bundler (~> 1.0.0)
29
- command-line-utils (>= 0.0.1)
30
- highline (> 1.6)
31
- jeweler (~> 1.5.2)
32
- json
33
- keystorage (> 0.1)
34
- launchy
35
- rcov
36
- rest-client
37
- shoulda