masterview 0.0.11 → 0.0.12

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/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 0.0.12 - April 24, 2006 - Fixed generator to use Controller name for files it generates, added attr directive, added more default styles to css, added styles to generator templates
2
+
1
3
  0.0.11 - April 22, 2006 - Changed the main load file to rescue LoadErrors from log4r and tidy
2
4
 
3
5
  0.0.6 - April 18, 2006 - Working on generator packaging
data/README CHANGED
@@ -53,15 +53,15 @@ After this MasterView is ready for use. Skip down to the Usage section for more
53
53
 
54
54
  === Installation without using gems, install as plugin
55
55
 
56
- script/plugin install masterview
56
+ script/plugin install svn://rubyforge.org/var/svn/masterview
57
57
 
58
- This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. You may also retrieve the plugin package (.tgz and .zip) from Rubyforge.org searching for the project masterview_complete.
58
+ This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. Note that if you don't have svn (subversion) installed, you may also retrieve the plugin package (masterview_plugin.tgz or masterview_plugin.zip) from http://rubyforge.org/projects/masterview and simply extract into vendor/plugins/masterview
59
59
 
60
60
  == Usage
61
61
 
62
62
  You may add MasterView attributes to existing (x)html or you may use the masterview generator to create a complete working application. The generator can create controllers, models, and the MasterView template file similar to how the built-in generator works. Simply change directory to your rails application and run the following
63
63
 
64
- script/generate masterview YourModelName
64
+ script/generate masterview YourModelName [YourControllerName]
65
65
 
66
66
  Once it is done generating, the generated MasterView template file will be created in app/views/masterview/YourModelName.html. This file is html and can be edited with any standard html editor. The rails specific logic is contained in simple attributes which are ignored by html editors. The syntax for these attributes is heavily derived from the rails helper tags themselves so it should feel natural to the rails developer.
67
67
 
@@ -171,7 +171,24 @@ mv:gen_replace="whatToLeave"
171
171
  <div>
172
172
  <form></form>
173
173
  </div>
174
-
174
+
175
+ mv:attr=":foo => 'bar', :cat => #{h product.name}"
176
+ At runtime this sets attribute values on the element this directive is defined on, for example...
177
+
178
+ <div mv:attr=":foo => 'bar', :hi => 'cat'">hello</div>
179
+
180
+ becomes
181
+
182
+ <div foo="bar" hi="cat">hello</div>
183
+
184
+ You can put erb evaluated code in #{ } like in this example
185
+
186
+ <div mv:attr=":foo => #{h product.name}, :hi => 'cat'">hello</div>
187
+
188
+ becomes
189
+
190
+ <div foo="<%= h product.name %>" hi="cat">hello</div>
191
+
175
192
  mv:block="rubyBlockCodeHere"
176
193
  At runtime this expands to the equivalent rhtml (erb) block code around this element, for example...
177
194
 
data/RELEASE_NOTES CHANGED
@@ -43,9 +43,9 @@ Install in one of the two following ways depending on whether you can use gems o
43
43
 
44
44
  If you can use gems you may simply do the following
45
45
 
46
- gem install masterview
46
+ gem install masterview_gem_pack
47
47
 
48
- Now your gem is installed and you can skip that step in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
48
+ Now your gem is installed and you can skip these steps in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
49
49
 
50
50
  script/generate masterview_plugin
51
51
 
@@ -53,13 +53,13 @@ After this MasterView is ready for use. Skip down to the Usage section for more
53
53
 
54
54
  === Installation without using gems, install as plugin
55
55
 
56
- script/plugin install masterview
56
+ script/plugin install svn://rubyforge.org/var/svn/masterview
57
57
 
58
- This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. You may also retrieve the plugin package (.tgz and .zip) from Rubyforge.org searching for the project masterview_complete.
58
+ This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. Note that if you don't have svn (subversion) installed, you may also retrieve the plugin package (masterview_plugin.tgz or masterview_plugin.zip) from http://rubyforge.org/projects/masterview and simply extract into vendor/plugins/masterview
59
59
 
60
60
  == Usage
61
61
 
62
62
  You may add MasterView attributes to existing (x)html or you may use the masterview generator to create a complete working application. The generator can create controllers, models, and the MasterView template file similar to how the built-in generator works. Simply change directory to your rails application and run the following
