old_style 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +20 -0
- data/README.md +71 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/app/assets/stylesheets/fake3.css.scss +13 -0
- data/app/assets/stylesheets/fake4.css +4 -0
- data/app/views/fake/fake.html.erb +13 -0
- data/app/views/fake/fake2.html +4 -0
- data/base.css +131 -0
- data/bin/old_style +6 -0
- data/lib/format.rb +112 -0
- data/lib/html_parser.rb +40 -0
- data/lib/load_dir.rb +35 -0
- data/lib/old_style.rb +5 -0
- data/lib/parse_dir.rb +92 -0
- data/old_style/index.css +131 -0
- data/old_style/index.html +5 -0
- data/old_style.gemspec +83 -0
- data/test/helper.rb +39 -0
- data/test/test_format.rb +53 -0
- data/test/test_html_parser.rb +67 -0
- data/test/test_load_dir.rb +28 -0
- data/test/test_old_style.rb +2 -0
- data/test/test_parse_dir.rb +86 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dad1fb00389e8c39b59862b8f9d2ab99e571212d
|
4
|
+
data.tar.gz: 8c4bde912e68d9ae4851585f22684449fd0de662
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac9c276e3937651c00deef39f8d22a8a6e5a733a4f1ed5c9cc0edc5c2c49b84ee35f6ac42abbeeb85c93a94345a7e7d2ea1118c899e50510c8933574ab549b30
|
7
|
+
data.tar.gz: 190770cee455b9864271765fb10efa5f3104234e42d954347851c85a004ee13bcaef7e6af2aba8c3015f22a79c7ce4045d0b7e363030bb7414c4d4fea9238621
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem 'css_parser'
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "minitest", ">= 0"
|
11
|
+
gem "rdoc", "~> 3.12"
|
12
|
+
gem "bundler", "~> 1.0"
|
13
|
+
gem "jeweler", "~> 2.0.1"
|
14
|
+
gem "simplecov", ">= 0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.5)
|
5
|
+
builder (3.2.2)
|
6
|
+
css_parser (1.3.5)
|
7
|
+
addressable
|
8
|
+
descendants_tracker (0.0.3)
|
9
|
+
docile (1.1.3)
|
10
|
+
faraday (0.9.0)
|
11
|
+
multipart-post (>= 1.2, < 3)
|
12
|
+
git (1.2.6)
|
13
|
+
github_api (0.11.2)
|
14
|
+
addressable (~> 2.3)
|
15
|
+
descendants_tracker (~> 0.0.1)
|
16
|
+
faraday (~> 0.8, < 0.10)
|
17
|
+
hashie (>= 1.2)
|
18
|
+
multi_json (>= 1.7.5, < 2.0)
|
19
|
+
oauth2
|
20
|
+
hashie (2.0.5)
|
21
|
+
highline (1.6.20)
|
22
|
+
jeweler (2.0.1)
|
23
|
+
builder
|
24
|
+
bundler (>= 1.0)
|
25
|
+
git (>= 1.2.5)
|
26
|
+
github_api
|
27
|
+
highline (>= 1.6.15)
|
28
|
+
rake
|
29
|
+
rdoc
|
30
|
+
json (1.8.1)
|
31
|
+
jwt (0.1.11)
|
32
|
+
multi_json (>= 1.5)
|
33
|
+
mini_portile (0.5.2)
|
34
|
+
minitest (5.2.2)
|
35
|
+
multi_json (1.8.4)
|
36
|
+
multi_xml (0.5.5)
|
37
|
+
multipart-post (2.0.0)
|
38
|
+
mini_portile (~> 0.5.0)
|
39
|
+
oauth2 (0.9.3)
|
40
|
+
faraday (>= 0.8, < 0.10)
|
41
|
+
jwt (~> 0.1.8)
|
42
|
+
multi_json (~> 1.3)
|
43
|
+
multi_xml (~> 0.5)
|
44
|
+
rack (~> 1.2)
|
45
|
+
rack (1.5.2)
|
46
|
+
rake (10.1.1)
|
47
|
+
rdoc (3.12.2)
|
48
|
+
json (~> 1.4)
|
49
|
+
simplecov (0.8.2)
|
50
|
+
docile (~> 1.1.0)
|
51
|
+
multi_json
|
52
|
+
simplecov-html (~> 0.8.0)
|
53
|
+
simplecov-html (0.8.0)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 1.0)
|
60
|
+
css_parser
|
61
|
+
jeweler (~> 2.0.1)
|
62
|
+
minitest
|
63
|
+
rdoc (~> 3.12)
|
64
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 hayduke19us
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# old_style for Rails
|
2
|
+
|
3
|
+
I'm not the most organized person. It would be a big help to me if there was a helper to keep my stylesheets clean. old_style.gem helps you do that!
|
4
|
+
old_style compares all of your styles with the differen nodes in your views.
|
5
|
+
If old_style doesn't find a corresponding id or class or parent node in the html file it registers the style as **Bad**.
|
6
|
+
|
7
|
+
####Setup is simple
|
8
|
+
gem install 'old_style'
|
9
|
+
|
10
|
+
#### Commands
|
11
|
+
###### *In the root of your project
|
12
|
+
old_style 'some controller name that has views and stylesheets'
|
13
|
+
|
14
|
+
If I had a project with a posts controller. That posts controller had a set of views and one stylesheet. I would type:
|
15
|
+
|
16
|
+
old_style posts
|
17
|
+
|
18
|
+
If my project had a users controller with views and stylesheets and I wanted to include those in the comparison I would type:
|
19
|
+
|
20
|
+
old_style posts users
|
21
|
+
|
22
|
+
If all went well an old_style/index.html file has been generated in the root of your project.
|
23
|
+
|
24
|
+
open old_style/index.html
|
25
|
+
|
26
|
+
![example index](http://i.imgur.com/mGGpY8m.png)
|
27
|
+
|
28
|
+
####Updates
|
29
|
+
I keep a [work blog](http://mcsullivan.me/blog/2014/01/30/old-style-dot-gem-work-blog/) But be gental this is just a place for me to write quickly as I code. I'm a horrible speller.
|
30
|
+
|
31
|
+
######Version 1.3.1
|
32
|
+
* performance boost by two seconds
|
33
|
+
* fixed bug. Can now find tags like 'div.something'
|
34
|
+
|
35
|
+
######Version 1.2.1
|
36
|
+
* sorted list of styles
|
37
|
+
|
38
|
+
######Version 1.2.0
|
39
|
+
* got rid of nokogiri
|
40
|
+
* Using an in house parser
|
41
|
+
* parses erb,html,haml
|
42
|
+
* better accuracy on comparing files
|
43
|
+
|
44
|
+
######Version 1.1.0
|
45
|
+
* Nicer old_style/index.html view
|
46
|
+
* Links to each compared file
|
47
|
+
* Format moved to a module for better performance
|
48
|
+
* ParseDir inherits from LoadDir. More organized code!
|
49
|
+
* Testing is in the green.
|
50
|
+
|
51
|
+
####Future Features
|
52
|
+
|
53
|
+
* JS rendering of html file with hover affect from styles
|
54
|
+
* possible chart of improvement
|
55
|
+
|
56
|
+
|
57
|
+
####Contributing to old_style
|
58
|
+
|
59
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
60
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
61
|
+
* Fork the project.
|
62
|
+
* Start a feature/bugfix branch.
|
63
|
+
* Commit and push until you are happy with your contribution.
|
64
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
65
|
+
* 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.
|
66
|
+
|
67
|
+
####Copyright
|
68
|
+
|
69
|
+
Copyright (c) 2014 hayduke19us. See LICENSE.txt for
|
70
|
+
further details.
|
71
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "old_style"
|
18
|
+
gem.homepage = "http://github.com/hayduke19us/old_style"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Get rid of those old css styles}
|
21
|
+
gem.description = %Q{Rails helper. Finds the irrelevent styles in your
|
22
|
+
stylesheet and generates a html report to keep you informed.}
|
23
|
+
gem.email = "hayduke19us@gmail.com"
|
24
|
+
gem.authors = ["hayduke19us"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Code coverage detail"
|
37
|
+
task :simplecov do
|
38
|
+
ENV['COVERAGE'] = "true"
|
39
|
+
Rake::Task['test'].execute
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rdoc/task'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "old_style #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.4.1
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= link_to "test", "#", id: 'test-id'%>
|
2
|
+
<%= :class => 'row' %>
|
3
|
+
<li id = 'peace' class = 'give'>forget you</li>
|
4
|
+
|
5
|
+
<h1>some randome string</h1>
|
6
|
+
hello i am an unmarked group of text
|
7
|
+
|
8
|
+
|
9
|
+
<a href = "http://something">some random link</a>
|
10
|
+
i am another unmarked group of text
|
11
|
+
that gets really long winded. Like the family member
|
12
|
+
that is a depressant and pulls you aside at thanksgiving to talk to you about a set of
|
13
|
+
memories that quite frankly dont mean anything to you
|
data/base.css
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
li {list-style: none;}
|
3
|
+
|
4
|
+
a {text-decoration: none;
|
5
|
+
}
|
6
|
+
|
7
|
+
body {background-color: #efefef;
|
8
|
+
margin: 0 0 0 0;
|
9
|
+
}
|
10
|
+
|
11
|
+
#header{height: 50px;
|
12
|
+
width: 100%;
|
13
|
+
background-color: #3EA4ED;
|
14
|
+
font-family: "HelveticaNeue-Light",
|
15
|
+
}
|
16
|
+
|
17
|
+
#main-heading {padding: 20px 0 20px 5%;
|
18
|
+
font-size: 20px;
|
19
|
+
color: #B2D4ED;
|
20
|
+
}
|
21
|
+
|
22
|
+
#content {padding: 30px 5% 5% 5%;
|
23
|
+
line-height: 1.4;
|
24
|
+
font-family: "HelveticaNeue-Light",
|
25
|
+
"Helvetica Neue Light",
|
26
|
+
"Helvetica Neue",
|
27
|
+
"Helvetica Helvetica",
|
28
|
+
"Helvetica",
|
29
|
+
"Arial",
|
30
|
+
"Lucida Grande",
|
31
|
+
"sans-serif";
|
32
|
+
font-weight 300;
|
33
|
+
}
|
34
|
+
|
35
|
+
#dir-heading {border-bottom: 1px solid #cccaca;}
|
36
|
+
|
37
|
+
#looked-in {width:100%;
|
38
|
+
padding-bottom: 50px;
|
39
|
+
}
|
40
|
+
|
41
|
+
#looked-css {width: 200px;
|
42
|
+
float: left;
|
43
|
+
border-right: 2px solid #cccaca;
|
44
|
+
padding-right: 10px;
|
45
|
+
}
|
46
|
+
|
47
|
+
#css-heading {border-bottom: 1px solid #cccaca;
|
48
|
+
font-size: 20px;
|
49
|
+
font-weight: bold;
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
#html-heading {border-bottom: 1px solid #cccaca;
|
54
|
+
font-size: 20px;
|
55
|
+
font-weight: bold;
|
56
|
+
}
|
57
|
+
#looked-html {width: 200px;
|
58
|
+
float: left;
|
59
|
+
padding-left: 10px;
|
60
|
+
}
|
61
|
+
|
62
|
+
#css-file:hover {color: blue;}
|
63
|
+
#html-file:hover {color: blue;}
|
64
|
+
|
65
|
+
#found-wrapper{padding: 30px 0 30px 0;
|
66
|
+
width: 100%;
|
67
|
+
float: left;
|
68
|
+
color: green;
|
69
|
+
}
|
70
|
+
|
71
|
+
#found-title-wrapper {border-bottom: 1px solid #cccaca;}
|
72
|
+
|
73
|
+
|
74
|
+
#found-css {padding-right: 10px;
|
75
|
+
display: inline;
|
76
|
+
font-weight: bold;
|
77
|
+
font-size: 20px;
|
78
|
+
|
79
|
+
}
|
80
|
+
#good-percent {display: inline;
|
81
|
+
color: black;
|
82
|
+
}
|
83
|
+
|
84
|
+
#found-style-wrapper {padding-top:10px;}
|
85
|
+
|
86
|
+
#empty-wrapper {color: red;
|
87
|
+
float: left;
|
88
|
+
width: 100%;
|
89
|
+
}
|
90
|
+
|
91
|
+
#empty-title-wrapper {border-bottom: 1px solid #cccaca;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
#empty-css {padding-right: 10px;
|
96
|
+
display: inline;
|
97
|
+
font-weight: bold;
|
98
|
+
font-size: 20px;
|
99
|
+
|
100
|
+
}
|
101
|
+
|
102
|
+
#bad-percent {display: inline;
|
103
|
+
color: black;
|
104
|
+
}
|
105
|
+
|
106
|
+
#empty-style-wrapper {padding: 10px 0 40px 0;}
|
107
|
+
|
108
|
+
|
109
|
+
#style {color: green;}
|
110
|
+
|
111
|
+
#footer {width: 100%;
|
112
|
+
float: left;
|
113
|
+
height: 200px;
|
114
|
+
background-color: #ADB3B8;
|
115
|
+
padding-top: 50px;
|
116
|
+
line-height: 1.4;
|
117
|
+
font-family: "HelveticaNeue-Light";
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
#footer-info {padding: 0 0 0 5%;
|
122
|
+
font-size: 20px;
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
#footer-caption {color: #efefef;}
|
127
|
+
|
128
|
+
#issues-link:hover {color: blue;}
|
129
|
+
|
130
|
+
|
131
|
+
|
data/bin/old_style
ADDED
data/lib/format.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
|
2
|
+
module Format
|
3
|
+
PATH = Dir.pwd
|
4
|
+
BASE = File.expand_path('../../base.css', __FILE__)
|
5
|
+
|
6
|
+
def new_or_open_index
|
7
|
+
unless File.directory?(PATH + "/old_style")
|
8
|
+
Dir.mkdir(PATH + "/old_style")
|
9
|
+
end
|
10
|
+
File.open(PATH + "/old_style/index.html", 'w+')
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_css_file?
|
14
|
+
write_css
|
15
|
+
end
|
16
|
+
|
17
|
+
def css_path
|
18
|
+
PATH + "/old_style/index.css"
|
19
|
+
end
|
20
|
+
|
21
|
+
def write_css
|
22
|
+
file = File.new(css_path, 'w+')
|
23
|
+
File.readlines(BASE).each do |line|
|
24
|
+
file.write line
|
25
|
+
end
|
26
|
+
file.close
|
27
|
+
end
|
28
|
+
|
29
|
+
def write_index
|
30
|
+
file = new_or_open_index
|
31
|
+
create_css_file?
|
32
|
+
file.write "<div id='header'>"
|
33
|
+
file.write "<li id='main-heading'>
|
34
|
+
#{self.directories.count} Controller evaluated </li>"
|
35
|
+
file.write "</div>"
|
36
|
+
file.write "<body>"
|
37
|
+
file.write "<head>"
|
38
|
+
file.write "<link rel='stylesheet' type='text/css' href=#{css_path}>"
|
39
|
+
file.write "</head>"
|
40
|
+
file.write "<div id='content'>"
|
41
|
+
file.write "<div id='directories'>"
|
42
|
+
file.write "<h2 id='dir-heading'>#{self.directories.sort_by{|x| x.downcase}}</h2>"
|
43
|
+
file.write "</div>"
|
44
|
+
file.write "<h4>#{self.css.count} css files compared to
|
45
|
+
#{self.html.count} html files
|
46
|
+
</h4>"
|
47
|
+
file.write "<div id='looked-in'>"
|
48
|
+
file.write "<div id='looked-css'>"
|
49
|
+
file.write "<div id='css-heading'>Css</div>"
|
50
|
+
self.css.each do |css, path|
|
51
|
+
file.write "<li><a id='css-file' href=#{path}/#{css}>#{css}<a></li>"
|
52
|
+
end
|
53
|
+
file.write "</div>"
|
54
|
+
file.write "<div id='looked-html'>"
|
55
|
+
file.write "<div id='html-heading'>Html</div>"
|
56
|
+
self.html.each do |html, path|
|
57
|
+
file.write "<li><a id='html-file' href=#{path}>#{html}<a></li>"
|
58
|
+
|
59
|
+
end
|
60
|
+
file.write "</div>"
|
61
|
+
file.write "</div>"
|
62
|
+
file.write "<div id='found-wrapper'>"
|
63
|
+
file.write "<div id='found-title-wrapper'>"
|
64
|
+
file.write "<li id='found-css'>Good</li>"
|
65
|
+
file.write "<li id='good-percent'> #{self.good_percent}</li>"
|
66
|
+
file.write "</div>"
|
67
|
+
file.write "<div id='found-style-wrapper'>"
|
68
|
+
self.found.sort_by{|x| x.first.downcase}.each do |style, desc|
|
69
|
+
file.write "<li id='style'>#{style} {#{desc}}</li>"
|
70
|
+
end
|
71
|
+
file.write "</div>"
|
72
|
+
file.write "</div>"
|
73
|
+
|
74
|
+
file.write "<div id='empty-wrapper'>"
|
75
|
+
file.write "<div id='empty-title-wrapper'>"
|
76
|
+
file.write "<h4 id='empty-css'>Bad</h4>"
|
77
|
+
file.write "<li id='bad-percent'> #{self.bad_percent}</li>"
|
78
|
+
file.write "</div>"
|
79
|
+
file.write "<div id='empty-style-wrapper'>"
|
80
|
+
self.empty.sort_by{|x| x.first.downcase}.each do |style, desc|
|
81
|
+
file.write "<li id='empty_style'>#{style} {#{desc}}</li>"
|
82
|
+
end
|
83
|
+
file.write "</div>"
|
84
|
+
file.write "</div>"
|
85
|
+
file.write "</div>"
|
86
|
+
file.write "</body>"
|
87
|
+
file.write "<div id='footer'>"
|
88
|
+
file.write "<div id='footer-info'>"
|
89
|
+
file.write "<li id='footer-caption'>If you find any issues please let me know
|
90
|
+
at </li>"
|
91
|
+
file.write "<a id ='issues-link' href = 'https://github.com/hayduke19us/old_style/issues?state=open'>old_style's issues page on github<a>"
|
92
|
+
file.write "</div>"
|
93
|
+
file.write "</div>"
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
def good_percent
|
98
|
+
x = self.found.keys.count/(self.found.keys.count + self.empty.keys.count).to_f
|
99
|
+
y = (x * 100).to_s
|
100
|
+
z = /(.{5}|.{3}.|.{2})/.match(y)
|
101
|
+
z.to_s + "%"
|
102
|
+
end
|
103
|
+
|
104
|
+
def bad_percent
|
105
|
+
x = self.empty.keys.count/(self.found.keys.count + self.empty.keys.count).to_f
|
106
|
+
y = (x * 100).to_s
|
107
|
+
z = /(.{5}|.{3}.|.{2})/.match(y)
|
108
|
+
z.to_s + "%"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
data/lib/html_parser.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
module HtmlParser
|
3
|
+
|
4
|
+
def read_html file
|
5
|
+
File.readlines(file)
|
6
|
+
end
|
7
|
+
|
8
|
+
def remove_extras file
|
9
|
+
#the whitespace first
|
10
|
+
read_html(file).map {|line| line.delete(" <%>:=''\"\"")}
|
11
|
+
end
|
12
|
+
|
13
|
+
def id_exists? tag, file
|
14
|
+
tag = tag.gsub('#', 'id')
|
15
|
+
remove_extras(file).each do |line|
|
16
|
+
if line.match(tag)
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def class_exists? tag, file
|
23
|
+
tag = tag.gsub('.', 'class') if tag.match(/^./)
|
24
|
+
remove_extras(file).each do |line|
|
25
|
+
if line.match(tag)
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def parent_exists? tag, file
|
32
|
+
tag = tag.gsub('div.', 'class') if tag.match(/div/)
|
33
|
+
remove_extras(file).each do |line|
|
34
|
+
if line.match(tag)
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/load_dir.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
class LoadDir
|
3
|
+
|
4
|
+
HTML_PATH = Dir.pwd + '/app/views'
|
5
|
+
CSS_PATH = Dir.pwd + '/app/assets/stylesheets'
|
6
|
+
|
7
|
+
attr_accessor :directories, :files
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
@directories = args.flatten
|
11
|
+
@files = {}
|
12
|
+
dir_iteration
|
13
|
+
end
|
14
|
+
|
15
|
+
def dir_iteration
|
16
|
+
@directories.each {|dir| html_files(dir)}
|
17
|
+
@directories.each {|dir| css_files(dir)}
|
18
|
+
end
|
19
|
+
|
20
|
+
def html_files dir
|
21
|
+
Dir.foreach(HTML_PATH + "/" + dir) do |file|
|
22
|
+
@files[file] = HTML_PATH + "/" + dir + "/" + file unless /^\./.match(file)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def css_files dir
|
27
|
+
#Dir.foreach methods arg is only the base dir
|
28
|
+
Dir.foreach(CSS_PATH) do |file|
|
29
|
+
@files[file] = CSS_PATH if /#{dir}/.match(file)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|