kss 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -53,7 +53,7 @@ styleguide.section('2.1.1').modifiers.first.name
53
53
  styleguide.section('2.1.1').modifiers.first.class_name
54
54
  # => 'pseudo-class-hover'
55
55
 
56
- styleguide.section('2.1.1').modifiers.first.first.description
56
+ styleguide.section('2.1.1').modifiers.first.description
57
57
  # => 'Subtle hover highlight'
58
58
 
59
59
  ```
@@ -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.
4
+ # Supported pseudo classes: hover, disabled, active, visited.
5
5
  #
6
6
  # Example:
7
7
  #
@@ -9,15 +9,16 @@
9
9
  # => a.pseudo-class-hover{ color:blue; }
10
10
  class KssStateGenerator
11
11
  constructor: ->
12
- hover = /:hover/
13
- disabled = /:disabled/
12
+ pseudos = /(\:hover|\:disabled|\:active|\:visited)/g
14
13
 
15
14
  try
16
15
  for stylesheet in document.styleSheets
17
16
  idxs = []
18
17
  for rule, idx in stylesheet.cssRules
19
- if rule.type is CSSRule.STYLE_RULE and (hover.test(rule.selectorText) or disabled.test(rule.selectorText))
20
- @insertRule(rule.cssText.replace(':', '.pseudo-class-'))
18
+ if (rule.type == CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)
19
+ replaceRule = (matched, stuff) ->
20
+ return ".pseudo-class-" + matched.replace(':', '')
21
+ @insertRule(rule.cssText.replace(pseudos, replaceRule))
21
22
 
22
23
  # Takes a given style and attaches it to the current page.
23
24
  #
@@ -29,7 +29,7 @@ module Kss
29
29
  #
30
30
  # Returns a CSS class String.
31
31
  def class_name
32
- name.sub('.', ' ').sub(':', ' pseudo-class-').strip
32
+ name.gsub('.', ' ').gsub(':', ' pseudo-class-').strip
33
33
  end
34
34
 
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Kss
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kss
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kyle Neath
@@ -15,10 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-07 00:00:00 -08:00
18
+ date: 2011-12-10 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ name: sass
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
@@ -31,7 +32,6 @@ dependencies:
31
32
  - 1
32
33
  version: "3.1"
33
34
  type: :runtime
34
- name: sass
35
35
  version_requirements: *id001
36
36
  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"
37
37
  email: kneath@gmail.com