asset_sweeper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
File without changes
data/Manifest ADDED
@@ -0,0 +1,10 @@
1
+ CHANGELOG
2
+ README.rdoc
3
+ Rakefile
4
+ init.rb
5
+ lib/asset_sweeper.rb
6
+ nbproject/private/private.xml
7
+ nbproject/project.properties
8
+ nbproject/project.xml
9
+ tasks/asset_sweeper.rake
10
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,43 @@
1
+ = Asset Sweeper
2
+
3
+ This plugin is for cleaning up rails application by removing unused images from application.
4
+
5
+ == Install
6
+
7
+ ruby script/plugin install git@github.com:anilg/asset_sweeper.git
8
+
9
+
10
+ == Usage
11
+
12
+ Run rake task
13
+
14
+ rake asset_sweeper:sweep -t
15
+
16
+ This rake task scans for all images (.jpg, .png, .gif) in application (html, css, js files)
17
+ and create a folder named unused in applications root directory and list all images which are not used in application.
18
+ But if image name is constructed dynamically in code this script will list such images also
19
+ and images in assets/attachments like folder will be listed so you need to verify images in that folder before deleting.
20
+
21
+
22
+ == License
23
+
24
+ Copyright (c) 2008 Ryan Bates
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining
27
+ a copy of this software and associated documentation files (the
28
+ "Software"), to deal in the Software without restriction, including
29
+ without limitation the rights to use, copy, modify, merge, publish,
30
+ distribute, sublicense, and/or sell copies of the Software, and to
31
+ permit persons to whom the Software is furnished to do so, subject to
32
+ the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be
35
+ included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
43
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('asset_sweeper', '0.1.0') do |p|
6
+ p.description = "Cleans up application by removing unused images."
7
+ p.url = "http://github.com/anilg/asset_sweeper"
8
+ p.author = "Anil Galve"
9
+ p.email = "galve.anil@gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "asset_sweeper"
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Anil Galve"]
9
+ s.date = "2011-09-14"
10
+ s.description = "Cleans up application by removing unused images."
11
+ s.email = "galve.anil@gmail.com"
12
+ s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/asset_sweeper.rb", "tasks/asset_sweeper.rake"]
13
+ s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "init.rb", "lib/asset_sweeper.rb", "nbproject/private/private.xml", "nbproject/project.properties", "nbproject/project.xml", "tasks/asset_sweeper.rake", "Manifest", "asset_sweeper.gemspec"]
14
+ s.homepage = "http://github.com/anilg/asset_sweeper"
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Asset_sweeper", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = "asset_sweeper"
18
+ s.rubygems_version = "1.8.10"
19
+ s.summary = "Cleans up application by removing unused images."
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'asset_sweeper'
@@ -0,0 +1,14 @@
1
+ module AssetSweeper
2
+ def self.included(base)
3
+ base.extend ClassMethods
4
+ end
5
+
6
+ module ClassMethods
7
+ end
8
+ end
9
+
10
+ class ActiveRecord::Base
11
+ include AssetSweeper
12
+ end
13
+
14
+
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
4
+ </project-private>
@@ -0,0 +1,3 @@
1
+ main.file=
2
+ platform.active=JRuby
3
+ source.encoding=UTF-8
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://www.netbeans.org/ns/project/1">
3
+ <type>org.netbeans.modules.ruby.rubyproject</type>
4
+ <configuration>
5
+ <data xmlns="http://www.netbeans.org/ns/ruby-project/1">
6
+ <name>sweeper</name>
7
+ <source-roots/>
8
+ <test-roots/>
9
+ </data>
10
+ </configuration>
11
+ </project>
@@ -0,0 +1,21 @@
1
+ # Author Anil
2
+ # Task to remove unused images
3
+ namespace :asset_sweeper do
4
+ task :sweep => :environment do
5
+ require "fileutils"
6
+ img=Dir.glob("**/*.jpg")+Dir.glob("**/*.png")+Dir.glob("**/*.gif")
7
+ data=Dir.glob("**/*.htm*")+Dir.glob("**/*.css")+Dir.glob("**/*.js")
8
+ puts img.length.to_s+" images found & "+data.length.to_s+" files found to search against"
9
+ content=""
10
+ data.each do |f|
11
+ content+=File.open(f, 'r').read
12
+ end
13
+ img.each do |m|
14
+ if not content=~ Regexp.new("\\b"+File.basename(m)+"\\b")
15
+ FileUtils.mkdir_p "unused/"+File.dirname(m)
16
+ FileUtils.cp m,"unused/"+m
17
+ puts "Image "+m+" moved to unused/"+File.dirname(m)+" folder"
18
+ end
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asset_sweeper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Anil Galve
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-14 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Cleans up application by removing unused images.
22
+ email: galve.anil@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - CHANGELOG
29
+ - README.rdoc
30
+ - lib/asset_sweeper.rb
31
+ - tasks/asset_sweeper.rake
32
+ files:
33
+ - CHANGELOG
34
+ - README.rdoc
35
+ - Rakefile
36
+ - init.rb
37
+ - lib/asset_sweeper.rb
38
+ - nbproject/private/private.xml
39
+ - nbproject/project.properties
40
+ - nbproject/project.xml
41
+ - tasks/asset_sweeper.rake
42
+ - Manifest
43
+ - asset_sweeper.gemspec
44
+ homepage: http://github.com/anilg/asset_sweeper
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --line-numbers
50
+ - --inline-source
51
+ - --title
52
+ - Asset_sweeper
53
+ - --main
54
+ - README.rdoc
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 11
72
+ segments:
73
+ - 1
74
+ - 2
75
+ version: "1.2"
76
+ requirements: []
77
+
78
+ rubyforge_project: asset_sweeper
79
+ rubygems_version: 1.8.10
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Cleans up application by removing unused images.
83
+ test_files: []
84
+