css-native 0.1.3 → 0.2.0
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/bin/css-native +37 -0
- data/lib/css-native.rb +13 -13
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee87dca577f0bc699626f6414e47162717c6215b5f0e26c9a44e2d0aa85201ee
|
4
|
+
data.tar.gz: 2afa0bed4ccba889f5145944363044afbb51c0f240af6b9aff29a0cf2d1258cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2242eea7b30e95ffadd3c15e4cd3bdbfac4011a5cc8615624bc18b9c5c565e9b0d4604bbc3590943912718e667629f5c5e33cc75f7e06af740b086f3a9318394
|
7
|
+
data.tar.gz: dc1e2f00d377288fb735ea25fcf3520ea2f6fba1f8261042277126a28c5e1e33cd42dd99f4e8012d8fd6b5f156382283f31fb0dc8ec3439c05eb1f073c4fe22e
|
data/bin/css-native
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
require "css-native"
|
4
|
+
require "optparse"
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
exit if ARGV.empty?
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.define("--output FILE", "-o FILE", "Write output to FILE")
|
12
|
+
end.parse!(into: options)
|
13
|
+
|
14
|
+
if ARGV.empty?
|
15
|
+
puts "No css-native files provided"
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
output = []
|
20
|
+
|
21
|
+
ARGV.each do |file_name|
|
22
|
+
File.open(file_name, "r") do |file|
|
23
|
+
contents = file.read
|
24
|
+
sheet = CSSNative.stylesheet do
|
25
|
+
eval(contents)
|
26
|
+
end
|
27
|
+
output << "/*---#{file_name}---*/\n" + sheet.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if options[:output].nil?
|
32
|
+
puts output.join("\n")
|
33
|
+
else
|
34
|
+
File.open(options[:output], "w") do |file|
|
35
|
+
file.puts output.join("\n")
|
36
|
+
end
|
37
|
+
end
|
data/lib/css-native.rb
CHANGED
@@ -14,37 +14,37 @@ class CSSNative
|
|
14
14
|
@rules = []
|
15
15
|
end
|
16
16
|
|
17
|
-
def element(name)
|
18
|
-
Rule.new(self).with_element(name)
|
17
|
+
def element(name, &block)
|
18
|
+
Rule.new(self).with_element(name, &block)
|
19
19
|
end
|
20
20
|
|
21
21
|
alias_method :klass, :class
|
22
|
-
def class(name = nil)
|
22
|
+
def class(name = nil, &block)
|
23
23
|
if name.nil?
|
24
24
|
klass
|
25
25
|
else
|
26
|
-
Rule.new(self).with_class(name)
|
26
|
+
Rule.new(self).with_class(name, &block)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def id(name)
|
31
|
-
Rule.new(self).with_id(name)
|
30
|
+
def id(name, &block)
|
31
|
+
Rule.new(self).with_id(name, &block)
|
32
32
|
end
|
33
33
|
|
34
|
-
def attribute(name, operation = :none, value = nil, case_sensitive: true)
|
35
|
-
Rule.new(self).with_attribute(name, operation, value, case_sensitive: case_sensitive)
|
34
|
+
def attribute(name, operation = :none, value = nil, case_sensitive: true, &block)
|
35
|
+
Rule.new(self).with_attribute(name, operation, value, case_sensitive: case_sensitive, &block)
|
36
36
|
end
|
37
37
|
|
38
|
-
def select(name, *args, type: :element)
|
38
|
+
def select(name, *args, type: :element, &block)
|
39
39
|
case type
|
40
40
|
when :element
|
41
|
-
Rule.new(self).with(name)
|
41
|
+
Rule.new(self).with(name, &block)
|
42
42
|
when :class
|
43
|
-
self.class(name)
|
43
|
+
self.class(name, &block)
|
44
44
|
when :id
|
45
|
-
id(name)
|
45
|
+
id(name, &block)
|
46
46
|
when :attribute
|
47
|
-
attribute(name, *args)
|
47
|
+
attribute(name, *args, &block)
|
48
48
|
else
|
49
49
|
raise RuleError.new(rule: type)
|
50
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css-native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kellen Watt
|
@@ -13,10 +13,12 @@ dependencies: []
|
|
13
13
|
description: A CSS generator designed to make writing CSS-compatible code cleaner
|
14
14
|
and easier to undestand
|
15
15
|
email:
|
16
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- css-native
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
21
|
+
- bin/css-native
|
20
22
|
- lib/css-native.rb
|
21
23
|
- lib/css-native/errors.rb
|
22
24
|
- lib/css-native/rule.rb
|