taggart 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -89,27 +89,43 @@ Like this:
89
89
  ```ruby
90
90
  "alert('This string will pop up an alert!')".script
91
91
  ```
92
+
92
93
  gives you
94
+
93
95
  ```html
94
- <script id="pants_pants" type="text/javascript">alert('This string will pop up an alert!')</script>"
96
+ <script type="text/javascript">alert('This string will pop up an alert!')</script>
95
97
  ```
96
98
 
97
99
  whereas this string
98
100
 
99
101
  ```ruby
100
- "/script/awesomes_script.js".script
102
+ "/script/awesome_script.js".script
101
103
  ```
102
104
 
103
105
  gives you this
104
106
 
105
107
  ```html
106
- "<script type="text/javascript" src="/script/awesomes_script.js"></script>"
108
+ <script type="text/javascript" src="/script/awesome_script.js"></script>
109
+ ```
110
+
111
+ Calling `.ol` or `.ul` on an array, will generate a full ordered or unordered list, like this
112
+
113
+ ```ruby
114
+ %w(First Second Third).ol
115
+ ```
116
+
117
+ returns
118
+
119
+ ```html
120
+ <ol><li>First</li><li>Second</li><li>Third</li></ol>
107
121
  ```
108
122
 
109
- Naturally this also works with attributes.
123
+
124
+ Naturally they all also work with attributes.
110
125
 
111
126
  See the `spec/taggart_spec.rb` for more examples (until I have time to do a bigger-better-faster-example file).
112
127
 
128
+
113
129
  Background:
114
130
  -----------
115
131
  I have a lot of Ruby code that marks some String in an HTML tag, usually with a
@@ -147,9 +163,12 @@ Taggart is now active, which means you can play around.
147
163
 
148
164
  History
149
165
  -------
