miss-marple 0.0.1
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 +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +11 -0
- data/bin/miss-marple +5 -0
- data/lib/miss-marple/comparer.rb +17 -0
- data/lib/miss-marple/detector.rb +19 -0
- data/lib/miss-marple/logger.rb +13 -0
- data/lib/miss-marple/parser.rb +18 -0
- data/lib/miss-marple/searcher.rb +10 -0
- data/lib/miss-marple/version.rb +3 -0
- data/lib/miss-marple.rb +9 -0
- data/miss-marple.gemspec +25 -0
- data/test/fixtures/app.css +4 -0
- data/test/fixtures/tree/first.css +0 -0
- data/test/fixtures/tree/manifest.css +3 -0
- data/test/fixtures/tree/second.css +0 -0
- data/test/fixtures/ui/orange.css +0 -0
- data/test/miss-marple/comparer_test.rb +15 -0
- data/test/miss-marple/parser_test.rb +14 -0
- data/test/miss-marple/searcher_test.rb +10 -0
- data/test/test_helper.rb +8 -0
- metadata +135 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f2fb606a3e03eb00447fe26f98469b1f898e75b2
|
|
4
|
+
data.tar.gz: 8550af14218076fa7a90ca3a6f989302df396e1d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7dcb7619c0039ea5d46ac372c100c22e399dc71524e0728b67675bfbc47316e997ffa83b3ff9132258d0a8a7beed1115a5c5023af65afc022578bf91cbee0efc
|
|
7
|
+
data.tar.gz: 1eabf544cb0b0dca736bf3a028742187ec57078782739d9f6a4f84e77ac6fe9e0f115379b085cf3e170926faf93fc5c277a75b88554564c8ba064d0a77df5c19
|
data/.coveralls.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Jana Petrova
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Miss Marple
|
|
2
|
+
[](https://coveralls.io/r/JanaVPetrova/miss-marple?branch=develop)
|
|
3
|
+
[](https://travis-ci.org/JanaVPetrova/miss-marple)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
TODO: Write a gem description
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
gem 'miss-marple'
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install miss-marple
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
1. Fork it ( http://github.com/JanaVPetrova/miss-marple/fork )
|
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/miss-marple
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class MissMarple::Comparer
|
|
2
|
+
def self.compare(parsed, searched)
|
|
3
|
+
searched.map!{|fname| fname.split(".").first }
|
|
4
|
+
|
|
5
|
+
searched.reject{ |fname| search_similar(parsed, fname) }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
def self.search_similar(arr, searched_fname)
|
|
10
|
+
arr.each do |path|
|
|
11
|
+
if searched_fname.end_with?(path) || searched_fname.start_with?(path)
|
|
12
|
+
return true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
return false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class MissMarple::Detector
|
|
2
|
+
def self.run(rails_root)
|
|
3
|
+
dirs = ["app/assets", "lib/assets", "vendor/assets"]
|
|
4
|
+
dirs.map!{|path| rails_root + path}
|
|
5
|
+
|
|
6
|
+
searched = MissMarple::Searcher.search(dirs)
|
|
7
|
+
|
|
8
|
+
required = searched.inject([]){ |result, fname| result + MissMarple::Parser.parse(fname) }
|
|
9
|
+
|
|
10
|
+
# FIXME insert requiring into required. this is not a place for logic %)
|
|
11
|
+
# FIXME dirty hack
|
|
12
|
+
requiring = searched.reject(){ |fname| MissMarple::Parser.parse(fname).empty? }
|
|
13
|
+
searched -= requiring
|
|
14
|
+
|
|
15
|
+
unused = MissMarple::Comparer.compare(required, searched)
|
|
16
|
+
|
|
17
|
+
MissMarple::Logger.log(unused, requiring)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class MissMarple::Parser
|
|
2
|
+
def self.parse(path)
|
|
3
|
+
content = File.readlines(path)
|
|
4
|
+
valuable_strings = content.reject{ |str| !str.include?("= require") }
|
|
5
|
+
|
|
6
|
+
required = search_paths valuable_strings, path
|
|
7
|
+
required += valuable_strings.map{ |str| str.partition("require ").last.chomp }
|
|
8
|
+
required.map!{|str| str.gsub(".", "")}
|
|
9
|
+
required.reject{ |str| str.empty? }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
def self.search_paths arr, path
|
|
14
|
+
result = arr.map{ |str| str.partition("require_tree ").last.chomp }
|
|
15
|
+
result.reject!{ |str| str.empty? }
|
|
16
|
+
result.map{|str| File.dirname(path) + str }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class MissMarple::Searcher
|
|
2
|
+
def self.search(paths)
|
|
3
|
+
files_and_dirs = paths.map{|path| Dir.glob("#{path}/**/*") }.flatten
|
|
4
|
+
|
|
5
|
+
permited_exts = %(.css .js .js.coffee .less .scss .sass)
|
|
6
|
+
|
|
7
|
+
no_dirs = files_and_dirs.reject{ |file| File.directory?(file) }
|
|
8
|
+
no_dirs.reject{|file| !permited_exts.include? File.extname(file) }
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/miss-marple.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require "miss-marple/version"
|
|
2
|
+
|
|
3
|
+
module MissMarple
|
|
4
|
+
autoload :Parser, "miss-marple/parser"
|
|
5
|
+
autoload :Comparer, "miss-marple/comparer"
|
|
6
|
+
autoload :Searcher, "miss-marple/searcher"
|
|
7
|
+
autoload :Detector, "miss-marple/detector"
|
|
8
|
+
autoload :Logger, "miss-marple/logger"
|
|
9
|
+
end
|
data/miss-marple.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'miss-marple/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "miss-marple"
|
|
8
|
+
spec.version = MissMarple::VERSION
|
|
9
|
+
spec.authors = ["Jana Petrova"]
|
|
10
|
+
spec.email = ["janavpetrova@gmail.com"]
|
|
11
|
+
spec.summary = "Detects unused assets"
|
|
12
|
+
spec.description = "Miss Marple provides an easy way to detect unused assets"
|
|
13
|
+
spec.homepage = "https://github.com/JanaVPetrova/miss-marple"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
|
22
|
+
spec.add_development_dependency "minitest", "~> 4.2"
|
|
23
|
+
spec.add_development_dependency "wrong", "~> 0.7"
|
|
24
|
+
spec.add_development_dependency "coveralls", "~> 0.7"
|
|
25
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class MissMarple::ComparerTest < MiniTest::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@parsed_filenames = ["ui/orange", "app"]
|
|
6
|
+
@searched_filenames = @parsed_filenames + ["extra-file"]
|
|
7
|
+
|
|
8
|
+
@compared = MissMarple::Comparer.compare(@parsed_filenames, @searched_filenames)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_should_compare_filenames
|
|
12
|
+
assert { @compared.class == Array }
|
|
13
|
+
assert { @compared == (@searched_filenames - @parsed_filenames) }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class MissMarple::ParserTest < MiniTest::Unit::TestCase
|
|
4
|
+
def test_should_tun_tests
|
|
5
|
+
assert { true == true }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_should_read_manifest
|
|
9
|
+
c = MissMarple::Parser.parse("test/fixtures/tree/manifest.css")
|
|
10
|
+
|
|
11
|
+
assert { c.class == Array }
|
|
12
|
+
assert { !c.empty? }
|
|
13
|
+
end
|
|
14
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: miss-marple
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jana Petrova
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.5'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.5'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: minitest
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '4.2'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '4.2'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: wrong
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0.7'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0.7'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: coveralls
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0.7'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0.7'
|
|
69
|
+
description: Miss Marple provides an easy way to detect unused assets
|
|
70
|
+
email:
|
|
71
|
+
- janavpetrova@gmail.com
|
|
72
|
+
executables:
|
|
73
|
+
- miss-marple
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".coveralls.yml"
|
|
78
|
+
- ".gitignore"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- Gemfile
|
|
81
|
+
- LICENSE.txt
|
|
82
|
+
- README.md
|
|
83
|
+
- Rakefile
|
|
84
|
+
- bin/miss-marple
|
|
85
|
+
- lib/miss-marple.rb
|
|
86
|
+
- lib/miss-marple/comparer.rb
|
|
87
|
+
- lib/miss-marple/detector.rb
|
|
88
|
+
- lib/miss-marple/logger.rb
|
|
89
|
+
- lib/miss-marple/parser.rb
|
|
90
|
+
- lib/miss-marple/searcher.rb
|
|
91
|
+
- lib/miss-marple/version.rb
|
|
92
|
+
- miss-marple.gemspec
|
|
93
|
+
- test/fixtures/app.css
|
|
94
|
+
- test/fixtures/tree/first.css
|
|
95
|
+
- test/fixtures/tree/manifest.css
|
|
96
|
+
- test/fixtures/tree/second.css
|
|
97
|
+
- test/fixtures/ui/orange.css
|
|
98
|
+
- test/miss-marple/comparer_test.rb
|
|
99
|
+
- test/miss-marple/parser_test.rb
|
|
100
|
+
- test/miss-marple/searcher_test.rb
|
|
101
|
+
- test/test_helper.rb
|
|
102
|
+
homepage: https://github.com/JanaVPetrova/miss-marple
|
|
103
|
+
licenses:
|
|
104
|
+
- MIT
|
|
105
|
+
metadata: {}
|
|
106
|
+
post_install_message:
|
|
107
|
+
rdoc_options: []
|
|
108
|
+
require_paths:
|
|
109
|
+
- lib
|
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: '0'
|
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
requirements: []
|
|
121
|
+
rubyforge_project:
|
|
122
|
+
rubygems_version: 2.2.2
|
|
123
|
+
signing_key:
|
|
124
|
+
specification_version: 4
|
|
125
|
+
summary: Detects unused assets
|
|
126
|
+
test_files:
|
|
127
|
+
- test/fixtures/app.css
|
|
128
|
+
- test/fixtures/tree/first.css
|
|
129
|
+
- test/fixtures/tree/manifest.css
|
|
130
|
+
- test/fixtures/tree/second.css
|
|
131
|
+
- test/fixtures/ui/orange.css
|
|
132
|
+
- test/miss-marple/comparer_test.rb
|
|
133
|
+
- test/miss-marple/parser_test.rb
|
|
134
|
+
- test/miss-marple/searcher_test.rb
|
|
135
|
+
- test/test_helper.rb
|