old_style 1.4.1 → 1.4.2
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 +4 -4
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/app/assets/stylesheets/application.css +4 -0
- data/app/views/fake/{fake.html.erb → fake1.html.erb} +0 -0
- data/app/views/layouts/application.html.erb +0 -0
- data/app/views/layouts/fake.html.erb +0 -0
- data/app/views/layouts/not_relevent.html.erb +0 -0
- data/base.css +0 -2
- data/lib/format.rb +14 -6
- data/lib/html_parser.rb +0 -1
- data/lib/load_dir.rb +15 -4
- data/old_style/index.css +0 -2
- data/old_style/index.html +3 -3
- data/old_style.gemspec +9 -4
- data/test/helper.rb +1 -0
- data/test/performance/bench_html_parser.rb +40 -0
- data/test/test_format.rb +8 -33
- data/test/test_html_parser.rb +5 -5
- data/test/test_load_dir.rb +4 -1
- data/test/test_parse_dir.rb +5 -5
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39068544c4ac65f06a7aa7ec48395d0c5dad58d
|
4
|
+
data.tar.gz: 5b80a3d2c48f6d78e7cd4909442b9717bcecb128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d3b77c306368700bc5f53ccc27855eaf5175cf4a499215508c8d38871d68ff7433beee4f0d6eaa2cb1d30d4e44ac52d45b2e5413a51076220a1722d0dfcd27
|
7
|
+
data.tar.gz: a57ae805e96352347d1b8b17ad787ae3a0ee720eed8983f462448bf2c3f71503ddfd3ed825c34f00b14576c2246b844805b552ed5409a2cbb900e397dffa6643
|
data/Rakefile
CHANGED
@@ -33,6 +33,13 @@ Rake::TestTask.new(:test) do |test|
|
|
33
33
|
test.verbose = true
|
34
34
|
end
|
35
35
|
|
36
|
+
Rake::TestTask.new(:bench) do |bench|
|
37
|
+
ENV['BENCH'] = 'true'
|
38
|
+
bench.libs << 'lib' << 'test'
|
39
|
+
bench.pattern = 'test/**/bench_*.rb'
|
40
|
+
bench.verbose = true
|
41
|
+
end
|
42
|
+
|
36
43
|
desc "Code coverage detail"
|
37
44
|
task :simplecov do
|
38
45
|
ENV['COVERAGE'] = "true"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.2
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/base.css
CHANGED
data/lib/format.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
|
2
2
|
module Format
|
3
|
+
|
3
4
|
PATH = Dir.pwd
|
4
5
|
BASE = File.expand_path('../../base.css', __FILE__)
|
6
|
+
CSS_PATH = PATH + "/old_style/index.css"
|
5
7
|
|
6
8
|
def new_or_open_index
|
7
9
|
unless File.directory?(PATH + "/old_style")
|
@@ -10,16 +12,21 @@ module Format
|
|
10
12
|
File.open(PATH + "/old_style/index.html", 'w+')
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
14
|
-
|
15
|
+
def base_css_count
|
16
|
+
File.readlines(BASE).count == File.readlines(CSS_PATH).count
|
15
17
|
end
|
16
18
|
|
17
|
-
def
|
18
|
-
|
19
|
+
def create_css_file?
|
20
|
+
unless File.exists?(CSS_PATH) && base_css_count
|
21
|
+
write_css
|
22
|
+
true
|
23
|
+
else
|
24
|
+
false
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
28
|
def write_css
|
22
|
-
file = File.new(
|
29
|
+
file = File.new(CSS_PATH, 'w+')
|
23
30
|
File.readlines(BASE).each do |line|
|
24
31
|
file.write line
|
25
32
|
end
|
@@ -35,7 +42,7 @@ module Format
|
|
35
42
|
file.write "</div>"
|
36
43
|
file.write "<body>"
|
37
44
|
file.write "<head>"
|
38
|
-
file.write "<link rel='stylesheet' type='text/css' href=#{
|
45
|
+
file.write "<link rel='stylesheet' type='text/css' href=#{CSS_PATH}>"
|
39
46
|
file.write "</head>"
|
40
47
|
file.write "<div id='content'>"
|
41
48
|
file.write "<div id='directories'>"
|
@@ -91,6 +98,7 @@ module Format
|
|
91
98
|
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
99
|
file.write "</div>"
|
93
100
|
file.write "</div>"
|
101
|
+
file.close
|
94
102
|
true
|
95
103
|
end
|
96
104
|
|
data/lib/html_parser.rb
CHANGED
data/lib/load_dir.rb
CHANGED
@@ -13,20 +13,31 @@ class LoadDir
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def dir_iteration
|
16
|
-
@directories.each
|
17
|
-
|
16
|
+
@directories.each do |dir|
|
17
|
+
html_files(dir)
|
18
|
+
layout_files(dir)
|
19
|
+
css_files(dir)
|
20
|
+
end
|
18
21
|
end
|
19
22
|
|
20
23
|
def html_files dir
|
21
24
|
Dir.foreach(HTML_PATH + "/" + dir) do |file|
|
22
|
-
|
25
|
+
self.files[file] = HTML_PATH + "/" + dir + "/" + file unless /^\./.match(file)
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
29
|
+
def layout_files dir
|
30
|
+
Dir.foreach(HTML_PATH + "/layouts") do |file|
|
31
|
+
if /(#{dir}\.html|application\.html)/.match(file)
|
32
|
+
self.files[file] = HTML_PATH + "/layouts/" + file unless /^\./.match(file)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
26
37
|
def css_files dir
|
27
38
|
#Dir.foreach methods arg is only the base dir
|
28
39
|
Dir.foreach(CSS_PATH) do |file|
|
29
|
-
|
40
|
+
self.files[file] = CSS_PATH if /(#{dir}|application)/.match(file)
|
30
41
|
end
|
31
42
|
end
|
32
43
|
|
data/old_style/index.css
CHANGED
data/old_style/index.html
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<div id='header'><li id='main-heading'>
|
2
|
-
1 Controller evaluated </li></div><body><head><link rel='stylesheet' type='text/css' href=/Users/hayduke19us/my_gems/old_style/old_style/index.css></head><div id='content'><div id='directories'><h2 id='dir-heading'>["fake"]</h2></div><h4>
|
3
|
-
|
4
|
-
</h4><div id='looked-in'><div id='looked-css'><div id='css-heading'>Css</div><li><a id='css-file' href=/Users/hayduke19us/my_gems/old_style/app/assets/stylesheets/fake3.css.scss>fake3.css.scss<a></li><li><a id='css-file' href=/Users/hayduke19us/my_gems/old_style/app/assets/stylesheets/fake4.css>fake4.css<a></li></div><div id='looked-html'><div id='html-heading'>Html</div><li><a id='html-file' href=/Users/hayduke19us/my_gems/old_style/app/views/fake/
|
2
|
+
1 Controller evaluated </li></div><body><head><link rel='stylesheet' type='text/css' href=/Users/hayduke19us/my_gems/old_style/old_style/index.css></head><div id='content'><div id='directories'><h2 id='dir-heading'>["fake"]</h2></div><h4>3 css files compared to
|
3
|
+
4 html files
|
4
|
+
</h4><div id='looked-in'><div id='looked-css'><div id='css-heading'>Css</div><li><a id='css-file' href=/Users/hayduke19us/my_gems/old_style/app/assets/stylesheets/application.css>application.css<a></li><li><a id='css-file' href=/Users/hayduke19us/my_gems/old_style/app/assets/stylesheets/fake3.css.scss>fake3.css.scss<a></li><li><a id='css-file' href=/Users/hayduke19us/my_gems/old_style/app/assets/stylesheets/fake4.css>fake4.css<a></li></div><div id='looked-html'><div id='html-heading'>Html</div><li><a id='html-file' href=/Users/hayduke19us/my_gems/old_style/app/views/fake/fake1.html.erb>fake1.html.erb<a></li><li><a id='html-file' href=/Users/hayduke19us/my_gems/old_style/app/views/fake/fake2.html>fake2.html<a></li><li><a id='html-file' href=/Users/hayduke19us/my_gems/old_style/app/views/layouts/application.html.erb>application.html.erb<a></li><li><a id='html-file' href=/Users/hayduke19us/my_gems/old_style/app/views/layouts/fake.html.erb>fake.html.erb<a></li></div></div><div id='found-wrapper'><div id='found-title-wrapper'><li id='found-css'>Good</li><li id='good-percent'> 62.5%</li></div><div id='found-style-wrapper'><li id='style'>#franny {padding: 100%;}</li><li id='style'>#salinger {color: blue;}</li><li id='style'>#test-id {border: 1px solid #efefef;}</li><li id='style'>.row {float: left; color: red; border-radius: 5px;}</li><li id='style'>div.well {}</li></div></div><div id='empty-wrapper'><div id='empty-title-wrapper'><h4 id='empty-css'>Bad</h4><li id='bad-percent'> 37.5%</li></div><div id='empty-style-wrapper'><li id='empty_style'>#find {color: blue;}</li><li id='empty_style'>.franny {padding: 50%;}</li><li id='empty_style'>.zooey {width: 5px;}</li></div></div></div></body><div id='footer'><div id='footer-info'><li id='footer-caption'>If you find any issues please let me know
|
5
5
|
at </li><a id ='issues-link' href = 'https://github.com/hayduke19us/old_style/issues?state=open'>old_style's issues page on github<a></div></div>
|
data/old_style.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: old_style 1.4.
|
5
|
+
# stub: old_style 1.4.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "old_style"
|
9
|
-
s.version = "1.4.
|
9
|
+
s.version = "1.4.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["hayduke19us"]
|
13
|
-
s.date = "2014-02-
|
13
|
+
s.date = "2014-02-13"
|
14
14
|
s.description = "Rails helper. Finds the irrelevent styles in your \n stylesheet and generates a html report to keep you informed."
|
15
15
|
s.email = "hayduke19us@gmail.com"
|
16
16
|
s.executables = ["old_style"]
|
@@ -26,10 +26,14 @@ Gem::Specification.new do |s|
|
|
26
26
|
"README.md",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
|
+
"app/assets/stylesheets/application.css",
|
29
30
|
"app/assets/stylesheets/fake3.css.scss",
|
30
31
|
"app/assets/stylesheets/fake4.css",
|
31
|
-
"app/views/fake/
|
32
|
+
"app/views/fake/fake1.html.erb",
|
32
33
|
"app/views/fake/fake2.html",
|
34
|
+
"app/views/layouts/application.html.erb",
|
35
|
+
"app/views/layouts/fake.html.erb",
|
36
|
+
"app/views/layouts/not_relevent.html.erb",
|
33
37
|
"base.css",
|
34
38
|
"bin/old_style",
|
35
39
|
"lib/format.rb",
|
@@ -41,6 +45,7 @@ Gem::Specification.new do |s|
|
|
41
45
|
"old_style/index.css",
|
42
46
|
"old_style/index.html",
|
43
47
|
"test/helper.rb",
|
48
|
+
"test/performance/bench_html_parser.rb",
|
44
49
|
"test/test_format.rb",
|
45
50
|
"test/test_html_parser.rb",
|
46
51
|
"test/test_load_dir.rb",
|
data/test/helper.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BenchKlass < Minitest::Benchmark
|
4
|
+
include HtmlParser
|
5
|
+
|
6
|
+
if ENV["BENCH"]
|
7
|
+
|
8
|
+
def setup
|
9
|
+
file = File.expand_path("../../../app", __FILE__)
|
10
|
+
@file = file + "/views/fake/fake.html.erb"
|
11
|
+
end
|
12
|
+
|
13
|
+
def bench_remove_extras
|
14
|
+
assert_performance_linear 0.99 do |n|
|
15
|
+
n.times do
|
16
|
+
remove_extras(@file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def bench_id_spike
|
22
|
+
assert_performance_linear 0.99 do |n|
|
23
|
+
n.times do
|
24
|
+
id_spike("#salinger", @file)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def bench_id_exists?
|
30
|
+
assert_performance_linear 0.99 do |n|
|
31
|
+
n.times do
|
32
|
+
id_exists?("#salinger", @file)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/test/test_format.rb
CHANGED
@@ -4,50 +4,25 @@ module Format
|
|
4
4
|
|
5
5
|
include Format
|
6
6
|
|
7
|
-
def
|
8
|
-
|
9
|
-
assert_equal File, new_or_open_index.class
|
7
|
+
def test_css_path
|
8
|
+
assert_equal Format::PATH + "/old_style/index.css", Format::CSS_PATH
|
10
9
|
end
|
11
10
|
|
12
|
-
def
|
13
|
-
|
14
|
-
assert File.exist?(Format::PATH + "/old_style/index.css")
|
11
|
+
def test_new_or_open_index_returns_file
|
12
|
+
assert_equal File, new_or_open_index.class
|
15
13
|
end
|
16
14
|
|
17
|
-
def
|
18
|
-
|
19
|
-
assert_equal nil, create_css_file?
|
15
|
+
def test_base_css_count_should_return_true
|
16
|
+
assert_equal true, base_css_count
|
20
17
|
end
|
21
18
|
|
22
|
-
def
|
23
|
-
|
19
|
+
def test_create_css_file_should_return_false
|
20
|
+
assert_equal false, create_css_file?
|
24
21
|
end
|
25
22
|
|
26
23
|
def test_base_css_file_exist
|
27
24
|
assert File.exists?("base.css")
|
28
25
|
end
|
29
|
-
|
30
|
-
def test_base_file_can_be_read
|
31
|
-
assert_equal 131, File.readlines("base.css").count
|
32
|
-
end
|
33
|
-
|
34
|
-
# the following two test are in sequence
|
35
|
-
# the first deletes the contents of the css file
|
36
|
-
# the next one adds the css to file
|
37
|
-
|
38
|
-
def test_index_css_is_empty
|
39
|
-
#deletes file contents by File.new ('w+')
|
40
|
-
file = File.new(css_path, 'w+')
|
41
|
-
assert_equal 0, File.readlines(file).count
|
42
|
-
file.close
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_file_index_css_has_lines
|
46
|
-
#write the css from base.css file in gem
|
47
|
-
write_css
|
48
|
-
assert_equal 131, File.readlines(css_path).count
|
49
|
-
end
|
50
|
-
|
51
26
|
end
|
52
27
|
|
53
28
|
end
|
data/test/test_html_parser.rb
CHANGED
@@ -4,11 +4,7 @@ class KlassTest < Minitest::Test
|
|
4
4
|
include HtmlParser
|
5
5
|
|
6
6
|
def setup
|
7
|
-
@file = File.expand_path("../../app", __FILE__) + "/views/fake/
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_read_html_should_put_document_into_an_array
|
11
|
-
refute read_html(@file).empty?
|
7
|
+
@file = File.expand_path("../../app", __FILE__) + "/views/fake/fake1.html.erb"
|
12
8
|
end
|
13
9
|
|
14
10
|
def test_remove_extras_should_remove_all_punctuation_and_whitespace
|
@@ -64,4 +60,8 @@ class KlassTest < Minitest::Test
|
|
64
60
|
assert_equal true, id_exists?("#test-id", @file)
|
65
61
|
end
|
66
62
|
|
63
|
+
def test_id_spike
|
64
|
+
skip
|
65
|
+
end
|
66
|
+
|
67
67
|
end
|
data/test/test_load_dir.rb
CHANGED
@@ -22,7 +22,10 @@ class LoadDirTest < MiniTest::Test
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_html_files_attribute_is_populated_after_initialization
|
25
|
-
|
25
|
+
#4 html files including layouts
|
26
|
+
#3 css files
|
27
|
+
assert_equal 7, @load_dir.files.keys.count
|
26
28
|
end
|
27
29
|
|
28
30
|
end
|
31
|
+
|
data/test/test_parse_dir.rb
CHANGED
@@ -40,21 +40,21 @@ class ParseDirTest < MiniTest::Test
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_ParseDir#segregate_puts_html_files_in_an_array
|
43
|
-
assert_equal
|
43
|
+
assert_equal 4, @parse.html.count
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_parse_css_returns_hash_of_all_selectors_no_comments_no_SASS
|
47
|
-
assert_equal
|
47
|
+
assert_equal 8, @parse.parse_css.keys.count
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_parse_css_keys_content
|
51
|
-
a = ["#salinger", "#find", "div.well",
|
51
|
+
a = [".row", "#salinger", "#find", "div.well",
|
52
52
|
".franny", "#franny", ".zooey", "#test-id"]
|
53
53
|
assert_equal a, @parse.parse_css.keys
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_found_css_finds_the_relevent_css
|
57
|
-
assert_equal
|
57
|
+
assert_equal 5, @parse.found.keys.count
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_empty_css_returns_a_hash_of_false_selectors
|
@@ -66,7 +66,7 @@ class ParseDirTest < MiniTest::Test
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_good_percent
|
69
|
-
assert_equal "
|
69
|
+
assert_equal "62.5%", @parse.good_percent
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_success_message_if_Format#write_index_is_true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: old_style
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hayduke19us
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: css_parser
|
@@ -111,10 +111,14 @@ files:
|
|
111
111
|
- README.md
|
112
112
|
- Rakefile
|
113
113
|
- VERSION
|
114
|
+
- app/assets/stylesheets/application.css
|
114
115
|
- app/assets/stylesheets/fake3.css.scss
|
115
116
|
- app/assets/stylesheets/fake4.css
|
116
|
-
- app/views/fake/
|
117
|
+
- app/views/fake/fake1.html.erb
|
117
118
|
- app/views/fake/fake2.html
|
119
|
+
- app/views/layouts/application.html.erb
|
120
|
+
- app/views/layouts/fake.html.erb
|
121
|
+
- app/views/layouts/not_relevent.html.erb
|
118
122
|
- base.css
|
119
123
|
- bin/old_style
|
120
124
|
- lib/format.rb
|
@@ -126,6 +130,7 @@ files:
|
|
126
130
|
- old_style/index.css
|
127
131
|
- old_style/index.html
|
128
132
|
- test/helper.rb
|
133
|
+
- test/performance/bench_html_parser.rb
|
129
134
|
- test/test_format.rb
|
130
135
|
- test/test_html_parser.rb
|
131
136
|
- test/test_load_dir.rb
|