reaper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage
6
+ rdoc
7
+ doc
8
+ .yardoc
9
+ .bundle
10
+ pkg
11
+ tmp/*
12
+ .DS_Store
13
+ For vim:
14
+ *.swp
15
+ *.swo
16
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'slop'
4
+
5
+ # Specify your gem's dependencies in reaper.gemspec
6
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'slop'
4
+
5
+ opts = Slop.parse do
6
+ on :v, :verbose, 'Enable verbose mode' # boolean value
7
+ on :i, :images, 'Remove standard images'
8
+ end
9
+
10
+ puts "testing the build"
@@ -0,0 +1,5 @@
1
+ require "reaper/version"
2
+
3
+ module Reaper
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,33 @@
1
+ module Reaper
2
+ class Images
3
+ def self.reap!
4
+
5
+ images = Dir.glob("**/*.jpg")+Dir.glob("**/*.png")+Dir.glob("**/*.gif")
6
+ data = Dir.glob("**/*.htm*")+Dir.glob("**/*.css")+Dir.glob("**/*.js") + Dir.glob("**/*.haml*") + Dir.glob("**/*.rb")
7
+
8
+ puts images.length.to_s + " images found & " + data.length.to_s + " files found to search against"
9
+
10
+ #
11
+ # concatenate all content into one big string
12
+ #
13
+ content=""
14
+ data.each do |f|
15
+ content+=File.open(f, 'r').read
16
+ end
17
+
18
+
19
+ total = images.inject(0) do |total_removed, image|
20
+ #if not content=~ Regexp.new("\\b"+File.basename(m)+"\\b", true)
21
+ unless content.match( /\b#{File.basename(image)}\b/i )
22
+ FileUtils.mkdir_p "./unused/" + File.dirname(image)
23
+ FileUtils.mv image, "./unused/" + image
24
+ puts "Image " + image + " moved to ./unused/" + File.dirname(image) + " folder"
25
+ total_removed += 1
26
+ end
27
+ end
28
+
29
+ "There were #{total || 0} images removed in all"
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Reaper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ Reaper
2
+ ====
3
+
4
+ A tool to remove unused static assets from a project. Only image removal is supported for now, stylesheets and javascripts at some point in the future.
5
+
6
+ Usage
7
+ -----
8
+ $ reap --images
9
+
10
+ Future
11
+ ----
12
+ * support removal of javascript and css/sass files
13
+ * allow directories and filetypes to be manually specified
14
+ * baked in git branching support
15
+ * support for concatenated filenames
16
+
17
+ Contributing to Reaper
18
+ --------------------
19
+
20
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
21
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
22
+ * Fork the project
23
+ * Start a feature/bugfix branch
24
+ * Commit and push until you are happy with your contribution
25
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
26
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
27
+
28
+ Copyright
29
+ ---------
30
+
31
+ Copyright (c) 2011 Dan Carper. See LICENSE.txt for
32
+ further details.
33
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "reaper/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "reaper"
7
+ s.version = Reaper::VERSION
8
+ s.authors = ["Dan Carper"]
9
+ s.email = ["dcarper@dreamagile.com"]
10
+ s.homepage = ""
11
+ s.summary = "Removes files that are not referenced in other text files"
12
+ s.description = "Only images are handled for now. Totally not that battle heardened"
13
+
14
+ s.rubyforge_project = "reaper"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.executables = 'reap'
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ s.add_runtime_dependency "slop"
25
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reaper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Dan Carper
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-16 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: slop
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Only images are handled for now. Totally not that battle heardened
36
+ email:
37
+ - dcarper@dreamagile.com
38
+ executables:
39
+ - reap
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - Rakefile
48
+ - bin/reap
49
+ - lib/reaper.rb
50
+ - lib/reaper/images.rb
51
+ - lib/reaper/version.rb
52
+ - readme.markdown
53
+ - reaper.gemspec
54
+ has_rdoc: true
55
+ homepage: ""
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: reaper
84
+ rubygems_version: 1.3.9.2
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Removes files that are not referenced in other text files
88
+ test_files: []
89
+