tsscssd 0.0.1 → 0.0.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.
- data/lib/tsscssd/version.rb +1 -1
- data/lib/tsscssd.rb +109 -3
- metadata +2 -2
data/lib/tsscssd/version.rb
CHANGED
data/lib/tsscssd.rb
CHANGED
@@ -1,9 +1,115 @@
|
|
1
1
|
require "tsscssd/version"
|
2
|
-
|
3
2
|
module Tsscssd
|
3
|
+
|
4
|
+
LIB = File.dirname(__FILE__)
|
5
|
+
|
6
|
+
autoload :Runner, File.join(LIB, 'tsscssd/runner')
|
7
|
+
autoload :Builder, File.join(LIB, 'tsscssd/builder')
|
8
|
+
|
9
|
+
def self.run!(input, config = {}, &block)
|
10
|
+
Runner.new(input, config).run!(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :appname
|
15
|
+
attr_accessor :stylesheets
|
16
|
+
attr_accessor :output
|
17
|
+
end
|
18
|
+
|
4
19
|
class StyleGuide
|
5
|
-
def
|
6
|
-
|
20
|
+
def initialize
|
21
|
+
@files = []
|
22
|
+
end
|
23
|
+
def files
|
24
|
+
@files
|
25
|
+
end
|
26
|
+
def addFile(file)
|
27
|
+
cssFile = Tsscssd::CssFile.new(file)
|
28
|
+
@files.push(cssFile)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class CssFile
|
33
|
+
def initialize(fileName)
|
34
|
+
@fileName = fileName
|
35
|
+
fn = fileName.split('/')
|
36
|
+
fn = fn[fn.length-1]
|
37
|
+
fn = fn.split('.')[0]
|
38
|
+
@prettyName = fn
|
39
|
+
@header = []
|
40
|
+
@imports = []
|
41
|
+
@comments = []
|
42
|
+
@lineNumber = 0
|
43
|
+
@inComment = false
|
44
|
+
@comment = ''
|
45
|
+
parseFile
|
46
|
+
end
|
47
|
+
def fileName
|
48
|
+
@fileName
|
49
|
+
end
|
50
|
+
def prettyName
|
51
|
+
@prettyName
|
52
|
+
end
|
53
|
+
def header
|
54
|
+
@header
|
55
|
+
end
|
56
|
+
def imports
|
57
|
+
@imports
|
58
|
+
end
|
59
|
+
def imports?
|
60
|
+
@imports.length > 0 ? true : false
|
61
|
+
end
|
62
|
+
def comments
|
63
|
+
@comments
|
64
|
+
end
|
65
|
+
def comments?
|
66
|
+
@comments.length > 0 ? true : false
|
67
|
+
end
|
68
|
+
def parseFile
|
69
|
+
File.open(fileName) do |file|
|
70
|
+
while @line = file.gets
|
71
|
+
@lineNumber = @lineNumber + 1
|
72
|
+
if @line
|
73
|
+
@line = @line.chomp
|
74
|
+
@words = @line.split
|
75
|
+
case @words[0]
|
76
|
+
when '/*'
|
77
|
+
#Begin the header comments. May need this for later.
|
78
|
+
when '*'
|
79
|
+
#puts 'Header Comment'
|
80
|
+
headerComment = @line.split('*')
|
81
|
+
value = @line.split('- ')
|
82
|
+
value = value[value.length-1]
|
83
|
+
key = headerComment[1].split[0]
|
84
|
+
@header.push({key:key, value:value})
|
85
|
+
when '*/'
|
86
|
+
#End header comments. May need this for later.
|
87
|
+
when '@import' # Collect those imports!
|
88
|
+
#puts 'In imports | ' + @words[1].split("'")[1]
|
89
|
+
@imports.push(@words[1].split("'")[1])
|
90
|
+
when '//' #ID the comment. Mark as inComment for the next pass to grab the right hand side.
|
91
|
+
#puts 'Inline Comment'
|
92
|
+
if @inComment == false
|
93
|
+
@inComment = true
|
94
|
+
@comment = @line.split('// ')
|
95
|
+
@comment = @comment.join.chomp
|
96
|
+
end
|
97
|
+
else
|
98
|
+
if @inComment == true # grab the selector/variable for the comment we have ID'ed
|
99
|
+
if @line[0] == '$'
|
100
|
+
@line = @line.split(':')[0]
|
101
|
+
elsif @line.split('{')[0].length < 2
|
102
|
+
@line = @line.chomp(' {')
|
103
|
+
else
|
104
|
+
@line = @line.split('{')[0]
|
105
|
+
end
|
106
|
+
@comments.push({lineNumber:@lineNumber,selector:@line,comment:@comment})
|
107
|
+
@inComment = false
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
7
113
|
end
|
8
114
|
end
|
9
115
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsscssd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|