63
63
 
64
- script/generate masterview YourModelName
64
+ script/generate masterview YourModelName [YourControllerName]
65
65
 
data/Rakefile CHANGED
@@ -105,13 +105,14 @@ end
105
105
  # Rake::SshDirPublisher.new("foobar.com", "dist/api/#{PKG_NAME}", "doc").upload
106
106
  #end
107
107
 
108
-
108
+ desc 'Verify RUBYFORGE_USER and RUBYFORGE_PASSWORD'
109
109
  task :verify_rubyforge do
110
110
  raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
111
111
  raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
112
112
  MASTERVIEW = MetaProject::Project::XForge::RubyForge.new('masterview')
113
113
  end
114
114
 
115
+ desc 'Verify GMAIL_USER GMAIL_PASSWORD'
115
116
  task :verify_gmail do
116
117
  raise "GMAIL_USER environment variable not set!" unless ENV['GMAIL_USER']
117
118
  raise "GMAIL_PASSWORD environment variable not set!" unless ENV['GMAIL_PASSWORD']
@@ -0,0 +1,27 @@
1
+ module MasterView
2
+ module Directives
3
+ # takes the attr_value and parses it as a hash :foo => 'bar', :baz => 'cat'
4
+ # it sets/overrides the tag's attribute values for each value.
5
+ # To use erb output simply wrap the content in #{ foo } for example :foo => #{h product.name}
6
+ class Attr < MasterView::DirectiveBase
7
+ # substitution to make it easy to parse erb in attr
8
+ SubstForErb = '#'+InlineErbStart+'= \1 '+InlineErbEnd+'#'
9
+
10
+ def priority
11
+ DirectivePriorities::MediumLow
12
+ end
13
+
14
+ def stag(dcs)
15
+
16
+ attr_value.gsub!( /#\{([^}]*)\}/, SubstForErb ) #taking #{h product.name} and changing to #{{{= h product.name}}}# for easy parsing
17
+ arr = attr_value.scan( /:(\w+)\s*=>\s*(['"#])([^,\2]*)\2,?/ )
18
+ arr.each do |scn|
19
+ n = scn[0]
20
+ v = scn[2]
21
+ dcs.context[:tag].attributes[n] = v
22
+ end
23
+ dcs.render
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,7 +2,7 @@ module MasterView
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 11
5
+ TINY = 12
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/test/attr_test.rb ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ currentPath = File.dirname(__FILE__)
5
+ require File.join( currentPath, '../lib/masterview' )
6
+ require File.join( currentPath, '../lib/masterview/directives/attr')
7
+
8
+ class TestAttr < Test::Unit::TestCase
9
+ include MasterView::Directives
10
+
11
+ def setup
12
+ @directives = MasterView::DirectiveSet.new
13
+ @tag = MasterView::Tag.new(@directives, 'foo', {'bar' => 'cat'}, :normal, nil)
14
+ end
15
+
16
+ def test_hello
17
+ @directives.directives = []
18
+ attr_value = "{:hello => 'world'}"
19
+ @directives << Attr.new(attr_value)
20
+ dcs = @directives.determine_dcs(:stag)
21
+ dcs.context = @tag.create_context
22
+ assert_equal '', dcs.render.join
23
+ assert_equal 'cat', dcs.context[:tag].attributes['bar']
24
+ assert_equal 'world', dcs.context[:tag].attributes['hello']
25
+ end
26
+
27
+ def test_hello_hi
28
+ @directives.directives = []
29
+ attr_value = ":hello => 'world', :hi => 'there'"
30
+ @directives << Attr.new(attr_value)
31
+ dcs = @directives.determine_dcs(:stag)
32
+ dcs.context = @tag.create_context
33
+ assert_equal '', dcs.render.join
34
+ assert_equal 'cat', dcs.context[:tag].attributes['bar']
35
+ assert_equal 'world', dcs.context[:tag].attributes['hello']
36
+ assert_equal 'there', dcs.context[:tag].attributes['hi']
37
+ end
38
+
39
+ def test_hello_erb
40
+ @directives.directives = []
41
+ attr_value = %q":hello => 'world', :hi => 'there', :wow => #{h product.name}"
42
+ @directives << Attr.new(attr_value)
43
+ dcs = @directives.determine_dcs(:stag)
44
+ dcs.context = @tag.create_context
45
+ assert_equal '', dcs.render.join
46
+ assert_equal 'cat', dcs.context[:tag].attributes['bar']
47
+ assert_equal 'world', dcs.context[:tag].attributes['hello']
48
+ assert_equal 'there', dcs.context[:tag].attributes['hi']
49
+ assert_equal '{{{= h product.name }}}', dcs.context[:tag].attributes['wow']
50
+ end
51
+
52
+ end
@@ -1,11 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require 'test/unit'
2
4
  currentPath = File.dirname(__FILE__)
3
5
  require File.join( currentPath, '../lib/masterview' )
4
6
  require File.join( currentPath, 'test_helper' )
5
- include MasterView::Directives
6
7
 
7
8
  class TestTemplate < Test::Unit::TestCase
8
9
 
10
+ def test_attr
11
+ template = <<-END
12
+ <div mv:generate='foo/bar'>
13
+ <span class="red" mv:attr=":class => 'blue', :id => 'testid'">foo bar</span>
14
+ </div>
15
+ END
16
+ expected = {
17
+ 'foo/bar' => "<div><span class=\"blue\" id=\"testid\">foo bar</span></div>"
18
+ }
19
+ assert_template_result expected, template
20
+ end
21
+
22
+ def test_attr_erb
23
+ template = <<-END
24
+ <div mv:generate='foo/bar'>
25
+ <span class="red" mv:attr=":class => 'blue', :id => '{{{= @product.id }}}'">foo bar</span>
26
+ </div>
27
+ END
28
+ expected = {
29
+ 'foo/bar' => "<div><span class=\"blue\" id=\"<%= @product.id %>\">foo bar</span></div>"
30
+ }
31
+ assert_template_result expected, template
32
+ end
33
+
34
+ def test_attr_erb2
35
+ template = <<-END
36
+ <div mv:generate='foo/bar'>
37
+ <span class="red" mv:attr=":class => 'blue', :id => \#\{@product.id\}">foo bar</span>
38
+ </div>
39
+ END
40
+ expected = {
41
+ 'foo/bar' => "<div><span class=\"blue\" id=\"<%= @product.id %>\">foo bar</span></div>"
42
+ }
43
+ assert_template_result expected, template
44
+ end
45
+
9
46
  def test_multi
10
47
  template = <<-END
11
48
  <div mv:generate='foo/bar'>
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: masterview
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.11
7
- date: 2006-04-22 00:00:00 -05:00
6
+ version: 0.0.12
7
+ date: 2006-04-24 00:00:00 -05:00
8
8
  summary: A (x)html friendly template engine for rails with the power of layouts, and partials.
9
9
  require_paths:
10
10
  - lib
@@ -28,79 +28,81 @@ cert_chain:
28
28
  authors:
29
29
  - Jeff Barczewski
30
30
  files:
31
+ - lib/facets
31
32
  - lib/masterview
32
33
  - lib/masterview.rb
33
- - lib/facets
34
+ - lib/facets/ProjectInfo
35
+ - lib/facets/AUTHORS
36
+ - lib/facets/CHANGELOG
37
+ - lib/facets/COPYING
38
+ - lib/facets/README
39
+ - lib/facets/core/string
40
+ - lib/facets/core/string/starts_with.rb
41
+ - lib/facets/core/string/indent.rb
42
+ - lib/facets/core/string/blank.rb
34
43
  - lib/masterview/directives
35
44
  - lib/masterview/extras
36
- - lib/masterview/directive_base.rb
37
- - lib/masterview/masterview_version.rb
38
- - lib/masterview/parser.rb
39
45
  - lib/masterview/plugin_load_tracking.rb
46
+ - lib/masterview/directive_helpers.rb
40
47
  - lib/masterview/runtime_helpers.rb
41
48
  - lib/masterview/string_extensions.rb
42
- - lib/masterview/directive_helpers.rb
43
- - lib/masterview/directives/block.rb
44
- - lib/masterview/directives/content.rb
45
- - lib/masterview/directives/else.rb
46
- - lib/masterview/directives/elsif.rb
47
- - lib/masterview/directives/form.rb
49
+ - lib/masterview/directive_base.rb
50
+ - lib/masterview/masterview_version.rb
51
+ - lib/masterview/parser.rb
48
52
  - lib/masterview/directives/global_inline_erb.rb
49
- - lib/masterview/directives/hidden_field.rb
50
- - lib/masterview/directives/if.rb
51
- - lib/masterview/directives/javascript_include.rb
52
- - lib/masterview/directives/link_to.rb
53
53
  - lib/masterview/directives/link_to_if.rb
54
- - lib/masterview/directives/link_to_remote.rb
55
- - lib/masterview/directives/password_field.rb
56
54
  - lib/masterview/directives/preview.rb
57
- - lib/masterview/directives/replace.rb
58
- - lib/masterview/directives/stylesheet_link.rb
59
55
  - lib/masterview/directives/testfilter.rb
60
- - lib/masterview/directives/text_area.rb
56
+ - lib/masterview/directives/password_field.rb
61
57
  - lib/masterview/directives/text_field.rb
58
+ - lib/masterview/directives/else.rb
59
+ - lib/masterview/directives/block.rb
60
+ - lib/masterview/directives/if.rb
61
+ - lib/masterview/directives/hidden_field.rb
62
+ - lib/masterview/directives/link_to.rb
63
+ - lib/masterview/directives/elsif.rb
64
+ - lib/masterview/directives/form.rb
62
65
  - lib/masterview/directives/submit.rb
63
66
  - lib/masterview/directives/insert_generated_comment.rb
67
+ - lib/masterview/directives/stylesheet_link.rb
68
+ - lib/masterview/directives/javascript_include.rb
69
+ - lib/masterview/directives/link_to_remote.rb
70
+ - lib/masterview/directives/content.rb
71
+ - lib/masterview/directives/replace.rb
72
+ - lib/masterview/directives/text_area.rb
73
+ - lib/masterview/directives/attr.rb
64
74
  - lib/masterview/extras/rails_init.rb
65
75
  - lib/masterview/extras/watcher.rb
66
- - lib/facets/README
67
- - lib/facets/ProjectInfo
68
- - lib/facets/COPYING
69
- - lib/facets/CHANGELOG
70
- - lib/facets/AUTHORS
71
- - lib/facets/core/string
72
- - lib/facets/core/string/starts_with.rb
73
- - lib/facets/core/string/indent.rb
74
- - lib/facets/core/string/blank.rb
75
- - test/block_test.rb
76
- - test/content_test.rb
76
+ - test/run_parser_test.rb
77
+ - test/test_helper.rb
78
+ - test/template_file_watcher_test.rb
79
+ - test/global_inline_erb_test.rb
80
+ - test/password_field_test.rb
81
+ - test/text_field_test.rb
77
82
  - test/else_test.rb
78
- - test/elsif_test.rb
83
+ - test/block_test.rb
79
84
  - test/example_test.rb
80
- - test/filter_helpers_test.rb
81
- - test/form_test.rb
82
- - test/global_inline_erb_test.rb
83
- - test/hidden_field_test.rb
85
+ - test/parser_test.rb
84
86
  - test/if_test.rb
85
- - test/javascript_include_test.rb
86
- - test/link_to_if_test.rb
87
+ - test/hidden_field_test.rb
87
88
  - test/link_to_test.rb
88
- - test/parser_test.rb
89
- - test/password_field_test.rb
90
- - test/replace_test.rb
91
- - test/run_parser_test.rb
92
- - test/stylesheet_link_test.rb
89
+ - test/elsif_test.rb
90
+ - test/form_test.rb
93
91
  - test/submit_test.rb
94
- - test/template_file_watcher_test.rb
95
- - test/template_test.rb
96
- - test/test_helper.rb
92
+ - test/javascript_include_test.rb
93
+ - test/stylesheet_link_test.rb
94
+ - test/filter_helpers_test.rb
97
95
  - test/text_area_test.rb
98
- - test/text_field_test.rb
96
+ - test/content_test.rb
97
+ - test/replace_test.rb
98
+ - test/template_test.rb
99
+ - test/link_to_if_test.rb
100
+ - test/attr_test.rb
99
101
  - CHANGELOG
100
- - MIT-LICENSE
101
102
  - Rakefile
102
- - README
103
103
  - RELEASE_NOTES
104
+ - MIT-LICENSE
105
+ - README
104
106
  - init.rb
105
107
  test_files: []
106
108