chlorine 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/Rakefile +20 -0
- data/chlorine.gemspec +47 -0
- data/lib/chlorine/clean.rb +53 -0
- data/lib/chlorine/version.rb +8 -0
- data/lib/chlorine.rb +2 -0
- data/lib/rails/generators/chlorine/config/config_generator.rb +20 -0
- data/lib/rails/generators/chlorine/config/templates/chlorine.yml +11 -0
- metadata +10 -2
data/.gitignore
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/lib/chlorine/version'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = 'chlorine'
|
10
|
+
gem.summary = %Q{Keep your Rails app clean.}
|
11
|
+
gem.description = %Q{Automatically cleans out directories you specify when the server starts up.}
|
12
|
+
gem.email = 'trevor@iterative.ly'
|
13
|
+
gem.homepage = 'http://github.com/TrevorBurnham/chlorine'
|
14
|
+
gem.version = Chlorine::Version::STRING
|
15
|
+
gem.authors = ['Trevor Burnham']
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
|
20
|
+
end
|
data/chlorine.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{chlorine}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Trevor Burnham"]
|
12
|
+
s.date = %q{2010-07-24}
|
13
|
+
s.description = %q{Automatically cleans out directories you specify when the server starts up.}
|
14
|
+
s.email = %q{trevor@iterative.ly}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"chlorine.gemspec",
|
25
|
+
"lib/chlorine.rb",
|
26
|
+
"lib/chlorine/clean.rb",
|
27
|
+
"lib/chlorine/version.rb",
|
28
|
+
"lib/rails/generators/chlorine/config/config_generator.rb",
|
29
|
+
"lib/rails/generators/chlorine/config/templates/chlorine.yml"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/TrevorBurnham/chlorine}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.7}
|
35
|
+
s.summary = %q{Keep your Rails app clean.}
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
else
|
43
|
+
end
|
44
|
+
else
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rails'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Chlorine
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
|
8
|
+
initializer "chlorine.configure_rails_initialization" do
|
9
|
+
begin
|
10
|
+
@config = YAML::load_file File.expand_path('config/chlorine.yml', RAILS_ROOT)
|
11
|
+
rescue Exception => e
|
12
|
+
puts "Chlorine was unable to read its configuration: #{e}"
|
13
|
+
end
|
14
|
+
|
15
|
+
return unless @config['envs'] and @config['envs'].include? Rails.env
|
16
|
+
|
17
|
+
@config['dirs'].each do |dir_name, dir_config|
|
18
|
+
begin
|
19
|
+
dir_config['excludes'] = dir_config['excludes'].collect {|x| x[-1] == '/' ? x[0...-1] : x}
|
20
|
+
next unless valid_dir_config? dir_config
|
21
|
+
next unless Dir.exists? File.expand_path(dir_name, RAILS_ROOT)
|
22
|
+
dir = Dir.new File.expand_path(dir_name, RAILS_ROOT)
|
23
|
+
dir.each { |filename|
|
24
|
+
unless (['.', '..'] + dir_config['excludes']).include?(filename)
|
25
|
+
filepath = File.expand_path(dir_name + '/' + filename, RAILS_ROOT)
|
26
|
+
if File.file?(filepath)
|
27
|
+
File.delete filepath
|
28
|
+
elsif File.directory?(filepath)
|
29
|
+
FileUtils.rm_rf filepath
|
30
|
+
end
|
31
|
+
end
|
32
|
+
}
|
33
|
+
rescue Exception => e
|
34
|
+
puts "Chlorine hit an exception: #{e}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def valid_dir_config?(dir_config)
|
42
|
+
dir_config['excludes'].each do |exclude|
|
43
|
+
next if exclude == ''
|
44
|
+
if exclude[0...-1].match '/'
|
45
|
+
puts "Invalid exclude '#{exclude}' in chlorine.yml: excludes must be root-level"
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/chlorine.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Chlorine
|
2
|
+
module Generators
|
3
|
+
class ConfigGenerator < Rails::Generators::Base
|
4
|
+
desc 'Creates a Chlorine configuration file at config/chlorine.yml'
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@_mongoid_source_root ||= File.expand_path('../templates', __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
def app_name
|
11
|
+
Rails::Application.subclasses.first.parent.to_s.underscore
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_config_file
|
15
|
+
template 'chlorine.yml', File.join('config', 'chlorine.yml')
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Trevor Burnham
|
@@ -28,8 +28,16 @@ extra_rdoc_files:
|
|
28
28
|
- LICENSE
|
29
29
|
- README.md
|
30
30
|
files:
|
31
|
+
- .gitignore
|
31
32
|
- LICENSE
|
32
33
|
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- chlorine.gemspec
|
36
|
+
- lib/chlorine.rb
|
37
|
+
- lib/chlorine/clean.rb
|
38
|
+
- lib/chlorine/version.rb
|
39
|
+
- lib/rails/generators/chlorine/config/config_generator.rb
|
40
|
+
- lib/rails/generators/chlorine/config/templates/chlorine.yml
|
33
41
|
has_rdoc: true
|
34
42
|
homepage: http://github.com/TrevorBurnham/chlorine
|
35
43
|
licenses: []
|