milk1000cc-tiny_css 0.0.2 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/README +0 -62
- data/lib/.DS_Store +0 -0
- data/lib/tiny_css/ordered_hash.rb +0 -6
- data/spec/base_spec.rb +0 -30
- data/spec/ordered_hash_spec.rb +0 -58
- data/tiny_css.gemspec +3 -3
- metadata +4 -3
- data/spec/spec.opts +0 -4
data/.DS_Store
ADDED
Binary file
|
data/README
CHANGED
@@ -1,62 +0,0 @@
|
|
1
|
-
TinyCss
|
2
|
-
=======
|
3
|
-
|
4
|
-
a ruby module to read and write .css stylesheets
|
5
|
-
|
6
|
-
|
7
|
-
Usage
|
8
|
-
=====
|
9
|
-
|
10
|
-
# In your .css file
|
11
|
-
H1 { color: blue }
|
12
|
-
H2 { color: red; font-family: Arial }
|
13
|
-
.this, .that { color: yellow }
|
14
|
-
|
15
|
-
# In your program
|
16
|
-
require 'tiny_css'
|
17
|
-
|
18
|
-
# Create a CSS stylesheet
|
19
|
-
css = TinyCss.new
|
20
|
-
|
21
|
-
# Open a CSS stylesheet
|
22
|
-
css = css.read('style.css')
|
23
|
-
|
24
|
-
# Reading properties
|
25
|
-
# (key is coverted to string, so you can access same value by symbol)
|
26
|
-
header_color = css.style['h1']['color']
|
27
|
-
css.style['h2'].each { |property, value| p "#{ property }: #{ value }" }
|
28
|
-
this_color = css.style[:this][:color]
|
29
|
-
that_color = css.style[:that][:color]
|
30
|
-
|
31
|
-
# Changing styles and properties
|
32
|
-
css.style['.newstyle']['color'] = '#FFFFFF' # Add a style
|
33
|
-
css.style['h1']['color'] = 'black' # Change a property
|
34
|
-
css.style['h2'].delete # Delete a style
|
35
|
-
|
36
|
-
# Save a CSS stylesheet
|
37
|
-
css.write 'style.css' # Sort selectors and properties
|
38
|
-
css.write 'style.css', false # Don't sort
|
39
|
-
|
40
|
-
|
41
|
-
Install
|
42
|
-
=======
|
43
|
-
|
44
|
-
git clone git://github.com/milk1000cc/tiny_css.git
|
45
|
-
|
46
|
-
or
|
47
|
-
|
48
|
-
sudo gem install milk1000cc-tiny_css --source=http://gems.github.com
|
49
|
-
|
50
|
-
|
51
|
-
Caution
|
52
|
-
=======
|
53
|
-
|
54
|
-
TinyCss#style doesn't return Hash object but TinyCss::OrderedHash, and TinyCss::OrderedHash class doesn't inherit Hash object.
|
55
|
-
|
56
|
-
I'm Japanese, and I'm not goot at English and Ruby, so please see the source code and edit them.
|
57
|
-
|
58
|
-
|
59
|
-
Author
|
60
|
-
======
|
61
|
-
|
62
|
-
milk1000cc <info@milk1000.cc>
|
data/lib/.DS_Store
ADDED
Binary file
|
data/spec/base_spec.rb
CHANGED
@@ -1,36 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../lib/tiny_css'
|
2
2
|
include TinyCss
|
3
3
|
|
4
|
-
describe Base, '削除に関して' do
|
5
|
-
before do
|
6
|
-
@css = TinyCss.new.read_string('h1, p { color: red; background: blue; }')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'セレクタを削除したら、style.keys にそのセレクタが含まれていないこと' do
|
10
|
-
@css.style.keys.should include('h1')
|
11
|
-
@css.style.delete 'h1'
|
12
|
-
@css.style.keys.should_not include('h1')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'セレクタを削除したら、write_string の結果にもそのセレクタが含まれていないこと' do
|
16
|
-
@css.style.delete 'h1'
|
17
|
-
@css.write_string.should == "p {\n\tbackground: blue;\n\tcolor: red;\n}\n"
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'プロパティを削除したら、style[セレクタ].keys にそのプロパティが' +
|
21
|
-
'含まれていないこと' do
|
22
|
-
@css.style['h1'].keys.should include('color')
|
23
|
-
@css.style['h1'].delete 'color'
|
24
|
-
@css.style['h1'].keys.should_not include('color')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'プロパティを削除したら、write_string の結果にも反映されていること' do
|
28
|
-
@css.style['h1'].delete 'color'
|
29
|
-
@css.write_string.should == "p {\n\tbackground: blue;\n\tcolor: red;\n}\n" +
|
30
|
-
"h1 {\n\tbackground: blue;\n}\n"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
4
|
describe Base, 'CSS 文字列を指定してパースするとき' do
|
35
5
|
before do
|
36
6
|
@css1 = TinyCss.new.read_string('h3 { color: red; }')
|
data/spec/ordered_hash_spec.rb
CHANGED
@@ -62,64 +62,6 @@ describe OrderedHash, '#dup について' do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
describe OrderedHash, '#delete について' do
|
66
|
-
before(:each) do
|
67
|
-
@oh = OrderedHash.new
|
68
|
-
@oh['foo'] = 3
|
69
|
-
end
|
70
|
-
|
71
|
-
it '存在するキーに対する関連を取り除いた場合は、取り除かれた値を返すこと' do
|
72
|
-
result = @oh.delete('foo')
|
73
|
-
result.should == 3
|
74
|
-
end
|
75
|
-
|
76
|
-
it '存在するキーに対する関連を取り除いた場合は、取り除かれた値を返すこと' +
|
77
|
-
'(シンボルでキーを指定した場合も)' do
|
78
|
-
result = @oh.delete(:foo)
|
79
|
-
result.should == 3
|
80
|
-
end
|
81
|
-
|
82
|
-
it '存在するキーに対する関連を取り除いた場合は、keys からそのキーがなくなっていること' do
|
83
|
-
@oh.keys.should include('foo')
|
84
|
-
@oh.delete 'foo'
|
85
|
-
@oh.keys.should_not include('foo')
|
86
|
-
end
|
87
|
-
|
88
|
-
it '存在するキーに対する関連を取り除いた場合は、keys からそのキーがなくなっていること' +
|
89
|
-
'(シンボルでキーを指定した場合も)' do
|
90
|
-
@oh.keys.should include('foo')
|
91
|
-
@oh.delete :foo
|
92
|
-
@oh.keys.should_not include('foo')
|
93
|
-
end
|
94
|
-
|
95
|
-
it '存在しないキーを指定された場合は、nil が返ること' do
|
96
|
-
result = @oh.delete('none')
|
97
|
-
result.should == nil
|
98
|
-
|
99
|
-
result = @oh.delete(:none)
|
100
|
-
result.should be_nil
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'ブロックが与えられたときは、key にマッチするものがなかった時に評価して、' +
|
104
|
-
'その結果を返すこと' do
|
105
|
-
result = @oh.delete('foo') { |key| key + 'no' }
|
106
|
-
result.should == 3
|
107
|
-
|
108
|
-
result = @oh.delete('none') { |key| key + 'no' }
|
109
|
-
result.should == 'noneno'
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'ブロックが与えられて、シンボルの key が与えられたときは' +
|
113
|
-
'key にマッチするものがなかった時にブロックを評価して、その結果を返すこと ' +
|
114
|
-
'(ブロックには文字列のキーが渡される)' do
|
115
|
-
result = @oh.delete(:foo) { |key| key + 'no' }
|
116
|
-
result.should == 3
|
117
|
-
|
118
|
-
result = @oh.delete(:none) { |key| key + 'no' }
|
119
|
-
result.should == 'noneno'
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
65
|
describe OrderedHash, '#each について' do
|
124
66
|
before do
|
125
67
|
@oh1, @oh2 = OrderedHash.new, OrderedHash.new
|
data/tiny_css.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "tiny_css"
|
3
|
-
s.version = "0.
|
4
|
-
s.date = "2008-07-
|
3
|
+
s.version = "0.1"
|
4
|
+
s.date = "2008-07-06"
|
5
5
|
s.summary = ""
|
6
6
|
s.email = "info@milk1000.cc"
|
7
7
|
s.homepage = "http://github.com/milk1000cc/tiny_css"
|
8
8
|
s.description = ""
|
9
9
|
s.has_rdoc = false
|
10
10
|
s.authors = ["milk1000cc"]
|
11
|
-
s.files = ["README", "lib/tiny_css.rb", "lib/tiny_css/base.rb", "lib/tiny_css/ordered_hash.rb", "spec/base_spec.rb", "spec/ordered_hash_spec.rb", "spec/
|
11
|
+
s.files = [".DS_Store", "README", "lib/.DS_Store", "lib/tiny_css.rb", "lib/tiny_css/base.rb", "lib/tiny_css/ordered_hash.rb", "spec/base_spec.rb", "spec/ordered_hash_spec.rb", "spec/style.css", "tiny_css.gemspec"]
|
12
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milk1000cc-tiny_css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.1"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- milk1000cc
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-07-
|
12
|
+
date: 2008-07-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,13 +22,14 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
+
- .DS_Store
|
25
26
|
- README
|
27
|
+
- lib/.DS_Store
|
26
28
|
- lib/tiny_css.rb
|
27
29
|
- lib/tiny_css/base.rb
|
28
30
|
- lib/tiny_css/ordered_hash.rb
|
29
31
|
- spec/base_spec.rb
|
30
32
|
- spec/ordered_hash_spec.rb
|
31
|
-
- spec/spec.opts
|
32
33
|
- spec/style.css
|
33
34
|
- tiny_css.gemspec
|
34
35
|
has_rdoc: false
|
data/spec/spec.opts
DELETED