can_write 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +8 -0
  2. data/bin/can_write +65 -0
  3. data/can_write.gemspec +13 -0
  4. metadata +63 -0
@@ -0,0 +1,8 @@
1
+ Make file named can_write in your application root and write simple commands, such as:
2
+
3
+
4
+ ['tmp', 'log'].should_be_writable.by_user 'www-data'
5
+
6
+ %w{app lib}.should_be_readable.by_user 'www-data'
7
+
8
+ %w{script/generate script/about}.should_be_executable.by_user 'www-data'
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fileutils'
4
+
5
+ if File.expand_path(__FILE__) == File.expand_path(File.join(Dir.pwd, 'can_write'))
6
+ puts "Run it from you app folder, containing can_wrtie file with permissions"
7
+ exit
8
+ end
9
+
10
+ unless File.file?(File.join Dir.pwd, 'can_write')
11
+ puts "No can_write file found at #{Dir.pwd}"
12
+ exit
13
+ end
14
+
15
+ VERBOSE = false
16
+
17
+ class Horse
18
+ class << self
19
+ attr_accessor :conf
20
+ end
21
+ @conf = []
22
+
23
+ def go!
24
+ self.class.conf.each do |rule|
25
+ rule[:dirs].each do |dir|
26
+ FileUtils.chown rule[:user], rule[:user], dir, :verbose => VERBOSE if rule[:user] != 'any'
27
+ FileUtils.chmod_R 0777, dir, :verbose => VERBOSE if rule[:access] == :execute
28
+ FileUtils.chmod_R 0666, dir, :verbose => VERBOSE if rule[:access] == :write
29
+ FileUtils.chmod_R 0444, dir, :verbose => VERBOSE if rule[:access] == :read
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ class Array
36
+ def should_be_writable
37
+ store_condition :write
38
+ end
39
+
40
+ def should_be_readable
41
+ store_condition :read
42
+ end
43
+
44
+ def should_be_executable
45
+ store_condition :execute
46
+ end
47
+
48
+ private
49
+
50
+ def store_condition access
51
+ hash = {:user => 'any', :access => access, :dirs => self}
52
+ Horse.conf << hash
53
+ hash
54
+ end
55
+ end
56
+
57
+ class Hash
58
+ def by_user user
59
+ self[:user] = user
60
+ end
61
+ end
62
+
63
+ at_exit { Horse.new.go! }
64
+
65
+ load File.join Dir.pwd, 'can_write'
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "can_write"
3
+ s.version = "0.4"
4
+ s.summary = "Set permissions for folders and files."
5
+ s.description = "Tool for setting permission on files of web after deploy"
6
+ s.author = "Pavel Evstigneev"
7
+ s.email = "pavel.evst@gmail.com"
8
+ s.homepage = "http://github.com/Paxa/can_write"
9
+ s.has_rdoc = false
10
+ s.executables = ["can_write"]
11
+ s.rubyforge_project = "can_write"
12
+ s.files = [ "bin/can_write", "README.md", "can_write.gemspec", "lib"]
13
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: can_write
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ version: "0.4"
9
+ platform: ruby
10
+ authors:
11
+ - Pavel Evstigneev
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-03-09 00:00:00 +03:00
17
+ default_executable:
18
+ dependencies: []
19
+
20
+ description: Tool for setting permission on files of web after deploy
21
+ email: pavel.evst@gmail.com
22
+ executables:
23
+ - can_write
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - bin/can_write
30
+ - README.md
31
+ - can_write.gemspec
32
+ has_rdoc: true
33
+ homepage: http://github.com/Paxa/can_write
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ requirements: []
56
+
57
+ rubyforge_project: can_write
58
+ rubygems_version: 1.3.6
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Set permissions for folders and files.
62
+ test_files: []
63
+