kss 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -65,7 +65,7 @@ The library is also fully TomDoc'd, completing the circle of life.
65
65
  The documenting syntax and ruby library are intended to generate styleguides automatically. To do this, you'll need to leverage a small javascript library that generates class styles for pseudo-class styles (`:hover`, `:disabled`, etc).
66
66
 
67
67
  * [kss.coffee](https://github.com/kneath/kss/blob/master/lib/kss.coffee)
68
- * [kss.js](https://github.com/kneath/kss/blob/master/lib/kss.js) (compiled js)
68
+ * [kss.js](https://github.com/kneath/kss/blob/master/example/public/javascripts/kss.js) (compiled js)
69
69
 
70
70
  For an example of how to generate a styleguide, check out the [`example`](https://github.com/kneath/kss/tree/master/example) sinatra application.
71
71
 
@@ -75,4 +75,4 @@ To hack on KSS, you'll need to install dependencies with `bundle install`. Run t
75
75
 
76
76
  To make your life easier, I suggest `bundle install --binstubs` and adding `bin/` to your `$PATH`. If you don't understand this, just blindly add `bundle exec` in front of everything you'd normally do, like `bundle exec rake`.
77
77
 
78
- I apologize on behalf of the Ruby community for this, it's embarrassing and disappointing that dependency management is still so clumsy.
78
+ I apologize on behalf of the Ruby community for this, it's embarrassing and disappointing that dependency management is still so clumsy.
@@ -1,7 +1,7 @@
1
1
  # This class scans your stylesheets for pseudo classes, then inserts a new CSS
2
2
  # rule with the same properties, but named 'psuedo-class-{{name}}'.
3
3
  #
4
- # Supported pseudo classes: hover, disabled, active, visited.
4
+ # Supported pseudo classes: hover, disabled, active, visited, focus.
5
5
  #
6
6
  # Example:
7
7
  #
@@ -9,15 +9,15 @@
9
9
  # => a.pseudo-class-hover{ color:blue; }
10
10
  class KssStateGenerator
11
11
  constructor: ->
12
- pseudos = /(\:hover|\:disabled|\:active|\:visited)/g
12
+ pseudos = /(\:hover|\:disabled|\:active|\:visited|\:focus)/g
13
13
 
14
14
  try
15
15
  for stylesheet in document.styleSheets
16
16
  idxs = []
17
17
  for rule, idx in stylesheet.cssRules
18
- if (rule.type == CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)
18
+ while (rule.type == CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)
19
19
  replaceRule = (matched, stuff) ->
20
- return ".pseudo-class-" + matched.replace(':', '')
20
+ return matched.replace(/\:/g, '.pseudo-class-')
21
21
  @insertRule(rule.cssText.replace(pseudos, replaceRule))
22
22
 
23
23
  # Takes a given style and attaches it to the current page.
@@ -36,4 +36,4 @@ class KssStateGenerator
36
36
 
37
37
  headEl.appendChild(styleEl)
38
38
 
39
- new KssStateGenerator
39
+ new KssStateGenerator
@@ -10,14 +10,16 @@ module Kss
10
10
  # within the directory recursively for any comment blocks that look like
11
11
  # KSS.
12
12
  #
13
- # base_path - The path String where style files are located.
14
- def initialize(base_path)
13
+ # paths - Each path String where style files are located.
14
+ def initialize(*paths)
15
15
  @sections = {}
16
16
 
17
- Dir["#{base_path}/**/*.*"].each do |filename|
18
- parser = CommentParser.new(filename)
19
- parser.blocks.each do |comment_block|
20
- add_section comment_block, filename if self.class.kss_block?(comment_block)
17
+ paths.each do |path|
18
+ Dir["#{path}/**/*.*"].each do |filename|
19
+ parser = CommentParser.new(filename)
20
+ parser.blocks.each do |comment_block|
21
+ add_section comment_block, filename if self.class.kss_block?(comment_block)
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -34,12 +34,8 @@ module Kss
34
34
  def section
35
35
  return @section unless @section.nil?
36
36
 
37
- comment_sections.each do |text|
38
- if text =~ /Styleguide \d/i
39
- cleaned = text.strip.sub(/\.$/, '') # Kill trailing period
40
- @section = cleaned.match(/Styleguide (.+)/)[1]
41
- end
42
- end
37
+ cleaned = section_comment.strip.sub(/\.$/, '') # Kill trailing period
38
+ @section = cleaned.match(/Styleguide (.+)/)[1]
43
39
 
44
40
  @section
45
41
  end
@@ -48,7 +44,10 @@ module Kss
48
44
  #
49
45
  # Returns the description String.
50
46
  def description
51
- comment_sections.first
47
+ comment_sections.reject do |section|
48
+ section == section_comment ||
49
+ section == modifiers_comment
50
+ end.join("\n\n")
52
51
  end
53
52
 
54
53
  # Public: The modifiers section of a styleguide comment block.
@@ -57,9 +56,10 @@ module Kss
57
56
  def modifiers
58
57
  last_indent = nil
59
58
  modifiers = []
60
- return modifiers unless comment_sections[1]
61
59
 
62
- comment_sections[1].split("\n").each do |line|
60
+ return modifiers unless modifiers_comment
61
+
62
+ modifiers_comment.split("\n").each do |line|
63
63
  next if line.strip.empty?
64
64
  indent = line.scan(/^\s*/)[0].to_s.size
65
65
 
@@ -76,5 +76,18 @@ module Kss
76
76
  modifiers
77
77
  end
78
78
 
79
+ private
80
+
81
+ def section_comment
82
+ comment_sections.find do |text|
83
+ text =~ /Styleguide \d/i
84
+ end.to_s
85
+ end
86
+
87
+ def modifiers_comment
88
+ comment_sections[1..-1].reject do |section|
89
+ section == section_comment
90
+ end.last
91
+ end
79
92
  end
80
93
  end
@@ -1,3 +1,3 @@
1
1
  module Kss
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -7,6 +7,7 @@ class ParserTest < Kss::Test
7
7
  @sass_parsed = Kss::Parser.new('test/fixtures/sass')
8
8
  @css_parsed = Kss::Parser.new('test/fixtures/css')
9
9
  @less_parsed = Kss::Parser.new('test/fixtures/less')
10
+ @multiple_parsed = Kss::Parser.new('test/fixtures/scss', 'test/fixtures/less')
10
11
 
11
12
  @css_comment = <<comment
12
13
  /*
@@ -104,4 +105,8 @@ comment
104
105
  assert_equal 2, @css_parsed.sections.count
105
106
  end
106
107
 
108
+ test "parse multiple paths" do
109
+ assert_equal 6, @multiple_parsed.sections.count
110
+ end
111
+
107
112
  end
@@ -4,6 +4,8 @@ class SectionTest < Kss::Test
4
4
 
5
5
  def setup
6
6
  @comment_text = <<comment
7
+ # Form Button
8
+
7
9
  Your standard form button.
8
10
 
9
11
  :hover - Highlights when hovering.
@@ -18,7 +20,7 @@ comment
18
20
  end
19
21
 
20
22
  test "parses the description" do
21
- assert_equal "Your standard form button.", @section.description
23
+ assert_equal "# Form Button\n\nYour standard form button.", @section.description
22
24
  end
23
25
 
24
26
  test "parses the modifiers" do
@@ -37,4 +39,4 @@ comment
37
39
  assert_equal '2.1.1', @section.section
38
40
  end
39
41
 
40
- end
42
+ end
metadata CHANGED
@@ -1,33 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: kss
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Kyle Neath
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-02-06 00:00:00 -08:00
19
- default_executable:
12
+ date: 2012-08-02 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: " Inspired by TomDoc, KSS attempts to provide a methodology for writing\n maintainable, documented CSS within a team. Specifically, KSS is a CSS\n structure, documentation specification, and styleguide format.\n\n This is a ruby library for parsing KSS documented CSS and generating\n styleguides.\n"
14
+ description: ! " Inspired by TomDoc, KSS attempts to provide a methodology for writing\n
15
+ \ maintainable, documented CSS within a team. Specifically, KSS is a CSS\n structure,
16
+ documentation specification, and styleguide format.\n\n This is a ruby library
17
+ for parsing KSS documented CSS and generating\n styleguides.\n"
23
18
  email: kneath@gmail.com
24
19
  executables: []
25
-
26
20
  extensions: []
27
-
28
21
  extra_rdoc_files: []
29
-
30
- files:
22
+ files:
31
23
  - README.md
32
24
  - Rakefile
33
25
  - LICENSE
@@ -52,39 +44,28 @@ files:
52
44
  - test/helper.rb
53
45
  - test/parser_test.rb
54
46
  - test/section_test.rb
55
- has_rdoc: true
56
47
  homepage: http://github.com/kneath/kss
57
48
  licenses: []
58
-
59
49
  post_install_message:
60
50
  rdoc_options: []
61
-
62
- require_paths:
51
+ require_paths:
63
52
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
53
+ required_ruby_version: !ruby/object:Gem::Requirement
65
54
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- hash: 3
70
- segments:
71
- - 0
72
- version: "0"
73
- required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
60
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- hash: 3
79
- segments:
80
- - 0
81
- version: "0"
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
82
65
  requirements: []
83
-
84
66
  rubyforge_project:
85
- rubygems_version: 1.6.2
67
+ rubygems_version: 1.8.23
86
68
  signing_key:
87
69
  specification_version: 3
88
70
  summary: A library for parsing KSS documented stylesheets and generating styleguides
89
71
  test_files: []
90
-