w2tags 0.9.3 → 0.9.5

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.
Files changed (64) hide show
  1. data/COPYING +340 -340
  2. data/LICENSE +6 -6
  3. data/MIT-LICENSE +18 -18
  4. data/Manifest.txt +28 -25
  5. data/README.rdoc +27 -21
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/bin/w2tags +173 -143
  9. data/doc/History.rdoc +88 -0
  10. data/hot/erb.hot +18 -156
  11. data/hot/erb_base.hot +164 -0
  12. data/hot/html.hot +30 -31
  13. data/hot/rails/scaffold.hot +15 -15
  14. data/hot/vm.hot +8 -8
  15. data/hot/vm2.hot +34 -34
  16. data/hot/vm_crud.hot +34 -34
  17. data/hot/vm_popup.hot +74 -74
  18. data/lib/tags2w.rb +263 -0
  19. data/lib/w2tags/block/block_hot.rb +37 -0
  20. data/lib/w2tags/block/plain_text.rb +57 -57
  21. data/lib/w2tags/block/remark.rb +37 -37
  22. data/lib/w2tags/block/sass.rb +68 -66
  23. data/lib/w2tags/merb_hook.rb +15 -15
  24. data/lib/w2tags/parser.rb +17 -8
  25. data/lib/w2tags/rails_hook.rb +15 -15
  26. data/lib/w2tags/sinatra_hook.rb +74 -50
  27. data/lib/w2tags.rb +100 -100
  28. data/plugins/{/w2tags/ → w2tags}/README +2 -2
  29. data/plugins/{/w2tags//generators//w2scaffold/ → w2tags/generators/w2scaffold}/USAGE +29 -29
  30. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/controller.rb +85 -85
  31. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/functional_test.rb +45 -45
  32. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/helper.rb +2 -2
  33. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/helper_test.rb +4 -4
  34. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/layout.html.erb +17 -17
  35. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/style.css +54 -54
  36. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_edit.html.erb +17 -17
  37. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_edit.html.w2erb +16 -16
  38. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_index.html.erb +23 -23
  39. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_index.html.w2erb +13 -13
  40. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_new.html.erb +16 -16
  41. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_new.html.w2erb +15 -15
  42. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_show.html.erb +9 -9
  43. data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_show.html.w2erb +8 -8
  44. data/plugins/{/w2tags//generators//w2scaffold/ → w2tags/generators/w2scaffold}/w2scaffold_generator.rb +106 -106
  45. data/plugins/{/w2tags/ → w2tags}/install.rb +0 -0
  46. data/tasks/ann.rake +81 -81
  47. data/tasks/bones.rake +21 -21
  48. data/tasks/gem.rake +126 -126
  49. data/tasks/git.rake +41 -41
  50. data/tasks/manifest.rake +49 -49
  51. data/tasks/notes.rake +28 -28
  52. data/tasks/post_load.rake +39 -39
  53. data/tasks/rdoc.rake +51 -51
  54. data/tasks/rubyforge.rake +57 -57
  55. data/tasks/setup.rb +268 -268
  56. data/tasks/spec.rake +55 -55
  57. data/tasks/svn.rake +48 -48
  58. data/tasks/test.rake +38 -38
  59. data/test/vars.hot +30 -30
  60. data/test/w2tags_basic_usability.rb +187 -187
  61. data/test/w2tags_enlightning.rb +42 -42
  62. data/test/w2tags_hot.rb +85 -85
  63. data/test/w2tags_hot_var.rb +115 -115
  64. metadata +28 -30
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- = License Terms
2
-
3
- Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the
4
- {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt] by Widi Harsojo.
5
-
6
- Please email wharsojo[mailto:wharsojo@gmail.com] with any questions.
1
+ = License Terms
2
+
3
+ Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the
4
+ {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt] by Widi Harsojo.
5
+
6
+ Please email wharsojo[mailto:wharsojo@gmail.com] with any questions.
data/MIT-LICENSE CHANGED
@@ -1,18 +1,18 @@
1
- Copyright (c) 2008-2009 Widi Harsojo
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to
5
- deal in the Software without restriction, including without limitation the
6
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- sell copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
- THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2008-2009 Widi Harsojo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -12,15 +12,18 @@ doc/HAML.rdoc
12
12
  doc/History.rdoc
13
13
  doc/HOT.rdoc
14
14
  bin/w2tags
15
+ lib/tags2w.rb
15
16
  lib/w2tags.rb
16
17
  lib/w2tags/parser.rb
17
18
  lib/w2tags/merb_hook.rb
18
19
  lib/w2tags/rails_hook.rb
19
- lib/w2tags/sinatra_hook.rb
20
- lib/w2tags/block/plain_text.rb
21
- lib/w2tags/block/remark.rb
20
+ lib/w2tags/sinatra_hook.rb
21
+ lib/w2tags/block/block_hot.rb
22
+ lib/w2tags/block/plain_text.rb
23
+ lib/w2tags/block/remark.rb
22
24
  lib/w2tags/block/sass.rb
23
25
  hot/erb.hot
26
+ hot/erb_base.hot
24
27
  hot/erb_form.hot
25
28
  hot/erb_head.hot
26
29
  hot/erb_jquery.hot
@@ -71,25 +74,25 @@ test/feature.hot
71
74
  test/tricky.hot
72
75
  test/vars.hot
73
76
  plugins
74
- plugins\w2tags
75
- plugins\w2tags\generators
76
- plugins\w2tags\install.rb
77
- plugins\w2tags\README
78
- plugins\w2tags\generators\w2scaffold
79
- plugins\w2tags\generators\w2scaffold\templates
80
- plugins\w2tags\generators\w2scaffold\USAGE
81
- plugins\w2tags\generators\w2scaffold\w2scaffold_generator.rb
82
- plugins\w2tags\generators\w2scaffold\templates\controller.rb
83
- plugins\w2tags\generators\w2scaffold\templates\functional_test.rb
84
- plugins\w2tags\generators\w2scaffold\templates\helper.rb
85
- plugins\w2tags\generators\w2scaffold\templates\helper_test.rb
86
- plugins\w2tags\generators\w2scaffold\templates\layout.html.erb
87
- plugins\w2tags\generators\w2scaffold\templates\style.css
88
- plugins\w2tags\generators\w2scaffold\templates\view_edit.html.erb
89
- plugins\w2tags\generators\w2scaffold\templates\view_edit.html.w2erb
90
- plugins\w2tags\generators\w2scaffold\templates\view_index.html.erb
91
- plugins\w2tags\generators\w2scaffold\templates\view_index.html.w2erb
92
- plugins\w2tags\generators\w2scaffold\templates\view_new.html.erb
93
- plugins\w2tags\generators\w2scaffold\templates\view_new.html.w2erb
94
- plugins\w2tags\generators\w2scaffold\templates\view_show.html.erb
95
- plugins\w2tags\generators\w2scaffold\templates\view_show.html.w2erb
77
+ plugins/w2tags
78
+ plugins/w2tags/generators
79
+ plugins/w2tags/install.rb
80
+ plugins/w2tags/README
81
+ plugins/w2tags/generators/w2scaffold
82
+ plugins/w2tags/generators/w2scaffold/templates
83
+ plugins/w2tags/generators/w2scaffold/USAGE
84
+ plugins/w2tags/generators/w2scaffold/w2scaffold_generator.rb
85
+ plugins/w2tags/generators/w2scaffold/templates/controller.rb
86
+ plugins/w2tags/generators/w2scaffold/templates/functional_test.rb
87
+ plugins/w2tags/generators/w2scaffold/templates/helper.rb
88
+ plugins/w2tags/generators/w2scaffold/templates/helper_test.rb
89
+ plugins/w2tags/generators/w2scaffold/templates/layout.html.erb
90
+ plugins/w2tags/generators/w2scaffold/templates/style.css
91
+ plugins/w2tags/generators/w2scaffold/templates/view_edit.html.erb
92
+ plugins/w2tags/generators/w2scaffold/templates/view_edit.html.w2erb
93
+ plugins/w2tags/generators/w2scaffold/templates/view_index.html.erb
94
+ plugins/w2tags/generators/w2scaffold/templates/view_index.html.w2erb
95
+ plugins/w2tags/generators/w2scaffold/templates/view_new.html.erb
96
+ plugins/w2tags/generators/w2scaffold/templates/view_new.html.w2erb
97
+ plugins/w2tags/generators/w2scaffold/templates/view_show.html.erb
98
+ plugins/w2tags/generators/w2scaffold/templates/view_show.html.w2erb
data/README.rdoc CHANGED
@@ -1,27 +1,29 @@
1
1
  = W2TAGS
2
- === Run on MRI Ruby : 1.8.x / 1.9.x
2
+ === Run on MRI Ruby : 1.8.6 / 1.9.x
3
3
 
4
- C:\>w2tags -irb
4
+ me@ubuntu:~$ sudo gem install wharsojo-w2tags
5
+
6
+ me@ubuntu:~$ w2tags -irb
5
7
  ARGV : -irb
6
8
 
7
9
  Your W2Tags instance object stored in WH...
8
10
  Ex: puts WH.parse_line("#content\n %span Hello")
9
11
  Shortcut command => wh("#content\n %span Hello")
10
12
 
11
- irb(main):001:0> wh(<<END)
13
+ irb(main):001:0> wh <<END
12
14
  irb(main):002:0" #wow
13
- irb(main):003:0" #kereen
14
- irb(main):004:0" %span Hello World
15
+ irb(main):003:0" #kereen
16
+ irb(main):004:0" . Hello World
15
17
  irb(main):005:0" END
16
- =>C:/mingw/lib/ruby/gems/1.9.1/gems/w2tags-0.9.1/hot/html.hot
18
+ =>/usr/lib/ruby/gems/1.8/gems/wharsojo-w2tags-0.9.49/hot/erb.hot
17
19
  <div id="wow">
18
- <div id="kereen">
19
- <span>Hello World</span>
20
- </div>
20
+ <div id="kereen">
21
+ <div>Hello World</div>
22
+ </div>
21
23
  </div>
22
24
  => nil
23
25
  irb(main):006:0>
24
-
26
+
25
27
  == DESCRIPTION:
26
28
 
27
29
  W2Tags is the way to tags, a short cut / macros. When it do, it use some patern
@@ -202,8 +204,11 @@ and code in source:
202
204
 
203
205
  == REQUIREMENTS:
204
206
 
205
- no requirement for now, since it use only regular expression to do
206
- parsing.
207
+ no requirement for w2tags (the parser), since it use only regular expression
208
+ to do parsing.
209
+
210
+ converting .erb or .html need hpricot engine to do search tags (see below
211
+ on command no.10)
207
212
 
208
213
  == INSTALL:
209
214
 
@@ -216,21 +221,22 @@ get it from commandline "w2tags"
216
221
  How to WaytoTags:
217
222
  ~~~~~~~~~~~~~~~~~~~~~~~
218
223
  syntax:
219
- w2tags [*.w2htm] [-a] [-d:*opt*]
224
+ w2tags [*.w2erb] [-a] [-d:*opt*]
220
225
  OR
221
226
  w2tags [file1,file2,file3] [-b] [-d:*opt*]
222
227
 
223
228
  example:
224
- 1. w2tags -a #=> translate all file with ext: w2htm
225
- 2. w2tags *.w2xml -a #=> translate all file with ext: w2xml
226
- 3. w2tags file1.w2htm #=> translate a file
227
- 4. w2tags file1.w2htm -b #=> translate a file with no initialize/finalize
228
- 5. w2tags file1.w2htm -d:parser #=> translate with debug parser
229
- 6. w2tags file1.w2htm -d:constanta #=> translate with debug constanta
230
- 7. w2tags file1.w2htm -d:stack #=> translate with debug stack indentation
229
+ 1. w2tags -a #=> translate all file with ext: w2erb
230
+ 2. w2tags *.w2erb -a #=> translate all file with ext: w2erb
231
+ 3. w2tags file1.w2erb #=> translate a file
232
+ 4. w2tags file1.w2erb -b #=> translate a file with no initialize/finalize
233
+ 5. w2tags file1.w2erb -d:parser #=> translate with debug parser
234
+ 6. w2tags file1.w2erb -d:constanta #=> translate with debug constanta
235
+ 7. w2tags file1.w2erb -d:stack #=> translate with debug stack indentation
231
236
  8. w2tags -irb #=> Start IRB with WH as instance object of W2Tags
232
237
  9. w2tags -rails #=> Copy w2scaffold Rails and set environment.rb
233
-
238
+ 10. w2tags -tags2w #=> Parsing erb to w2tags
239
+
234
240
  Enjoy...
235
241
 
236
242
  === RAILS HOOK
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ task :default => 'spec:run'
12
12
  PROJ.name = 'w2tags'
13
13
  PROJ.authors = 'widi harsojo'
14
14
  PROJ.email = 'wharsojo@gmail.com'
15
- PROJ.url = 'w2tags.rubyforge.org'
15
+ PROJ.url = 'http://w2tags.rubyforge.org'
16
16
  PROJ.rubyforge.name = 'w2tags'
17
17
 
18
18
  PROJ.rdoc.opts << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.4.2
data/bin/w2tags CHANGED
@@ -1,143 +1,173 @@
1
- #!/usr/bin/env ruby
2
- # The command line W2tags parser.
3
- # How to WaytoTags:
4
- # ~~~~~~~~~~~~~~~~~~~~~~~
5
- # syntax:
6
- # w2tags [*.w2htm] [-a] [-d:*opt*]
7
- # OR
8
- # w2tags [file1,file2,file3] [-b] [-d:*opt*]
9
- #
10
- # example:
11
- # 1. w2tags -a #=> translate all file with ext: w2htm
12
- # 2. w2tags *.w2xml -a #=> translate all file with ext: w2xml
13
- # 3. w2tags file1.w2htm #=> translate a file
14
- # 4. w2tags file1.w2htm -b #=> translate a file with no initialize/finalize
15
- # 5. w2tags file1.w2htm -d:parser #=> translate with debug parser
16
- # 6. w2tags file1.w2htm -d:constanta #=> translate with debug constanta
17
- # 7. w2tags file1.w2htm -d:stack #=> translate with debug stack indentation
18
- # 8. w2tags -irb #=> Start IRB with WT as instant object of W2Tags
19
- #
20
- # Enjoy...
21
-
22
- require File.expand_path(
23
- File.join(File.dirname(__FILE__),%w[.. lib w2tags]))
24
- wpath= File.dirname(__FILE__).gsub(/bin$/,'')
25
- def howto_w2tags
26
- puts <<END
27
-
28
- How to WaytoTags:
29
- ~~~~~~~~~~~~~~~~~~~~~~~
30
- syntax:
31
- w2tags [*.w2htm] [-a] [-d:*opt*]
32
- OR
33
- w2tags [file1,file2,file3] [-b] [-d:*opt*]
34
-
35
- example:
36
- 1. w2tags -a #=> translate all file with ext: w2htm
37
- 2. w2tags *.w2xml -a #=> translate all file with ext: w2xml
38
- 3. w2tags file1.w2htm #=> translate a file
39
- 4. w2tags file1.w2htm -b #=> translate a file with no initialize/finalize
40
- 5. w2tags file1.w2htm -d:parser #=> translate with debug parser
41
- 6. w2tags file1.w2htm -d:constanta #=> translate with debug constanta
42
- 7. w2tags file1.w2htm -d:stack #=> translate with debug stack indentation
43
- 8. w2tags -irb #=> Start IRB with WH as instance object of W2Tags
44
- 9. w2tags -rails #=> Copy w2scaffold Rails and set environment.rb
45
-
46
- Enjoy...
47
- END
48
-
49
- end
50
-
51
- arg = ARGV
52
- if arg.size>0
53
- arg = ['w2htm'] + arg if arg.size==1 && arg[0]=='-a'
54
- puts 'ARGV : '+arg.join(" ")
55
- puts arg[1]
56
-
57
- WH = W2Tags::Parser.new
58
-
59
- x = arg.select {|s|s[0,3]=='-d:'}
60
- #WH.dbg[:stack] = (x.size==0)
61
- x.each do |s|
62
- WH.dbg[:parse] = true if s=='-d:parser'
63
- WH.dbg[:stack] = true if s=='-d:stack'
64
- WH.dbg[:constanta] = true if s=='-d:constanta'
65
- WH.dbg[:show_hot] = true if s=='-d:show_hot'
66
- end
67
-
68
- if arg[0]=='-irb'
69
- ARGV.shift
70
-
71
- class Object
72
- def wh(str)
73
- puts WH.parse_line(str)
74
- end
75
- end
76
-
77
- require 'irb'
78
- puts "Your W2Tags instance object stored in WH..."
79
- puts 'Ex: puts WH.parse_line "#content\\n %span Hello"'
80
- puts 'Shortcut wh() => puts WH.parse_line()'
81
- puts ''
82
-
83
- IRB.start
84
- elsif arg[0]=='-rails'
85
- if !File.exist?('vendor/plugins')
86
- puts 'No Folder: vendor/plugins...'
87
- elsif !File.exist?('config/environment.rb')
88
- puts 'No File: config/environment.rb...'
89
- else
90
- ttl_copy = 0
91
- require 'fileutils'
92
- Dir[wpath + "plugins/**/*"].each do |fl|
93
- if !File.directory?(fl)
94
- path= fl.gsub(/.*\/plugins\//,'vendor/plugins/')
95
- dir = File.dirname(path)
96
- FileUtils.mkdir_p(dir) if !File.exist?(dir)
97
- if !File.exist?(path)
98
- ttl_copy += 1
99
- puts "Copy w2tags plugins for rails..." if ttl_copy==1
100
- puts "=> #{fl.gsub(/.*\/w2tags\//,'')}"
101
- File.open(path, 'wb') { |file| file.write(File.read(fl)) }
102
- end
103
- end
104
- end
105
- ttl_copy = 0
106
- Dir[wpath + "hot/rails/**/*"].each do |fl|
107
- path= fl.gsub(/.*\/rails\//,'')
108
- if !File.exist?(path)
109
- ttl_copy += 1
110
- puts "Copy w2tags HOT files..." if ttl_copy==1
111
- puts "=> #{path}"
112
- File.open(path, 'wb') { |file| file.write(File.read(fl)) }
113
- end
114
- end
115
- content = File.read('config/environment.rb')
116
- ori= content.length
117
- content << "\nrequire 'w2tags'" if /\n *require *\'w2tags\'/ !~ content
118
- content << "\nrequire 'w2tags/rails_hook'" if /\n *require *\'w2tags\/rails_hook\'/ !~ content
119
- if ori != content.length
120
- puts 'Update config/environment.rb...'
121
- File.open('config/environment.rb', 'wb') { |file| file.write(content) }
122
- end
123
- puts(<<END)
124
-
125
- FINISH W2TAGS for RAILS...
126
- You can try w2scaffold:
127
-
128
- script/generate w2scaffold post title:string body:text published:boolean
129
- rake db:migrate
130
- script/server
131
-
132
- END
133
- end
134
- else
135
- case arg[1]
136
- when '-a' ;WH.parse_files(Dir["*.#{arg[0]}*"])
137
- when '-b' ;WH.parse_files(arg[0].split(','),false)
138
- else ;WH.parse_files(arg[0].split(','))
139
- end
140
- end
141
- else
142
- howto_w2tags
143
- end
1
+ #!/usr/bin/env ruby
2
+ # The command line W2tags parser.
3
+ # How to WaytoTags:
4
+ # ~~~~~~~~~~~~~~~~~~~~~~~
5
+ # syntax:
6
+ # w2tags [*.w2erb] [-a] [-d:*opt*]
7
+ # OR
8
+ # w2tags [file1,file2,file3] [-b] [-d:*opt*]
9
+ #
10
+ # example:
11
+ # 1. w2tags -a #=> translate all file with ext: w2erb
12
+ # 2. w2tags *.w2erb -a #=> translate all file with ext: w2erb
13
+ # 3. w2tags file1.w2erb #=> translate a file
14
+ # 4. w2tags file1.w2erb -b #=> translate a file with no initialize/finalize
15
+ # 5. w2tags file1.w2erb -d:parser #=> translate with debug parser
16
+ # 6. w2tags file1.w2erb -d:constanta #=> translate with debug constanta
17
+ # 7. w2tags file1.w2erb -d:stack #=> translate with debug stack indentation
18
+ # 8. w2tags -irb #=> Start IRB with WT as instant object of W2Tags
19
+ # 9. w2tags -rails #=> Copy w2scaffold Rails and set environment.rb
20
+ # 10. w2tags -tags2w #=> Parsing erb to w2tags
21
+ #
22
+ # Enjoy...
23
+
24
+ require File.expand_path(
25
+ File.join(File.dirname(__FILE__),%w[.. lib w2tags]))
26
+ wpath= File.dirname(__FILE__).gsub(/bin$/,'')
27
+ def howto_w2tags
28
+ puts <<END
29
+
30
+ How to WaytoTags:
31
+ ~~~~~~~~~~~~~~~~~~~~~~~
32
+ syntax:
33
+ w2tags [*.w2erb] [-a] [-d:*opt*]
34
+ OR
35
+ w2tags [file1,file2,file3] [-b] [-d:*opt*]
36
+
37
+ example:
38
+ 1. w2tags -a #=> translate all file with ext: w2erb
39
+ 2. w2tags *.w2erb -a #=> translate all file with ext: w2erb
40
+ 3. w2tags file1.w2erb #=> translate a file
41
+ 4. w2tags file1.w2erb -b #=> translate a file with no initialize/finalize
42
+ 5. w2tags file1.w2erb -d:parser #=> translate with debug parser
43
+ 6. w2tags file1.w2erb -d:constanta #=> translate with debug constanta
44
+ 7. w2tags file1.w2erb -d:stack #=> translate with debug stack indentation
45
+ 8. w2tags -irb #=> Start IRB with WH as instance object of W2Tags
46
+ 9. w2tags -rails #=> Copy w2scaffold Rails and set environment.rb
47
+ 10.w2tags -tags2w #=> Parsing erb to w2tags
48
+
49
+ Enjoy...
50
+ END
51
+
52
+ end
53
+
54
+ arg = ARGV
55
+ if arg.size>0
56
+ arg = ['w2erb'] + arg if arg.size==1 && arg[0]=='-a'
57
+ puts 'ARGV : '+arg.join(" ")
58
+ puts arg[1]
59
+
60
+ WH = W2Tags::Parser.new
61
+
62
+ x = arg.select {|s|s[0,3]=='-d:'}
63
+ #WH.dbg[:stack] = (x.size==0)
64
+ x.each do |s|
65
+ WH.dbg[:parse] = true if s=='-d:parser'
66
+ WH.dbg[:stack] = true if s=='-d:stack'
67
+ WH.dbg[:constanta] = true if s=='-d:constanta'
68
+ WH.dbg[:show_hot] = true if s=='-d:show_hot'
69
+ end
70
+
71
+ if arg[0]=='-irb'
72
+ ARGV.shift
73
+
74
+ class Object
75
+ def wh(str)
76
+ puts WH.parse_line(str)
77
+ end
78
+ end
79
+
80
+ require 'irb'
81
+ puts "Your W2Tags instance object stored in WH..."
82
+ puts 'Ex: puts WH.parse_line "#content\\n %span Hello"'
83
+ puts 'Shortcut wh() => puts WH.parse_line()'
84
+ puts ''
85
+
86
+ IRB.start
87
+ elsif arg[0]=='-rails'
88
+ if !File.exist?('vendor/plugins')
89
+ puts 'No Folder: vendor/plugins...'
90
+ elsif !File.exist?('config/environment.rb')
91
+ puts 'No File: config/environment.rb...'
92
+ else
93
+ ttl_copy = 0
94
+ require 'fileutils'
95
+ Dir[wpath + "plugins/**/*"].each do |fl|
96
+ if !File.directory?(fl)
97
+ path= fl.gsub(/.*\/plugins\//,'vendor/plugins/')
98
+ dir = File.dirname(path)
99
+ FileUtils.mkdir_p(dir) if !File.exist?(dir)
100
+ if !File.exist?(path)
101
+ ttl_copy += 1
102
+ puts "Copy w2tags plugins for rails..." if ttl_copy==1
103
+ puts "=> #{fl.gsub(/.*\/w2tags\//,'')}"
104
+ File.open(path, 'wb') { |file| file.write(File.read(fl)) }
105
+ end
106
+ end
107
+ end
108
+ ttl_copy = 0
109
+ Dir[wpath + "hot/rails/**/*"].each do |fl|
110
+ path= fl.gsub(/.*\/rails\//,'')
111
+ if !File.exist?(path)
112
+ ttl_copy += 1
113
+ puts "Copy w2tags HOT files..." if ttl_copy==1
114
+ puts "=> #{path}"
115
+ File.open(path, 'wb') { |file| file.write(File.read(fl)) }
116
+ end
117
+ end
118
+ content = File.read('config/environment.rb')
119
+ ori= content.length
120
+ content << "\nrequire 'w2tags'" if /\n *require *\'w2tags\'/ !~ content
121
+ content << "\nrequire 'w2tags/rails_hook'" if /\n *require *\'w2tags\/rails_hook\'/ !~ content
122
+ if ori != content.length
123
+ puts 'Update config/environment.rb...'
124
+ File.open('config/environment.rb', 'wb') { |file| file.write(content) }
125
+ end
126
+ puts(<<END)
127
+
128
+ FINISH W2TAGS for RAILS...
129
+ You can try w2scaffold:
130
+
131
+ script/generate w2scaffold post title:string body:text published:boolean
132
+ rake db:migrate
133
+ script/server
134
+
135
+ END
136
+ end
137
+ elsif arg[0]=='-tags2w'
138
+ require 'tags2w'
139
+ t2t = MakeTag.new
140
+ t2w = Tags2w.new
141
+ fls = Dir['./**/views/**/*.erb']
142
+ fls = Dir['./**/*.erb'] if fls==[]
143
+
144
+ fls.each do |f|
145
+ puts f
146
+ lines= IO.read(f).delete("\r").split("\n")
147
+ t2t.make_it(lines)
148
+ if arg[1]=='-debug'
149
+ File.open(f.gsub('.erb','.w1erb'),'w') do |wr|
150
+ wr << lines.join("\n")
151
+ end
152
+ end
153
+ #hp = Hpricot(lines.join("\n"))
154
+ hp =Hpricot::XML(lines.join("\n"))
155
+ t2w.start(hp).line_code
156
+ File.open(f.gsub('.erb','.w2erb'),'w') do |wr|
157
+ wr << t2w.result.join("\n")
158
+ end
159
+ end
160
+ else
161
+ case arg[1]
162
+ when '-a' ;
163
+ fls = Dir["./**/views/**/#{arg[0]}"]
164
+ fls = Dir["./**/#{arg[0]}"] if fls==[]
165
+ #WH.parse_files(Dir["*.#{arg[0]}*"])
166
+ WH.parse_files(fls)
167
+ when '-b' ;WH.parse_files(arg[0].split(','),false)
168
+ else ;WH.parse_files(arg[0].split(','))
169
+ end
170
+ end
171
+ else
172
+ howto_w2tags
173
+ end
data/doc/History.rdoc CHANGED
@@ -2,6 +2,94 @@
2
2
 
3
3
  Below is a complete listing of changes for each revision of W2TAGS.
4
4
 
5
+ == 0.9.5
6
+
7
+ === Command line
8
+
9
+ Help Information change from w2html to w2erb, for params like
10
+
11
+ w2tags *.w2erb -a
12
+
13
+ it will parse all w2tags type 'erb' from folder view or if not found,
14
+ it will parse from current folder down to child folder
15
+
16
+ === tags2w
17
+
18
+ using index (not find_index), for compactible with ruby version 1.8.6
19
+
20
+ === Parser
21
+
22
+ Include Source now doesn't have default ext (.w2ex), for easy maintenace
23
+ of source code.
24
+
25
+ !inc!partial.w2erb
26
+
27
+ Remember command / Next command have multi class for parameters convert
28
+ to multiple line
29
+
30
+ %table
31
+ %tr
32
+ ^.c;.r No;Info
33
+
34
+ <table>
35
+ <tr>
36
+ <td class="c">No</td>
37
+ <td class="r">Info</td>
38
+ </tr>
39
+ </table>
40
+
41
+ === Add Condition Hook for Sinatra 0.9.2
42
+
43
+ Since sinatra change again method of "lookup_template", the Hook must add another
44
+ condition Hook.
45
+ Sinatra Hook update, it a same behaviour with Rails
46
+
47
+ === block_hot
48
+
49
+ add a block for hot so you can put your hot block inside your code (embed) mean
50
+ that you hot is only for this code only
51
+
52
+ === tags2w
53
+
54
+ Fix: html - erb with ruby sanitize code: "<%- -%>"
55
+
56
+ === HOT files
57
+
58
+ ==== erb.hot
59
+
60
+ add tag "%comment" since reverse erb to w2tags (tags2w) use this tag and it must
61
+ be play nice (no parsing inside it).
62
+
63
+ change form_tag, form_to, using block var
64
+
65
+ == 0.9.4
66
+
67
+ === Tags To W (Reverse parse to w2tags)
68
+
69
+ Implement Reverse parse to w2tags, it use Hpricot::XML and it cover standard
70
+ or basic reverse parse, for css and block of js not include (one day hack).
71
+
72
+ === HOT files
73
+
74
+ ==== erb.hot
75
+
76
+ add condition for unless
77
+
78
+ ==== html.hot
79
+
80
+ Fix old template for "initialize"
81
+
82
+ === Parser
83
+
84
+ ==== Update Debug parser
85
+
86
+ debug parser for uniq Var update to standarize with others -d:parser
87
+
88
+ ==== Update Regex for "reHot"
89
+
90
+ to cover inline w2tags, if inline w2tags include all Key-Variable it fail
91
+ since "reHot" use greedy regex, now fix with non greedy.
92
+
5
93
  == 0.9.3
6
94
 
7
95
  === Pass test on Linux Ubuntu 8.10 and win32