taggart 0.0.7 → 0.0.8
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.
- data/README.markdown +13 -8
- data/lib/taggart.rb +68 -119
- data/lib/taggart_help.rb +120 -0
- data/spec/{taggart_spec.rb → lib/taggart_spec.rb} +79 -0
- data/taggart.gemspec +4 -4
- metadata +20 -11
data/README.markdown
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Taggart
|
2
|
-
|
1
|
+
Taggart surrounds your strings with HTML Tags
|
2
|
+
=============================================
|
3
3
|
How and what
|
4
4
|
------------
|
5
5
|
```ruby
|
@@ -21,7 +21,7 @@ or try (in bad typographical taste)
|
|
21
21
|
to get
|
22
22
|
|
23
23
|
```html
|
24
|
-
<em
|
24
|
+
<strong><em>Important!</em></strong>
|
25
25
|
```
|
26
26
|
|
27
27
|
or do some more nesting
|
@@ -82,6 +82,8 @@ will return.
|
|
82
82
|
```html
|
83
83
|
Gimme a<br />
|
84
84
|
```
|
85
|
+
You can choose to close the tag with `Taggart.close_ending_tag` or open the tag (default as of 0.0.8) with `Taggart.open_ending_tag`.
|
86
|
+
|
85
87
|
|
86
88
|
Also try some of the 'cleverness', for example calling `.script` on a `.js` file will yield a different result compared to running it on a Javascript.
|
87
89
|
Like this:
|
@@ -134,8 +136,7 @@ console you can now run:
|
|
134
136
|
|
135
137
|
```ruby
|
136
138
|
Taggart.help # For generic information about Taggart (or Taggart.info)
|
137
|
-
Taggart.tags # For a list of different tags and other curious
|
138
|
-
things.
|
139
|
+
puts Taggart.tags # For a list of different tags and other curious things.
|
139
140
|
```
|
140
141
|
|
141
142
|
There's also some constants that you can access, such as `VERSION`, and
|
@@ -179,6 +180,11 @@ Taggart is now active, which means you can play around.
|
|
179
180
|
History
|
180
181
|
-------
|
181
182
|
|
183
|
+
- Added HTML5 tags - the list is not complete, let me know what I've
|
184
|
+
missed.
|
185
|
+
- Added ability to have closed and open endings on single tags (i.e `<br>`
|
186
|
+
and `<br />`.
|
187
|
+
- Moved help to a separate module.
|
182
188
|
- Added informational Taggart.help and Taggart.tags.
|
183
189
|
- Moved several tags into arrays for easier reference.
|
184
190
|
- Created Taggart::VERSION and Taggart::BUILD for reference and DRYness.
|
@@ -211,7 +217,6 @@ Future???
|
|
211
217
|
With your blessing. Like Ozzy said; _"The crazier you get, the crazier Ozzy gets!"_, or something.
|
212
218
|
|
213
219
|
* Potential validations, could check file, size, etc
|
214
|
-
* Switch between HTML and XHTML.
|
215
220
|
* Full fledged examples.
|
216
221
|
* Please send suggestions.
|
217
222
|
|
@@ -226,8 +231,8 @@ Feedback welcome!!
|
|
226
231
|
|
227
232
|
Author: Jocke Selin <jocke@selincite.com> @jockeselin
|
228
233
|
|
229
|
-
Date: 2012-
|
234
|
+
Date: 2012-10-10
|
230
235
|
|
231
|
-
Version: 0.0.
|
236
|
+
Version: 0.0.8 Build 013
|
232
237
|
|
233
238
|
Github: <https://github.com/jocke/taggart>
|
data/lib/taggart.rb
CHANGED
@@ -1,115 +1,40 @@
|
|
1
|
-
# Taggart
|
2
|
-
#
|
1
|
+
# Taggart surrounds your strings with HTML tags.
|
2
|
+
# ==============================================
|
3
3
|
# Author: Jocke Selin <jocke@selincite.com>
|
4
4
|
# @jockeselin
|
5
|
-
# Date: 2012-
|
6
|
-
# Version: 0.0.
|
5
|
+
# Date: 2012-10-10
|
6
|
+
# Version: 0.0.8 Build 013
|
7
7
|
# Github: https://github.com/jocke/taggart
|
8
8
|
|
9
9
|
module Taggart
|
10
|
+
# require './taggart_help.rb'
|
11
|
+
require File.expand_path('../taggart_help.rb', __FILE__)
|
10
12
|
|
11
|
-
VERSION = '0.0.
|
12
|
-
BUILD = '
|
13
|
+
VERSION = '0.0.8'
|
14
|
+
BUILD = '013'
|
15
|
+
CLOSED_TAG = ' /'
|
16
|
+
OPEN_TAG = ''
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
puts "Taggart is a library that allows you to easily"
|
18
|
-
puts "turn a string (or array) into an HTML tag or more tags"
|
19
|
-
puts "by simply calling the 'tag-method' on the string."
|
20
|
-
puts "Examples:"
|
21
|
-
puts " 'Hello World!'.h1 --> <h1>Hello World!</h1>'"
|
22
|
-
puts " 'Important'.span(class: :important) "
|
23
|
-
puts " --> <span class=\"important\">Important</span>"
|
24
|
-
puts " 'Break'.br --> Break<br />"
|
25
|
-
puts " %w(a b c).ul --> <ul><li>a</li><li>b</li><li>c</li></ul>"
|
26
|
-
puts "\nFor a list of tags run Taggart.tags"
|
27
|
-
puts "Other informational stuff:"
|
28
|
-
puts " - Version: Taggart::VERSION"
|
29
|
-
puts " - Build: Taggart::BUILD"
|
30
|
-
puts "\nPlease note that Taggart is considered 'experimental' (but"
|
31
|
-
puts "fairly stable) and in early development, so please help make"
|
32
|
-
puts "Taggart better; send suggestions, bug fixes, improvements, etc"
|
33
|
-
puts "to the author, and do fork the code and send pull requests if"
|
34
|
-
puts "you've made an improvement - Thanks!"
|
35
|
-
puts "\n\nAuthor: Jocke Selin <jocke@selincite.com> @jockeselin"
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@current_close_tag = OPEN_TAG
|
36
21
|
end
|
37
22
|
|
38
|
-
def self.
|
39
|
-
|
23
|
+
def self.version
|
24
|
+
VERSION
|
40
25
|
end
|
41
26
|
|
42
|
-
def self.
|
43
|
-
|
44
|
-
puts "~~~~~~~~~~~~~~~"
|
45
|
-
puts "This is a list of the tags that Taggart can generate, for your pleasure"
|
46
|
-
puts "\nStandard tags:"
|
47
|
-
puts "--------------"
|
48
|
-
puts "These tags have a start- and end-tag and the take any number of"
|
49
|
-
puts "attributes in the form of a hash with key-value pairs."
|
50
|
-
output_tags(Taggart::String::STANDARD_TAGS)
|
51
|
-
puts "\nSpecial tags"
|
52
|
-
puts "------------"
|
53
|
-
puts "These tags behave like the Standard tags, but there's already a"
|
54
|
-
puts "method defined for the String instance so these tags have to be"
|
55
|
-
puts "treated in a slightly special way, in that the tag that's ouputted"
|
56
|
-
puts "doesn't have the same method name. I.e to output <tr> you call '._tr'"
|
57
|
-
puts "however, you don't really need to bother with knowing this as Taggart"
|
58
|
-
puts "does some magic behind the scenes to determine wheter you are asking"
|
59
|
-
puts "for a Taggart tag or the original method."
|
60
|
-
Taggart::String::SPECIAL_TAGS.sort.each do |tag_pair|
|
61
|
-
puts " Tag: #{('<' + tag_pair[0] + '>').ljust(6)} Method: .#{tag_pair[1]}"
|
62
|
-
end
|
63
|
-
puts "\nSingle Tags"
|
64
|
-
puts "-------------"
|
65
|
-
puts "Single tags are tags that do not an end tag, <br> is one such tag"
|
66
|
-
puts "In Taggart Single Tags behave just like Standard tags; you can"
|
67
|
-
puts "add attributes to them."
|
68
|
-
output_tags(Taggart::String::SINGLE_TAGS)
|
69
|
-
puts "\nSmart Tags"
|
70
|
-
puts "------------"
|
71
|
-
puts "These tags go to the gifted class and can speak elvish. They know what"
|
72
|
-
puts "you want from them. They don't behave like the other ones in the sense"
|
73
|
-
puts "that you have a string that you want to turn into something, not just a"
|
74
|
-
puts "simple tag."
|
75
|
-
puts "Here's the pupils of the gifted class:"
|
76
|
-
puts ".img - Turns a URL to an image into an img tag."
|
77
|
-
puts ".href - turns a URL into the href-portion of an A-tag, takes the link"
|
78
|
-
puts " content as a parameter, and also other attributes as 2nd argument."
|
79
|
-
puts ".script - Either turns a URL to a script file into a <script src..></script>"
|
80
|
-
puts " tag, or embeds a script source in <script></script> tags. Smart!"
|
81
|
-
puts "\nArray tags"
|
82
|
-
puts "----------"
|
83
|
-
puts "The Array Tags generate HTML tags out of a list of strings in an array."
|
84
|
-
puts "For example, you can turn an array into list items by callin the .li-"
|
85
|
-
puts "method on the array."
|
86
|
-
puts "You can also pass attributes to the tags as with the Standard Tags"
|
87
|
-
puts "The tags are:"
|
88
|
-
puts " td li"
|
89
|
-
puts "\nSmart Array Tags"
|
90
|
-
puts "-----------------"
|
91
|
-
puts "The Smart Array Tags are all a bit more smartly dressed than the"
|
92
|
-
puts "proletarian Array Tags. Namely, they figure out what you do."
|
93
|
-
puts "Here's the honour roll"
|
94
|
-
puts "Method Tag Special powers"
|
95
|
-
puts ".ol - Turns an array into an ordered list, wrapping the array elements"
|
96
|
-
puts " in <li> tags so you get your awesome list in one go"
|
97
|
-
puts ".ul - The almost identical twin of .ol"
|
98
|
-
puts ".tr - Like .ol and .li, but wraps the array in <tr> tags with every"
|
99
|
-
puts " element wrapped in a <td> tag."
|
100
|
-
puts ".table - The smartest of them all. Creates a complete table from a, one or"
|
101
|
-
puts " two dimensional Array. Each array is wrapped in the <tr> tag with"
|
102
|
-
puts " every element in the Array in <td> tags. It's all finished off"
|
103
|
-
puts " with a decoration of <table>."
|
104
|
-
puts "\nTag arrays and methods"
|
105
|
-
puts "----------------------"
|
106
|
-
puts "You can access the following arrays and methods containing the tags."
|
107
|
-
puts "Tags Array Method"
|
108
|
-
puts "Standard tags Taggart::String::STANDARD_TAGS Taggart.standard_tags"
|
109
|
-
puts "Special tags Taggart::String::SPECIAL_TAGS Taggart.special_tags"
|
110
|
-
puts "Single tags Taggart::String::SINGLE_TAGS Taggart.single_tags"
|
27
|
+
def self.build
|
28
|
+
BUILD
|
111
29
|
end
|
112
30
|
|
31
|
+
def self.help
|
32
|
+
TaggartHelp.help
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.tags
|
36
|
+
TaggartHelp.tags
|
37
|
+
end
|
113
38
|
|
114
39
|
def self.standard_tags
|
115
40
|
Taggart::String::STANDARD_TAGS
|
@@ -124,28 +49,48 @@ module Taggart
|
|
124
49
|
end
|
125
50
|
|
126
51
|
|
127
|
-
|
52
|
+
# Returns true if the tags are open, false if they're closed
|
53
|
+
def self.end_tag_status?
|
54
|
+
(@current_close_tag == OPEN_TAG) ? :open : :closed
|
55
|
+
end
|
128
56
|
|
129
|
-
def self.
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
57
|
+
def self.end_tag_closed?
|
58
|
+
(end_tag_status? == :closed)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.end_tag_open?
|
62
|
+
(end_tag_status? == :open)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.close_ending_tag
|
66
|
+
@current_close_tag = CLOSED_TAG
|
67
|
+
true
|
140
68
|
end
|
141
69
|
|
70
|
+
def self.open_ending_tag
|
71
|
+
@current_close_tag = OPEN_TAG
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
|
77
|
+
def self.current_close_tag
|
78
|
+
@current_close_tag
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
private
|
83
|
+
|
142
84
|
module String
|
143
85
|
|
144
86
|
DEBUG = false
|
145
|
-
STANDARD_TAGS = %w{
|
146
|
-
|
147
|
-
|
148
|
-
|
87
|
+
STANDARD_TAGS = %w{ a abbr acronym address article aside audio bdi blockquote body button canvas
|
88
|
+
caption cite code command datalist dd del details div dl dt em embed fieldset
|
89
|
+
figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup html keygen
|
90
|
+
label legend li mark meter nav ol option output p pre progress q rp rt ruby
|
91
|
+
section select small source span strong style summary sup table tbody td textarea
|
92
|
+
tfoot th thead time title track tt ul video wbr} # This is not a complete list - please tweet or pull req.
|
93
|
+
|
149
94
|
SPECIAL_TAGS = [['tr', '_tr'], ['sub', '_sub']]
|
150
95
|
TAGS = STANDARD_TAGS + SPECIAL_TAGS
|
151
96
|
SINGLE_TAGS = %w{br hr input link meta}
|
@@ -175,7 +120,7 @@ module Taggart
|
|
175
120
|
end
|
176
121
|
end
|
177
122
|
|
178
|
-
|
123
|
+
|
179
124
|
def href(label = nil, *args)
|
180
125
|
option_str = parse_options(args << {href: self})
|
181
126
|
label ||= self
|
@@ -200,9 +145,13 @@ module Taggart
|
|
200
145
|
end
|
201
146
|
|
202
147
|
|
203
|
-
|
148
|
+
def htji
|
149
|
+
%w{72 101 108 108 111 32 116 111 32 74 97 115 111 110 32 73 115 97 97 99 115 33}.map { |c| c.to_i.chr }.join.h1
|
150
|
+
end
|
204
151
|
|
205
152
|
|
153
|
+
private
|
154
|
+
|
206
155
|
# Parses the options for the tags
|
207
156
|
def parse_options(args)
|
208
157
|
return "" if args.nil?
|
@@ -228,7 +177,7 @@ module Taggart
|
|
228
177
|
def self.single_attribute_tag(tag)
|
229
178
|
define_method(tag) do |*args|
|
230
179
|
option_str = parse_options(args)
|
231
|
-
"#{self}<#{tag}#{option_str}
|
180
|
+
"#{self}<#{tag}#{option_str}#{Taggart.current_close_tag}>"
|
232
181
|
end
|
233
182
|
end
|
234
183
|
|
@@ -320,7 +269,7 @@ module Taggart
|
|
320
269
|
end # End Array module
|
321
270
|
end
|
322
271
|
|
323
|
-
|
272
|
+
|
324
273
|
class String
|
325
274
|
alias_method :translate, :tr
|
326
275
|
alias_method :substitute, :sub
|
data/lib/taggart_help.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
module TaggartHelp
|
2
|
+
|
3
|
+
def self.help
|
4
|
+
puts "Welcome to Taggart (#{Taggart::VERSION} Build #{Taggart::BUILD})"
|
5
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
6
|
+
puts "Taggart is a library that allows you to easily"
|
7
|
+
puts "turn a string (or array) into an HTML tag or more tags"
|
8
|
+
puts "by simply calling the 'tag-method' on the string."
|
9
|
+
puts "Examples:"
|
10
|
+
puts " 'Hello World!'.h1 --> <h1>Hello World!</h1>'"
|
11
|
+
puts " 'Important'.span(class: :important) "
|
12
|
+
puts " --> <span class=\"important\">Important</span>"
|
13
|
+
puts " 'Break'.br --> Break<br />"
|
14
|
+
puts " %w(a b c).ul --> <ul><li>a</li><li>b</li><li>c</li></ul>"
|
15
|
+
puts "\nFor a list of tags run Taggart.tags"
|
16
|
+
puts "Other informational stuff:"
|
17
|
+
puts " - Version: Taggart::VERSION"
|
18
|
+
puts " - Build: Taggart::BUILD"
|
19
|
+
puts "\nPlease note that Taggart is considered 'experimental' (but"
|
20
|
+
puts "fairly stable) and in early development, so please help make"
|
21
|
+
puts "Taggart better; send suggestions, bug fixes, improvements, etc"
|
22
|
+
puts "to the author, and do fork the code and send pull requests if"
|
23
|
+
puts "you've made an improvement - Thanks!"
|
24
|
+
puts "\n\nAuthor: Jocke Selin <jocke@selincite.com> @jockeselin"
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def self.info
|
30
|
+
self.help
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def self.tags
|
35
|
+
"Taggart's tags:\n" +
|
36
|
+
"~~~~~~~~~~~~~~~"
|
37
|
+
"This is a list of the tags that Taggart can generate, for your pleasure\n" +
|
38
|
+
"\nStandard tags:\n" +
|
39
|
+
"--------------\n" +
|
40
|
+
"These tags have a start- and end-tag and the take any number of\n" +
|
41
|
+
"attributes in the form of a hash with key-value pairs.\n" +
|
42
|
+
output_tags(Taggart::String::STANDARD_TAGS) +
|
43
|
+
"\nSpecial tags\n" +
|
44
|
+
"------------\n" +
|
45
|
+
"These tags behave like the Standard tags, but there's already a\n" +
|
46
|
+
"method defined for the String instance so these tags have to be\n" +
|
47
|
+
"treated in a slightly special way, in that the tag that's ouputted\n" +
|
48
|
+
"doesn't have the same method name. I.e to output <tr> you call '._tr'\n" +
|
49
|
+
"however, you don't really need to bother with knowing this as Taggart\n" +
|
50
|
+
"does some magic behind the scenes to determine wheter you are asking\n" +
|
51
|
+
"for a Taggart tag or the original method.\n" +
|
52
|
+
(Taggart::String::SPECIAL_TAGS.sort.map do |tag_pair|
|
53
|
+
" Tag: #{('<' + tag_pair[0] + '>').ljust(6)} Method: .#{tag_pair[1]}"
|
54
|
+
end).join("\n") +
|
55
|
+
"\n\nSingle Tags\n" +
|
56
|
+
"-------------\n" +
|
57
|
+
"Single tags are tags that do not an end tag, <br> is one such tag\n" +
|
58
|
+
"In Taggart Single Tags behave just like Standard tags; you can\n" +
|
59
|
+
"add attributes to them.\n" +
|
60
|
+
output_tags(Taggart::String::SINGLE_TAGS) +
|
61
|
+
"\nSmart Tags\n" +
|
62
|
+
"------------\n" +
|
63
|
+
"These tags go to the gifted class and can speak elvish. They know what\n" +
|
64
|
+
"you want from them. They don't behave like the other ones in the sense\n" +
|
65
|
+
"that you have a string that you want to turn into something, not just a\n" +
|
66
|
+
"simple tag.\n" +
|
67
|
+
"Here's the pupils of the gifted class:\n" +
|
68
|
+
".img - Turns a URL to an image into an img tag.\n" +
|
69
|
+
".href - turns a URL into the href-portion of an A-tag, takes the link\n" +
|
70
|
+
" content as a parameter, and also other attributes as 2nd argument.\n" +
|
71
|
+
".script - Either turns a URL to a script file into a <script src..></script>\n" +
|
72
|
+
" tag, or embeds a script source in <script></script> tags. Smart!\n" +
|
73
|
+
"\nArray tags\n" +
|
74
|
+
"----------\n" +
|
75
|
+
"The Array Tags generate HTML tags out of a list of strings in an array.\n" +
|
76
|
+
"For example, you can turn an array into list items by callin the .li-\n" +
|
77
|
+
"method on the array.\n" +
|
78
|
+
"You can also pass attributes to the tags as with the Standard Tags\n" +
|
79
|
+
"The tags are:\n" +
|
80
|
+
" td li\n" +
|
81
|
+
"\nSmart Array Tags\n" +
|
82
|
+
"-----------------\n" +
|
83
|
+
"The Smart Array Tags are all a bit more smartly dressed than the\n" +
|
84
|
+
"proletarian Array Tags. Namely, they figure out what you do.\n" +
|
85
|
+
"Here's the honour roll\n" +
|
86
|
+
"Method Tag Special powers\n" +
|
87
|
+
".ol - Turns an array into an ordered list, wrapping the array elements\n" +
|
88
|
+
" in <li> tags so you get your awesome list in one go\n" +
|
89
|
+
".ul - The almost identical twin of .ol\n" +
|
90
|
+
".tr - Like .ol and .li, but wraps the array in <tr> tags with every\n" +
|
91
|
+
" element wrapped in a <td> tag.\n" +
|
92
|
+
".table - The smartest of them all. Creates a complete table from a, one or\n" +
|
93
|
+
" two dimensional Array. Each array is wrapped in the <tr> tag with\n" +
|
94
|
+
" every element in the Array in <td> tags. It's all finished off\n" +
|
95
|
+
" with a decoration of <table>.\n" +
|
96
|
+
"\nTag arrays and methods\n" +
|
97
|
+
"----------------------\n" +
|
98
|
+
"You can access the following arrays and methods containing the tags.\n" +
|
99
|
+
"Tags Array Method\n" +
|
100
|
+
"Standard tags Taggart::String::STANDARD_TAGS Taggart.standard_tags\n" +
|
101
|
+
"Special tags Taggart::String::SPECIAL_TAGS Taggart.special_tags\n" +
|
102
|
+
"Single tags Taggart::String::SINGLE_TAGS Taggart.single_tags"
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def self.output_tags(tags)
|
108
|
+
columns = 4
|
109
|
+
padding = 14
|
110
|
+
|
111
|
+
output = " "
|
112
|
+
tags.sort.each_with_index do |tag, index|
|
113
|
+
index += 1
|
114
|
+
output += "#{tag.ljust(padding)}"
|
115
|
+
output += "\n " if ((index % columns) == 0) and (index > 0)
|
116
|
+
end
|
117
|
+
output + "\n\n"
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -1,17 +1,55 @@
|
|
1
1
|
# Run with rake or with: rspec -fd -c taggart_spec.rb
|
2
|
+
# or run 'guard'
|
3
|
+
|
4
|
+
def silence_stream(stream)
|
5
|
+
old_stream = stream.dup
|
6
|
+
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
7
|
+
stream.sync = true
|
8
|
+
yield
|
9
|
+
ensure
|
10
|
+
stream.reopen(old_stream)
|
11
|
+
end
|
2
12
|
|
3
13
|
require 'taggart.rb'
|
4
14
|
|
5
15
|
describe Taggart, "informational" do
|
6
16
|
|
17
|
+
it "the version constant should return a string" do
|
18
|
+
Taggart::VERSION.should be_a(String)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "the build constant should return a string" do
|
22
|
+
Taggart::BUILD.should be_a(String)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "the version method should return the version number" do
|
26
|
+
Taggart.version.should == Taggart::VERSION
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return the build number" do
|
30
|
+
Taggart.build.should == Taggart::BUILD
|
31
|
+
end
|
32
|
+
|
7
33
|
it "should respond to help" do
|
8
34
|
Taggart.should respond_to(:help)
|
9
35
|
end
|
10
36
|
|
37
|
+
it "help should return a string." do
|
38
|
+
silence_stream(STDOUT) do
|
39
|
+
Taggart.help.should == true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
11
43
|
it "should respond to tags" do
|
12
44
|
Taggart.should respond_to(:tags)
|
13
45
|
end
|
14
46
|
|
47
|
+
it "tags should return a string" do
|
48
|
+
# silence_stream(STDOUT) do
|
49
|
+
Taggart.tags.should be_a(String)
|
50
|
+
# end
|
51
|
+
end
|
52
|
+
|
15
53
|
it "returns an array when asked for standard tags" do
|
16
54
|
Taggart.standard_tags.should be_an(Array)
|
17
55
|
end
|
@@ -24,6 +62,32 @@ describe Taggart, "informational" do
|
|
24
62
|
Taggart.single_tags.should be_an(Array)
|
25
63
|
end
|
26
64
|
|
65
|
+
describe Taggart, "tag closing" do
|
66
|
+
|
67
|
+
it "returns a symbol when asking for the current closing tag setting" do
|
68
|
+
Taggart.end_tag_status?.should be_a(Symbol)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns true when setting tag ending to closed" do
|
72
|
+
Taggart.close_ending_tag.should == true
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns true when setting tag ending to open" do
|
76
|
+
Taggart.open_ending_tag.should == true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns true when tag ending is set to open" do
|
80
|
+
Taggart.open_ending_tag
|
81
|
+
Taggart.end_tag_status?.should == :open
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns false when tag ending is set to closed" do
|
85
|
+
Taggart.close_ending_tag
|
86
|
+
Taggart.end_tag_status?.should == :closed
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
27
91
|
end
|
28
92
|
|
29
93
|
describe Taggart::String, "#attribute_tags" do
|
@@ -55,6 +119,17 @@ describe Taggart::String, "#single_attribute_tag" do
|
|
55
119
|
it "returns a standard tag with two attribute" do
|
56
120
|
"hello world".br(class: :header, id: :title).should == "hello world<br class=\"header\" id=\"title\" />"
|
57
121
|
end
|
122
|
+
describe "open or closed tag ending" do
|
123
|
+
it "returns <br /> when the tag ending is set to closed" do
|
124
|
+
Taggart.close_ending_tag
|
125
|
+
"hello world".br.should == 'hello world<br />'
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns <br> when the tag ending is set to open" do
|
129
|
+
Taggart.open_ending_tag
|
130
|
+
"hello world".br.should == 'hello world<br>'
|
131
|
+
end
|
132
|
+
end
|
58
133
|
end
|
59
134
|
|
60
135
|
describe Taggart::Array, "#array_attribute_tag" do
|
@@ -219,6 +294,10 @@ describe Taggart::Array, "#array_attribute_tag" do
|
|
219
294
|
"/path/to/img.png".img({class: :thumbnail}).a(href: '/hello/world.html').should == "<a href=\"/hello/world.html\"><img class=\"thumbnail\" src=\"/path/to/img.png\" /></a>"
|
220
295
|
end
|
221
296
|
end
|
297
|
+
|
298
|
+
it "responds to htji" do
|
299
|
+
"Hello World!".htji.should == %w{72 101 108 108 111 32 116 111 32 74 97 115 111 110 32 73 115 97 97 99 115 33}.map { |c| c.to_i.chr }.join.h1
|
300
|
+
end
|
222
301
|
end
|
223
302
|
|
224
303
|
describe Taggart::Array, "smarter tags" do
|
data/taggart.gemspec
CHANGED
@@ -6,13 +6,13 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = Taggart::VERSION
|
7
7
|
s.date = Date.today.strftime('%Y-%m-%d')
|
8
8
|
s.summary = "Tag Strings with HTML; 'Hello World'.h1"
|
9
|
-
s.description = "
|
9
|
+
s.description = "Add HTML tags around your strings by running \"Hello World\".h1 for example."
|
10
10
|
s.authors = ["Jocke Selin"]
|
11
11
|
s.email = ["jocke@selincite.com"]
|
12
12
|
s.homepage = "https://github.com/jocke/taggart"
|
13
13
|
s.require_paths = ["lib"]
|
14
|
-
s.files = ["lib/taggart.rb", "Rakefile", "taggart.gemspec", "README.markdown"]
|
15
|
-
s.test_files = ["spec/taggart_spec.rb"]
|
16
|
-
s.add_development_dependency "rspec"
|
14
|
+
s.files = ["lib/taggart.rb", "lib/taggart_help.rb", "Rakefile", "taggart.gemspec", "README.markdown"]
|
15
|
+
s.test_files = ["spec/lib/taggart_spec.rb"]
|
16
|
+
s.add_development_dependency ["rake", "rspec", "guard", "guard-rspec", "rb-fsevent"] # rb-fsevent is only required on MacOS.
|
17
17
|
s.post_install_message = "Thanks for showing interest in Taggart! Please provide feedback to jocke@selincite.com!"
|
18
18
|
end
|
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.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
|
15
|
+
name:
|
16
|
+
- rake
|
17
|
+
- rspec
|
18
|
+
- guard
|
19
|
+
- guard-rspec
|
20
|
+
- rb-fsevent
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
17
22
|
none: false
|
18
23
|
requirements:
|
19
24
|
- - ! '>='
|
@@ -21,9 +26,13 @@ dependencies:
|
|
21
26
|
version: '0'
|
22
27
|
type: :development
|
23
28
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
description: Add HTML tags around your strings by running "Hello World".h1 for example.
|
27
36
|
email:
|
28
37
|
- jocke@selincite.com
|
29
38
|
executables: []
|
@@ -31,10 +40,11 @@ extensions: []
|
|
31
40
|
extra_rdoc_files: []
|
32
41
|
files:
|
33
42
|
- lib/taggart.rb
|
43
|
+
- lib/taggart_help.rb
|
34
44
|
- Rakefile
|
35
45
|
- taggart.gemspec
|
36
46
|
- README.markdown
|
37
|
-
- spec/taggart_spec.rb
|
47
|
+
- spec/lib/taggart_spec.rb
|
38
48
|
homepage: https://github.com/jocke/taggart
|
39
49
|
licenses: []
|
40
50
|
post_install_message: Thanks for showing interest in Taggart! Please provide feedback
|
@@ -56,10 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
66
|
version: '0'
|
57
67
|
requirements: []
|
58
68
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.21
|
60
70
|
signing_key:
|
61
71
|
specification_version: 3
|
62
72
|
summary: Tag Strings with HTML; 'Hello World'.h1
|
63
73
|
test_files:
|
64
|
-
- spec/taggart_spec.rb
|
65
|
-
has_rdoc:
|
74
|
+
- spec/lib/taggart_spec.rb
|