150
- - Added <script>-tag. You can now add ``"my-script.js".script`` and ``"alert('Hello World!')".script`.
166
+
167
+ - Added `<table>` to Array that creates single or multi row tables.
168
+ - Added `<ol>` and `<ul>` tags to the Array so you can now generate lists in one fast action.
169
+ - Added `<script>`-tag. You can now add `"my-script.js".script` and `"alert('Hello World!')".script`.
151
170
  - Added several tags (still not a complete list, tweet or send a pull request for more tags.)
152
- - Removed several 'if DEBUG' lines
171
+ - Removed several `if DEBUG` lines
153
172
  - Removed examples and most comments from taggart.rb file
154
173
  - Converted the README to markdown for a bit better formatting fun.
155
174
  - Added `.href` and `.img` feature.
@@ -188,8 +207,8 @@ Feedback welcome!!
188
207
 
189
208
  Author: Jocke Selin <jocke@selincite.com> @jockeselin
190
209
 
191
- Date: 2012-03-09
210
+ Date: 2012-03-14
192
211
 
193
- Version: 0.0.5 Build 010
212
+ Version: 0.0.6 Build 011
194
213
 
195
214
  Github: <https://github.com/jocke/taggart>
data/lib/taggart.rb CHANGED
@@ -2,8 +2,8 @@
2
2
  # ===========================================
3
3
  # Author: Jocke Selin <jocke@selincite.com>
4
4
  # @jockeselin
5
- # Date: 2012-03-09
6
- # Version: 0.0.5 Build 010
5
+ # Date: 2012-03-14
6
+ # Version: 0.0.6 Build 011
7
7
  # Github: https://github.com/jocke/taggart
8
8
 
9
9
  module Taggart
@@ -159,6 +159,31 @@ module Taggart
159
159
  end
160
160
 
161
161
 
162
+ def ol(*args)
163
+ self.li.ol(*args)
164
+ end
165
+
166
+
167
+ def ul(*args)
168
+ self.li.ul(*args)
169
+ end
170
+
171
+
172
+ def tr(*args)
173
+ self.td.tr(*args)
174
+ end
175
+
176
+
177
+ def table(*args)
178
+ if self.first.is_a? Array
179
+ self.map do |table_row|
180
+ table_row.tr if table_row.is_a? Array
181
+ end.join.table(*args)
182
+ else
183
+ self.tr.table(*args)
184
+ end
185
+ end
186
+
162
187
  end # End Array module
163
188
  end
164
189
 
data/spec/taggart_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
- # Run with: rspec -fd -c taggart_spec.rb
1
+ # Run with rake or with: rspec -fd -c taggart_spec.rb
2
+
2
3
  require 'taggart.rb'
3
4
 
4
5
  describe Taggart::String, "#attribute_tags" do
@@ -195,4 +196,51 @@ describe Taggart::Array, "#array_attribute_tag" do
195
196
  end
196
197
  end
197
198
  end
199
+
200
+ describe Taggart::Array, "smarter tags" do
201
+ context "cleverer lists" do
202
+ it "returns an ordered list when calling ol." do
203
+ %w{one two three}.ol.should == "<ol><li>one</li><li>two</li><li>three</li></ol>"
204
+ end
205
+
206
+ it "returns an ordered list with attributes when calling ol." do
207
+ %w{one two three}.ol(id: :my_unordered_list).should == "<ol id=\"my_unordered_list\"><li>one</li><li>two</li><li>three</li></ol>"
208
+ end
209
+
210
+ it "returns an unordered list when calling ul." do
211
+ %w{one two three}.ul.should == "<ul><li>one</li><li>two</li><li>three</li></ul>"
212
+ end
213
+
214
+ it "returns an unordered list with attributes when calling ol." do
215
+ %w{one two three}.ul(id: :my_ordered_list).should == "<ul id=\"my_ordered_list\"><li>one</li><li>two</li><li>three</li></ul>"
216
+ end
217
+
218
+ end
219
+
220
+ context "cleverer tables" do
221
+ it "returns a table row when calling tr." do
222
+ %w{one two three}.tr.should == "<tr><td>one</td><td>two</td><td>three</td></tr>"
223
+ end
224
+
225
+ it "returns a table row witth attributes when calling tr." do
226
+ %w{one two three}.tr(id: :my_table_row).should == "<tr id=\"my_table_row\"><td>one</td><td>two</td><td>three</td></tr>"
227
+ end
228
+
229
+ it "returns a single row table when calling table with strings." do
230
+ %w{one two three}.table.should == "<table><tr><td>one</td><td>two</td><td>three</td></tr></table>"
231
+ end
232
+
233
+ it "returns a single row table with attributes when calling table with strings." do
234
+ %w{one two three}.table(id: :single_row).should == "<table id=\"single_row\"><tr><td>one</td><td>two</td><td>three</td></tr></table>"
235
+ end
236
+
237
+ it "returns a multi-row table when calling table with multidimensional arrays" do
238
+ [%w(one two three), %w(zero nine eight)].table.should == "<table><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>zero</td><td>nine</td><td>eight</td></tr></table>"
239
+ end
240
+
241
+ it "returns a multi-row table with attributes when calling table with multidimensional arrays" do
242
+ [%w(one two three), %w(zero nine eight)].table(id: :multi_row).should == "<table id=\"multi_row\"><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>zero</td><td>nine</td><td>eight</td></tr></table>"
243
+ end
244
+ end
245
+ end
198
246
  end
data/taggart.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "taggart"
3
- s.version = "0.0.5"
4
- s.date = "2012-03-09"
3
+ s.version = "0.0.6"
4
+ s.date = "2012-03-14"
5
5
  s.summary = "Tag Strings with HTML; 'Hello World'.h1"
6
6
  s.description = "Tag your strings in a simple and easy way by running \"Hello World\".h1 for example."
7
7
  s.authors = ["Jocke Selin"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taggart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-09 00:00:00.000000000 Z
12
+ date: 2012-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70190373434460 !ruby/object:Gem::Requirement
16
+ requirement: &70344203614200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70190373434460
24
+ version_requirements: *70344203614200
25
25
  description: Tag your strings in a simple and easy way by running "Hello World".h1
26
26
  for example.
27
27
  email: