talius 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -23
  3. data/lib/talius.rb +7 -4
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c923ee36c973d0f95514ccd29ed7d6b5181e55614c376817ff2c7cdbe4ac8291
4
- data.tar.gz: 82037c3e6161cec2b6b7999542c0a112b1ac6de9f2329833de9dbdd3323da6d6
3
+ metadata.gz: a624abc2cf8fd531e97d5fd08b205828f8732e99b9f0762eb001ec8f385c72b8
4
+ data.tar.gz: c1fdd7ddc052826b5cbebbd60734cd584cdfe781312b055491981bf6210ce33e
5
5
  SHA512:
6
- metadata.gz: ea1038d7afd52feff046aab805f225cc72cc05f1a17912b483986ce29c80fb2bab171953837783827ecc32efe890af9d723278100996b2f65f4185f809ceaac2
7
- data.tar.gz: ec31c961daf6e5d2f80e456b903fadf2130749fd672e34cf41594fac16c3664b4f28749331d3c2e3917ca9ada5ad86877a8e6565e98831e48838946313398d1c
6
+ metadata.gz: 0a0586aaf72b6a6d586f8d9b398591a7ea28beba7428e8d5842e9d28afec30625a54d963bc2abb6967532e8956b3ee44b2dd2b14a3d47136391114ef07fa7ec3
7
+ data.tar.gz: 52df1eb542940556683a97ada06165ce733874e4ce1fa661a5b4747b4efe2c12310609e5e2d274cff924ff254a8e2835e0a8098c900d7019ecb74423b60c0866
data/README.md CHANGED
@@ -10,25 +10,12 @@ selector.
10
10
  In this example, the selector consists of just `a`, meaning it selects
11
11
  `<a>` tags:
12
12
 
13
- <table>
14
- <tr>
15
- <td class='right'>
16
- <pre>1
17
- 2
18
- 3
19
- 4
20
- </pre>
21
- </td>
22
- <td>
23
- <pre>
13
+ ```ruby {.line-numbers}
24
14
  raw = 'a'
25
15
  selector = Talius.new(raw)
26
16
  rule = selector.rules[0]
27
17
  rule.tags # => {"a"=>{"name"=>"a"}}
28
- </pre>
29
- </td>
30
- </tr>
31
- </table>
18
+ ```
32
19
 
33
20
  Line 1 creates the raw CSS selector like you might find in a CSS file. Line 2
34
21
  creates a `Talius` object.
@@ -47,7 +34,7 @@ are detailed below.
47
34
  If a selector contains a tag name, that information will be put into the
48
35
  `tags` hash of the rule. Consider this example.
49
36
 
50
- ```ruby
37
+ ```ruby
51
38
  raw = 'a'
52
39
  selector = Talius.new(raw)
53
40
  rule = selector.rules[0]
@@ -68,7 +55,7 @@ followed by the name of the tag. For example, the following code has a selector
68
55
  for tags in the `mml` namespace with the name `a`. The keys in the `tags` hash
69
56
  are formatted in the same way.
70
57
 
71
- ```ruby
58
+ ```ruby
72
59
  raw = 'mml|a'
73
60
  selector = Talius.new(raw)
74
61
  rule = selector.rules[0]
@@ -84,7 +71,7 @@ For multiple rules for a selector, separate the rules with a comma. For example,
84
71
  the following code parses a selector with two rules, one for the `section` tag
85
72
  and one for the `div` tag.
86
73
 
87
- ```ruby
74
+ ```ruby
88
75
  raw = 'section, div'
89
76
  selector = Talius.new(raw)
90
77
  selector.rules.length # => 2
@@ -96,7 +83,7 @@ selector.rules # => [{"tags"=>{"section"=>{"name"=>"section"}}}, {"tags"=>{"div"
96
83
  If any ID descriptions are given, those IDs can be found in the rule's `ids`
97
84
  hash. The keys are the names of the IDs, the values are always `true`.
98
85
 
99
- ```ruby
86
+ ```ruby
100
87
  raw = '#overview'
101
88
  selector = Talius.new(raw)
102
89
  rule = selector.rules[0]
@@ -108,7 +95,7 @@ rule.ids # => {"overview"=>true}
108
95
  Classes are available in the `classes` property of the rule. `classes` is a
109
96
  simple hash in which the value of each class is true.
110
97
 
111
- ```ruby
98
+ ```ruby
112
99
  raw = 'section.overview.current'
113
100
  selector = Talius.new(raw)
114
101
  rule = selector.rules[0]
@@ -122,7 +109,7 @@ key of each attribute and a `Talius::Node::Att` object.
122
109
 
123
110
  In this simple example, the selector looks for tags with an `rel` attribute.
124
111
 
125
- ```ruby
112
+ ```ruby
126
113
  raw = '[rel]'
127
114
  selector = Talius.new(raw)
128
115
  rule = selector.rules[0]
@@ -133,7 +120,7 @@ att.name # => rel
133
120
 
134
121
  If you assign a value to the attribute, that value will be in `value` property.
135
122
 
136
- ```ruby
123
+ ```ruby
137
124
  raw = '[rel=license]'
138
125
  selector = Talius.new(raw)
139
126
  rule = selector.rules[0]
@@ -145,7 +132,7 @@ att.value # => license
145
132
  Attribute namespaces are indicated in the same way as with tags. You can access
146
133
  the namespace with the `namespace` property.
147
134
 
148
- ```ruby
135
+ ```ruby
149
136
  raw = '[mml|rel]'
150
137
  selector = Talius.new(raw)
151
138
  rule = selector.rules[0]
@@ -154,6 +141,14 @@ att.name # => rel
154
141
  att.namespace # => mml
155
142
  ```
156
143
 
144
+ ## Not implemented
145
+
146
+ There are a few aspects of CSS selectors that have not yet been implemented.
147
+
148
+ * Combinators are not parsed.
149
+ * The `:not()` pseudo-class is not understood.
150
+
151
+
157
152
  ## Install
158
153
 
159
154
  ``
@@ -6,9 +6,8 @@ require 'lx'
6
6
 
7
7
  # A +Talius+ object represents a full CSS selector.
8
8
  class Talius
9
- # version '0.5'
10
- VERSION = '0.5'
11
-
9
+ # version '0.6'
10
+ VERSION = '0.6'
12
11
 
13
12
  # An array of rule objects.
14
13
  attr_reader :rules
@@ -551,6 +550,9 @@ class Talius::Node
551
550
 
552
551
 
553
552
  #---------------------------------------------------------------------------
553
+ # namespace
554
+ #
555
+
554
556
  # The node's namespace. If a namespace is not explicitly given in the
555
557
  # selector string then this property is nil.
556
558
  #
@@ -684,6 +686,7 @@ class Talius::Node::Att < Talius::Node
684
686
  #---------------------------------------------------------------------------
685
687
  # initialize
686
688
  #
689
+
687
690
  def initialize(*opts)
688
691
  super(*opts)
689
692
  @value = nil
@@ -716,7 +719,7 @@ class Talius::Node::Att < Talius::Node
716
719
  # to_h
717
720
  #
718
721
 
719
- # Returns a hash representation of the obect.
722
+ # Returns a hash representation of the object.
720
723
  def to_h
721
724
  rv = super()
722
725
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talius
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike O'Sullivan