pitcgi 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0cf4459a29ff53d4dc34871d86107a136b5f2d1
4
- data.tar.gz: 231be48665e67fd8cc9143442b416e2915546ed4
3
+ metadata.gz: 8cba141a31259b063bb9fed2dcf9d0238fd03b80
4
+ data.tar.gz: 8cdd6b826ce45ee0d54f649df472d7777f7660e5
5
5
  SHA512:
6
- metadata.gz: 4ecaa88144cb0a545a40277cd4b5e7070024ec67893c1e64bc05e4710c1e52151b8a6c63f995f26230b77fcea7820335e61ecea7d9a3ad0f4d63390493781290
7
- data.tar.gz: 3fd742addbff52e5a1b61efb89cf28e776f43847aeb57520cd0066287589161cdc70a66ad7f078873b05a7d54225e394b3267be8c81d9b61ceede7b3783e4d27
6
+ metadata.gz: 4fd62cf6fcc9e15ff7c0677220b9d6ce177b7214bc7d8b2b399e42a18c1b6b5fc32d16a26ba781e7c9a63eeedceabacffaff361c0511d8ccf02c1ad3a56d2a7c
7
+ data.tar.gz: f69f1834ca502bfa9ab2e474394c5cdfbc85e3aeb40de2501fb4d838b51e322b0a6337c69af6ccaadccf10a9314d784f580ebce0510e594fa0b5d5b8a356fe00
data/ChangeLog CHANGED
@@ -1,6 +1,15 @@
1
+ 2015-01-28 sanadan <jecy00@gmail.com>
2
+
3
+ * Add init command
4
+
5
+
6
+ 2015-01-13 sanadan <jecy00@gmail.com>
7
+
8
+ * Fixed error using value "false"
9
+
10
+
1
11
  2014-12-18 sanadan <jecy00@gmail.com>
2
12
 
3
- * [release]:
4
- pit 0.0.7を改造してcgi専用に修正。
5
- コマンド名もpitcgiに修正。
13
+ * Change pit 0.0.7 for cgi only.
14
+ * Rename to pitcgi.
6
15
 
data/README.md CHANGED
@@ -19,12 +19,9 @@ pitcgi is account management tool for cgi.
19
19
 
20
20
 
21
21
  ### Setup
22
- ```sh
23
- $ sudo mkdir /etc/pitcgi
24
- $ sudo chgrp www-data /etc/pitcgi
25
- $ sudo chmod 770 /etc/pitcgi
26
- $ sudo adduser `echo $USER` www-data
27
- ```
22
+
23
+ $ pitcgi init
24
+
28
25
 
29
26
  ## Features/Problems
30
27
 
data/bin/pitcgi CHANGED
@@ -8,7 +8,7 @@ require "pitcgi"
8
8
 
9
9
  class PitcgiCommand
10
10
  VERSION = Pitcgi::VERSION
11
- NAME = "pitcgi"
11
+ NAME = Pitcgi::NAME
12
12
 
13
13
  def self.run(argv)
14
14
  new(argv.dup).run
@@ -49,6 +49,14 @@ class PitcgiCommand
49
49
  Switch profile to <profile>.
50
50
  EOB
51
51
  },
52
+
53
+ "init" => OptionParser.new { |opts|
54
+ opts.banner = <<-EOB.gsub(/^\t+/, "")
55
+ Usage: #{NAME} init
56
+
57
+ Initialize #{NAME} environment.
58
+ EOB
59
+ },
52
60
  }
53
61
 
54
62
  @parser = OptionParser.new do |parser|
@@ -130,6 +138,14 @@ class PitcgiCommand
130
138
  puts @parser.help
131
139
  end
132
140
  end
141
+
142
+ def cmd_init
143
+ puts( 'Initialize environment.' )
144
+ system( "sudo mkdir #{Pitcgi::Directory}" )
145
+ system( "sudo chmod 770 #{Pitcgi::Directory}" )
146
+ system( "sudo chgrp www-data #{Pitcgi::Directory}" )
147
+ system( "sudo adduser $USER www-data" )
148
+ end
133
149
  end
134
150
 
135
151
  PitcgiCommand.run(ARGV)
data/lib/pitcgi.rb CHANGED
@@ -1,10 +1,10 @@
1
-
2
1
  require 'pitcgi/version'
3
2
  require "yaml"
4
3
  require "pathname"
5
4
  require "tempfile"
6
5
 
7
6
  module Pitcgi
7
+ NAME = 'pitcgi'
8
8
  Directory = Pathname.new("/etc/pitcgi").expand_path
9
9
  @@config = Directory + "pitcgi.yaml"
10
10
  @@profile = Directory + "default.yaml"
@@ -68,9 +68,13 @@ module Pitcgi
68
68
  protected
69
69
  def self.load
70
70
  unless Directory.exist?
71
- Directory.mkpath
72
- Directory.chmod 0770
73
- Directory.chown(nil, 33) # www-data
71
+ begin
72
+ Directory.mkpath
73
+ Directory.chmod 0770
74
+ Directory.chown(nil, 33) # www-data
75
+ rescue Errno::EACCES => e
76
+ raise e, "May not be initialized. Use '#{NAME} init'."
77
+ end
74
78
  end
75
79
  unless @@config.exist?
76
80
  @@config.open("w") {|f| f << {"profile"=>"default"}.to_yaml }
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pitcgi
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
data/test/pitcgi_test.rb CHANGED
@@ -13,14 +13,31 @@ class Pathname
13
13
  end
14
14
  end
15
15
 
16
- dir = Pathname.tempname
17
- dir.mkpath
18
- #ENV["HOME"] = dir.to_s
19
-
20
16
  require File.dirname(__FILE__) + '/test_helper.rb'
21
-
22
17
  require "test/unit"
18
+ ORG_DIR = Pitcgi::Directory.to_s.sub( /\/$/, '' ) + '.org'
19
+
23
20
  class PitcgiTest < Test::Unit::TestCase
21
+ class << self
22
+ def ps( command )
23
+ puts( command )
24
+ system( command )
25
+ end
26
+
27
+ def startup
28
+ # Rename /etc/pitcgi if exist
29
+ ps( "sudo mv #{Pitcgi::Directory} #{ORG_DIR}" )
30
+ ps( "pitcgi init" )
31
+ end
32
+
33
+ def shutdown
34
+ # Rename /etc/pitcgi.org if exist
35
+ puts
36
+ ps( "sudo rm -rf #{Pitcgi::Directory}" )
37
+ ps( "sudo mv #{ORG_DIR} #{Pitcgi::Directory}" )
38
+ end
39
+ end
40
+
24
41
  def test_load
25
42
  assert Pitcgi
26
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pitcgi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanadan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-13 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'pitcgi: account management tool for cgi'
14
14
  email: