phper 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -115,14 +115,11 @@ class Phper::Commands < CommandLineUtils::Commands
115
115
  # if here
116
116
  if in_git? and project["project"]["id"] != git_remote(Dir.pwd)
117
117
  git = project["project"]["git"]
118
- cmd = "git remote add phper #{git}"
119
- %x{#{cmd}}
120
- puts "--> #{cmd}"
118
+ exec_report("git remote add phper #{git}")
119
+ init_phper_dir
121
120
  end
122
121
  end
123
122
 
124
-
125
-
126
123
  def destroy
127
124
  project = nil
128
125
  yes = false
@@ -147,9 +144,7 @@ class Phper::Commands < CommandLineUtils::Commands
147
144
  # if here
148
145
  if in_git? and project == git_remote(Dir.pwd)
149
146
  git_remotes(git).each{ |name|
150
- cmd = "git remote rm #{name}"
151
- %x{#{cmd}}
152
- puts "--> #{cmd}"
147
+ exec_report("git remote rm #{name}")
153
148
  }
154
149
  end
155
150
  end
@@ -383,4 +378,73 @@ class Phper::Commands < CommandLineUtils::Commands
383
378
  login unless @agent.login?
384
379
  end
385
380
  end
381
+
382
+ def exec_report cmd
383
+ %x{#{cmd}}
384
+ puts "--> #{cmd}"
385
+ end
386
+
387
+ =begin
388
+ * [CLI] .phper/deploy
389
+ * [CLI] .phper/initdb
390
+ * [CLI] .phper/httpd.conf
391
+ * [CLI] .phper/rsync_exclude.txt
392
+ =end
393
+ def init_phper_dir
394
+ files = {}
395
+ files[:deploy] = File.join(git_root,".phper","deploy")
396
+ files[:initdb] = File.join(git_root,".phper","initdb")
397
+ files[:httpd] = File.join(git_root,".phper","httpd.conf")
398
+ files[:rsync] = File.join(git_root,".phper","rsync_exclude.txt")
399
+ FileUtils.mkdir_p(File.join(git_root,".phper"))
400
+ puts File.join(git_root,".phper")
401
+ # deploy
402
+ unless File.file?(files[:deploy])
403
+ File.open(files[:deploy],"w"){ |f|
404
+ f.puts <<EOF
405
+ # deploy script here
406
+ if [ ! -f .phper.deployed ] ; then
407
+ # when 1st deployed.
408
+ fi
409
+
410
+ EOF
411
+ }
412
+ File::chmod(0100755,files[:deploy])
413
+ exec_report("git add -f #{files[:deploy]}")
414
+ end
415
+ # initdb
416
+ unless File.file?(files[:initdb])
417
+ File.open(files[:initdb],"w"){ |f|
418
+ f.puts <<EOF
419
+ # run after inititalize database
420
+ EOF
421
+ f.puts ""
422
+ }
423
+ File::chmod(0100755,files[:initdb])
424
+ exec_report("git add -f #{files[:initdb]}")
425
+ end
426
+ # httpd.conf
427
+ unless File.file?(files[:httpd])
428
+ File.open(files[:httpd],"w"){ |f|
429
+ f.puts <<EOF
430
+ # httpd.conf
431
+ EOF
432
+ }
433
+ exec_report("git add -f #{files[:httpd]}")
434
+ end
435
+ # rsync
436
+ unless File.file?(files[:rsync])
437
+ File.open(files[:rsync],"w"){ |f|
438
+ f.puts <<EOF
439
+ # rsync exclude
440
+ .git
441
+ CVS
442
+ .svn
443
+ EOF
444
+ }
445
+ exec_report("git add -f #{files[:rsync]}")
446
+ end
447
+ end
448
+
449
+
386
450
  end
data/lib/phper.rb CHANGED
@@ -33,6 +33,24 @@ module Phper
33
33
  $?.to_i == 0
34
34
  end
35
35
 
36
+ def git_root
37
+ root = nil
38
+ begin
39
+ startdir = FileUtils.pwd
40
+ until File.directory?(".git")
41
+ FileUtils.cd('..')
42
+ raise "can't find git project" if FileUtils.pwd == "/"
43
+ end
44
+ root = FileUtils.pwd
45
+ rescue =>e
46
+ puts e
47
+ ensure
48
+ FileUtils.cd(startdir)
49
+ end
50
+ return root
51
+ end
52
+
53
+
36
54
  end
37
55
  require "rubygems"
38
56
  require "json"
data/phper.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{phper}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yoshihiro TAKAHARA"]
12
- s.date = %q{2011-02-23}
12
+ s.date = %q{2011-02-25}
13
13
  s.default_executable = %q{phper}
14
14
  s.description = %q{phper}
15
15
  s.email = %q{y.takahara@gmail.com}
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-23 00:00:00 +09:00
18
+ date: 2011-02-25 00:00:00 +09:00
19
19
  default_executable: phper
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency