tagz 8.0.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,19 +1,67 @@
1
-
2
1
  This.rubyforge_project = 'codeforpeople'
3
2
  This.author = "Ara T. Howard"
4
3
  This.email = "ara.t.howard@gmail.com"
5
- This.homepage = "http://github.com/ahoward/#{ This.lib }/tree/master"
4
+ This.homepage = "http://github.com/ahoward/#{ This.lib }"
6
5
 
7
6
 
8
7
  task :default do
9
- puts(Rake::Task.tasks.map{|task| task.name} - ['default'])
8
+ puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
9
+ end
10
+
11
+ task :test do
12
+ run_tests!
13
+ end
14
+
15
+ namespace :test do
16
+ task(:unit){ run_tests!(:unit) }
17
+ task(:functional){ run_tests!(:functional) }
18
+ task(:integration){ run_tests!(:integration) }
19
+ end
20
+
21
+ def run_tests!(which = nil)
22
+ which ||= '**'
23
+ test_dir = File.join(This.dir, "test")
24
+ test_glob ||= File.join(test_dir, "#{ which }/**_test.rb")
25
+ test_rbs = Dir.glob(test_glob).sort
26
+
27
+ div = ('=' * 119)
28
+ line = ('-' * 119)
29
+ helper = "-r ./test/helper.rb" if test(?e, "./test/helper.rb")
30
+
31
+ test_rbs.each_with_index do |test_rb, index|
32
+ testno = index + 1
33
+ command = "#{ This.ruby } -I ./lib -I ./test/lib #{ helper } #{ test_rb }"
34
+
35
+ puts
36
+ say(div, :color => :cyan, :bold => true)
37
+ say("@#{ testno } => ", :bold => true, :method => :print)
38
+ say(command, :color => :cyan, :bold => true)
39
+ say(line, :color => :cyan, :bold => true)
40
+
41
+ system(command)
42
+
43
+ say(line, :color => :cyan, :bold => true)
44
+
45
+ status = $?.exitstatus
46
+
47
+ if status.zero?
48
+ say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
49
+ say("SUCCESS", :color => :green, :bold => true)
50
+ else
51
+ say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
52
+ say("FAILURE", :color => :red, :bold => true)
53
+ end
54
+ say(line, :color => :cyan, :bold => true)
55
+
56
+ exit(status) unless status.zero?
57
+ end
10
58
  end
11
59
 
12
60
 
13
61
  task :gemspec do
14
62
  ignore_extensions = 'git', 'svn', 'tmp', /sw./, 'bak', 'gem'
15
- ignore_directories = 'pkg'
16
- ignore_files = 'test/log'
63
+ ignore_directories = %w[ pkg ]
64
+ ignore_files = %w[ test/log ]
17
65
 
18
66
  shiteless =
19
67
  lambda do |list|
@@ -44,8 +92,9 @@ task :gemspec do
44
92
  summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
45
93
  description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
46
94
 
47
- extensions = This.extensions
48
- if extensions.nil?
95
+ if This.extensions.nil?
96
+ This.extensions = []
97
+ extensions = This.extensions
49
98
  %w( Makefile configure extconf.rb ).each do |ext|
50
99
  extensions << ext if File.exists?(ext)
51
100
  end
@@ -75,8 +124,8 @@ task :gemspec do
75
124
 
76
125
  spec.has_rdoc = #{ has_rdoc.inspect }
77
126
  spec.test_files = #{ test_files.inspect }
78
- #spec.add_dependency 'lib', '>= version'
79
- #spec.add_dependency 'fattr'
127
+
128
+ # spec.add_dependency 'lib', '>= version'
80
129
 
81
130
  spec.extensions.push(*#{ extensions.inspect })
82
131
 
@@ -89,12 +138,13 @@ task :gemspec do
89
138
  }
90
139
  end
91
140
 
92
- open("#{ lib }.gemspec", "w"){|fd| fd.puts template}
93
- This.gemspec = "#{ lib }.gemspec"
141
+ Fu.mkdir_p(This.pkgdir)
142
+ This.gemspec = File.join(This.dir, "#{ This.lib }.gemspec") #File.join(This.pkgdir, "gemspec.rb")
143
+ open("#{ This.gemspec }", "w"){|fd| fd.puts(template)}
94
144
  end
95
145
 
96
146
  task :gem => [:clean, :gemspec] do
97
- Fu.mkdir_p This.pkgdir
147
+ Fu.mkdir_p(This.pkgdir)
98
148
  before = Dir['*.gem']
99
149
  cmd = "gem build #{ This.gemspec }"
100
150
  `#{ cmd }`
@@ -160,6 +210,9 @@ task :release => [:clean, :gemspec, :gem] do
160
210
  cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.pkgdir }/#{ This.gem }"
161
211
  puts cmd
162
212
  system cmd
213
+ cmd = "gem push #{ This.pkgdir }/#{ This.gem }"
214
+ puts cmd
215
+ system cmd
163
216
  end
164
217
 
165
218
 
@@ -167,26 +220,37 @@ end
167
220
 
168
221
 
169
222
  BEGIN {
223
+ # support for this rakefile
224
+ #
170
225
  $VERBOSE = nil
171
226
 
172
227
  require 'ostruct'
173
228
  require 'erb'
174
229
  require 'fileutils'
230
+ require 'rbconfig'
175
231
 
232
+ # fu shortcut
233
+ #
176
234
  Fu = FileUtils
177
235
 
236
+ # cache a bunch of stuff about this rakefile/environment
237
+ #
178
238
  This = OpenStruct.new
179
239
 
180
240
  This.file = File.expand_path(__FILE__)
181
241
  This.dir = File.dirname(This.file)
182
242
  This.pkgdir = File.join(This.dir, 'pkg')
183
243
 
244
+ # grok lib
245
+ #
184
246
  lib = ENV['LIB']
185
247
  unless lib
186
- lib = File.basename(Dir.pwd)
248
+ lib = File.basename(Dir.pwd).sub(/[-].*$/, '')
187
249
  end
188
250
  This.lib = lib
189
251
 
252
+ # grok version
253
+ #
190
254
  version = ENV['VERSION']
191
255
  unless version
192
256
  require "./lib/#{ This.lib }"
@@ -196,9 +260,22 @@ BEGIN {
196
260
  end
197
261
  This.version = version
198
262
 
263
+ # we need to know the name of the lib an it's version
264
+ #
199
265
  abort('no lib') unless This.lib
200
266
  abort('no version') unless This.version
201
267
 
268
+ # discover full path to this ruby executable
269
+ #
270
+ c = Config::CONFIG
271
+ bindir = c["bindir"] || c['BINDIR']
272
+ ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby'
273
+ ruby_ext = c['EXEEXT'] || ''
274
+ ruby = File.join(bindir, (ruby_install_name + ruby_ext))
275
+ This.ruby = ruby
276
+
277
+ # some utils
278
+ #
202
279
  module Util
203
280
  def indent(s, n = 2)
204
281
  s = unindent(s)
@@ -208,18 +285,20 @@ BEGIN {
208
285
 
209
286
  def unindent(s)
210
287
  indent = nil
211
- s.each do |line|
212
- next if line =~ %r/^\s*$/
213
- indent = line[%r/^\s*/] and break
288
+ s.each_line do |line|
289
+ next if line =~ %r/^\s*$/
290
+ indent = line[%r/^\s*/] and break
291
+ end
292
+ indent ? s.gsub(%r/^#{ indent }/, "") : s
214
293
  end
215
- indent ? s.gsub(%r/^#{ indent }/, "") : s
216
- end
217
294
  extend self
218
295
  end
219
296
 
297
+ # template support
298
+ #
220
299
  class Template
221
300
  def initialize(&block)
222
- @block = block
301
+ @block = block.binding
223
302
  @template = block.call.to_s
224
303
  end
225
304
  def expand(b=nil)
@@ -229,5 +308,57 @@ BEGIN {
229
308
  end
230
309
  def Template(*args, &block) Template.new(*args, &block) end
231
310
 
311
+ # colored console output support
312
+ #
313
+ This.ansi = {
314
+ :clear => "\e[0m",
315
+ :reset => "\e[0m",
316
+ :erase_line => "\e[K",
317
+ :erase_char => "\e[P",
318
+ :bold => "\e[1m",
319
+ :dark => "\e[2m",
320
+ :underline => "\e[4m",
321
+ :underscore => "\e[4m",
322
+ :blink => "\e[5m",
323
+ :reverse => "\e[7m",
324
+ :concealed => "\e[8m",
325
+ :black => "\e[30m",
326
+ :red => "\e[31m",
327
+ :green => "\e[32m",
328
+ :yellow => "\e[33m",
329
+ :blue => "\e[34m",
330
+ :magenta => "\e[35m",
331
+ :cyan => "\e[36m",
332
+ :white => "\e[37m",
333
+ :on_black => "\e[40m",
334
+ :on_red => "\e[41m",
335
+ :on_green => "\e[42m",
336
+ :on_yellow => "\e[43m",
337
+ :on_blue => "\e[44m",
338
+ :on_magenta => "\e[45m",
339
+ :on_cyan => "\e[46m",
340
+ :on_white => "\e[47m"
341
+ }
342
+ def say(phrase, *args)
343
+ options = args.last.is_a?(Hash) ? args.pop : {}
344
+ options[:color] = args.shift.to_s.to_sym unless args.empty?
345
+ keys = options.keys
346
+ keys.each{|key| options[key.to_s.to_sym] = options.delete(key)}
347
+
348
+ color = options[:color]
349
+ bold = options.has_key?(:bold)
350
+
351
+ parts = [phrase]
352
+ parts.unshift(This.ansi[color]) if color
353
+ parts.unshift(This.ansi[:bold]) if bold
354
+ parts.push(This.ansi[:clear]) if parts.size > 1
355
+
356
+ method = options[:method] || :puts
357
+
358
+ Kernel.send(method, parts.join)
359
+ end
360
+
361
+ # always run out of the project dir
362
+ #
232
363
  Dir.chdir(This.dir)
233
364
  }
data/lib/tagz.rb CHANGED
@@ -4,11 +4,12 @@ unless defined? Tagz
4
4
  #
5
5
  module Tagz
6
6
  def Tagz.version()
7
- '8.0.0'
7
+ '8.1.0'
8
8
  end
9
9
 
10
- def Tagz.description()
11
- <<-__
10
+ def Tagz.description
11
+ <<-____
12
+
12
13
  tagz.rb is generates html, xml, or any sgml variant like a small ninja
13
14
  running across the backs of a herd of giraffes swatting of heads like
14
15
  a mark-up weedwacker. weighing in at less than 300 lines of code
@@ -18,13 +19,14 @@ unless defined? Tagz
18
19
  that generate html to be able to do so easily in any context without
19
20
  heavyweight syntax or scoping issues, like a ninja sword through
20
21
  butter.
21
- __
22
+
23
+ ____
22
24
  end
23
25
 
24
26
  private
25
27
  # access tagz doc and enclose tagz operations
26
28
  #
27
- def tagz document = nil, &block
29
+ def tagz(document = nil, &block)
28
30
  @tagz ||= nil ## shut wornings up
29
31
  previous = @tagz
30
32
 
@@ -43,9 +45,10 @@ unless defined? Tagz
43
45
  end
44
46
  end
45
47
 
48
+
46
49
  # open_tag
47
50
  #
48
- def tagz__ name, *argv, &block
51
+ def tagz__(name, *argv, &block)
49
52
  options = argv.last.is_a?(Hash) ? argv.pop : {}
50
53
  content = argv
51
54
 
@@ -101,13 +104,13 @@ unless defined? Tagz
101
104
 
102
105
  # close_tag
103
106
  #
104
- def __tagz tag, *a, &b
107
+ def __tagz(tag, *a, &b)
105
108
  tagz.push "</#{ tag }>"
106
109
  end
107
110
 
108
111
  # catch special tagz methods
109
112
  #
110
- def method_missing m, *a, &b
113
+ def method_missing(m, *a, &b)
111
114
  strategy =
112
115
  case m.to_s
113
116
  when %r/^(.*[^_])_(!)?$/o
@@ -135,11 +138,14 @@ unless defined? Tagz
135
138
  m, bang = $1, $2
136
139
  b ||= lambda{} if bang
137
140
  tagz{ tagz__(m, *a, &b) }
141
+
138
142
  when :close_tag
139
143
  m = $1
140
144
  tagz{ __tagz(m, *a, &b) }
145
+
141
146
  when :element
142
147
  Tagz.element.new(*a, &b)
148
+
143
149
  when :puts
144
150
  tagz do
145
151
  tagz.push("\n")
@@ -205,7 +211,8 @@ unless defined? Tagz
205
211
  end
206
212
  self
207
213
  end
208
- def concat string
214
+
215
+ def concat(string)
209
216
  self << string
210
217
  end
211
218
  #alias_method 'concat', '<<'
@@ -215,7 +222,7 @@ unless defined? Tagz
215
222
  end
216
223
  alias_method 'h', 'escape'
217
224
 
218
- def puts string
225
+ def puts(string)
219
226
  write "#{ string }\n"
220
227
  end
221
228
 
@@ -235,11 +242,19 @@ unless defined? Tagz
235
242
  def to_str
236
243
  self
237
244
  end
245
+
246
+ def html_safe
247
+ self
248
+ end
249
+
250
+ def html_safe?
251
+ true
252
+ end
238
253
  end
239
254
  Tagz.singleton_class{ define_method(:document){ Tagz.namespace(:Document) } }
240
255
 
241
256
  class Element < ::String
242
- def Element.attributes options
257
+ def Element.attributes(options)
243
258
  unless options.empty?
244
259
  ' ' <<
245
260
  options.map do |key, value|
@@ -261,7 +276,7 @@ unless defined? Tagz
261
276
 
262
277
  attr 'name'
263
278
 
264
- def initialize name, *argv, &block
279
+ def initialize(name, *argv, &block)
265
280
  options = {}
266
281
  content = []
267
282
 
@@ -447,5 +462,5 @@ unless defined? Tagz
447
462
  (argv.empty? and block.nil?) ? ::Tagz : Tagz.tagz(*argv, &block)
448
463
  end
449
464
 
450
- Tagz.html_mode!
465
+ Tagz.xml_mode!
451
466
  end
data/lib/tagz/rails.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  if defined?(Rails)
2
- _ = ActionView, ActionView::Base, ActionController, ActionController::Base
3
- ActionView::Base.send(:include, Tagz.globally)
4
- ActionController::Base.send(:include, Tagz)
2
+ #_ = ActionView, ActionView::Base, ActionController, ActionController::Base
3
+ #ActionView::Base.send(:include, Tagz.globally)
4
+ #ActionController::Base.send(:include, Tagz)
5
+
6
+ unloadable(Tagz)
7
+ Tagz.xml_mode!
5
8
  end
data/tagz.gemspec CHANGED
@@ -3,25 +3,25 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "tagz"
6
- spec.version = "8.0.0"
6
+ spec.version = "8.1.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "tagz"
9
- spec.description = " tagz.rb is generates html, xml, or any sgml variant like a small ninja\n running across the backs of a herd of giraffes swatting of heads like\n a mark-up weedwacker. weighing in at less than 300 lines of code\n tagz.rb adds an html/xml/sgml syntax to ruby that is both unobtrusive,\n safe, and available globally to objects without the need for any\n builder or superfluous objects. tagz.rb is designed for applications\n that generate html to be able to do so easily in any context without\n heavyweight syntax or scoping issues, like a ninja sword through\n butter.\n"
9
+ spec.description = "\n tagz.rb is generates html, xml, or any sgml variant like a small ninja\n running across the backs of a herd of giraffes swatting of heads like\n a mark-up weedwacker. weighing in at less than 300 lines of code\n tagz.rb adds an html/xml/sgml syntax to ruby that is both unobtrusive,\n safe, and available globally to objects without the need for any\n builder or superfluous objects. tagz.rb is designed for applications\n that generate html to be able to do so easily in any context without\n heavyweight syntax or scoping issues, like a ninja sword through\n butter.\n\n"
10
10
 
11
- spec.files = ["lib", "lib/tagz", "lib/tagz/rails.rb", "lib/tagz.rb", "Rakefile", "README", "readme.erb", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb", "samples/g.rb", "tagz.gemspec", "test", "test/tagz.rb"]
11
+ spec.files = ["lib", "lib/tagz", "lib/tagz/rails.rb", "lib/tagz.rb", "Rakefile", "README", "readme.erb", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb", "samples/g.rb", "tagz.gemspec", "test", "test/tagz_test.rb"]
12
12
  spec.executables = []
13
13
 
14
14
  spec.require_path = "lib"
15
15
 
16
16
  spec.has_rdoc = true
17
- spec.test_files = "test/tagz.rb"
18
- #spec.add_dependency 'lib', '>= version'
19
- #spec.add_dependency 'fattr'
17
+ spec.test_files = nil
18
+
19
+ # spec.add_dependency 'lib', '>= version'
20
20
 
21
21
  spec.extensions.push(*[])
22
22
 
23
23
  spec.rubyforge_project = "codeforpeople"
24
24
  spec.author = "Ara T. Howard"
25
25
  spec.email = "ara.t.howard@gmail.com"
26
- spec.homepage = "http://github.com/ahoward/tagz/tree/master"
26
+ spec.homepage = "http://github.com/ahoward/tagz"
27
27
  end
@@ -10,6 +10,8 @@ $:.unshift '.'
10
10
 
11
11
  require 'tagz'
12
12
 
13
+ Tagz.html_mode!
14
+
13
15
  class TagzTest < Test::Unit::TestCase
14
16
  include Tagz
15
17
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 95
5
- prerelease: false
4
+ hash: 91
5
+ prerelease:
6
6
  segments:
7
7
  - 8
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 8.0.0
10
+ version: 8.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ara T. Howard
@@ -15,11 +15,22 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-09 00:00:00 -06:00
18
+ date: 2011-01-31 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
22
- description: " tagz.rb is generates html, xml, or any sgml variant like a small ninja\n running across the backs of a herd of giraffes swatting of heads like\n a mark-up weedwacker. weighing in at less than 300 lines of code\n tagz.rb adds an html/xml/sgml syntax to ruby that is both unobtrusive,\n safe, and available globally to objects without the need for any\n builder or superfluous objects. tagz.rb is designed for applications\n that generate html to be able to do so easily in any context without\n heavyweight syntax or scoping issues, like a ninja sword through\n butter.\n"
22
+ description: |+
23
+
24
+ tagz.rb is generates html, xml, or any sgml variant like a small ninja
25
+ running across the backs of a herd of giraffes swatting of heads like
26
+ a mark-up weedwacker. weighing in at less than 300 lines of code
27
+ tagz.rb adds an html/xml/sgml syntax to ruby that is both unobtrusive,
28
+ safe, and available globally to objects without the need for any
29
+ builder or superfluous objects. tagz.rb is designed for applications
30
+ that generate html to be able to do so easily in any context without
31
+ heavyweight syntax or scoping issues, like a ninja sword through
32
+ butter.
33
+
23
34
  email: ara.t.howard@gmail.com
24
35
  executables: []
25
36
 
@@ -41,9 +52,9 @@ files:
41
52
  - samples/f.rb
42
53
  - samples/g.rb
43
54
  - tagz.gemspec
44
- - test/tagz.rb
55
+ - test/tagz_test.rb
45
56
  has_rdoc: true
46
- homepage: http://github.com/ahoward/tagz/tree/master
57
+ homepage: http://github.com/ahoward/tagz
47
58
  licenses: []
48
59
 
49
60
  post_install_message:
@@ -72,9 +83,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
83
  requirements: []
73
84
 
74
85
  rubyforge_project: codeforpeople
75
- rubygems_version: 1.3.7
86
+ rubygems_version: 1.4.2
76
87
  signing_key:
77
88
  specification_version: 3
78
89
  summary: tagz
79
- test_files:
80
- - test/tagz.rb
90
+ test_files: []
91
+