shway 3.0
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 +11 -0
- data/Manifest +41 -0
- data/README +14 -0
- data/Rakefile +47 -0
- data/init.rb +2 -0
- data/install.rb +0 -0
- data/install_files/javascripts/iepngfix.htc +193 -0
- data/install_files/javascripts/iepngfix_tilebg.js +155 -0
- data/install_files/stylesheets/reset.css +47 -0
- data/install_files/templates/example_presenter.rb +12 -0
- data/install_files/templates/example_stylesheet.css.rb +20 -0
- data/lib/rubygems/commands/shway_init_command.rb +112 -0
- data/lib/rubygems_plugin.rb +3 -0
- data/lib/shway/controllers/shway_controller.rb +22 -0
- data/lib/shway/css/css_helper.rb +221 -0
- data/lib/shway/css/css_parser.rb +155 -0
- data/lib/shway/css/css_styles.rb +368 -0
- data/lib/shway/extensions/routing_extensions.rb +22 -0
- data/lib/shway/helpers/html_helper.rb +54 -0
- data/lib/shway/helpers/shway_controller_helper.rb +51 -0
- data/lib/shway/helpers/shway_helper.rb +187 -0
- data/lib/shway/presenters/shway_model_presenter.rb +10 -0
- data/lib/shway/presenters/shway_presenter.rb +184 -0
- data/lib/shway/test/shway_test_helper.rb +78 -0
- data/lib/shway.rb +129 -0
- data/shway.gemspec +31 -0
- data/templates/css.html.erb +3 -0
- data/templates/css.rhtml +3 -0
- data/test/shway_core/css_config_test.rb +186 -0
- data/test/shway_core/css_helper_test.rb +655 -0
- data/test/shway_core/css_parser_test.rb +219 -0
- data/test/shway_core/html_helper_test.rb +32 -0
- data/test/shway_core/shway_controller_test.rb +44 -0
- data/test/shway_core/shway_core_test_helper.rb +45 -0
- data/test/shway_core/shway_helper_test.rb +280 -0
- data/test/shway_core/shway_presenter_test.rb +173 -0
- data/test/shway_core/shway_routes_test.rb +31 -0
- data/test/shway_core/views/mock_foos/_list_header.html.erb +1 -0
- data/test/shway_core/views/mock_foos/_list_item.html.erb +5 -0
- data/test/shway_core/views/model_list/list_for_action.html.erb +1 -0
- data/test/shway_core/views/model_list/list_item_for_action.html.erb +1 -0
- data/test/shway_core/views/shway_helper_test.html.erb +24 -0
- metadata +123 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'shway_test_helper')
|
|
2
|
+
|
|
3
|
+
class ShwayPresenterController < ActionController::Base
|
|
4
|
+
|
|
5
|
+
before_filter :set_view_paths
|
|
6
|
+
|
|
7
|
+
def set_view_paths
|
|
8
|
+
self.view_paths = [File.join(File.dirname(__FILE__), 'views')]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@foo = 'foo'
|
|
13
|
+
end
|
|
14
|
+
def controller_method
|
|
15
|
+
:my_controller_method
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class SomeModel
|
|
20
|
+
def name
|
|
21
|
+
'Some Model Name'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class SomeModelPresenter < ShwayModelPresenter
|
|
26
|
+
renderer_with_method :display_name do
|
|
27
|
+
r some_model.name
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class TestPresenter < ShwayPresenter
|
|
32
|
+
|
|
33
|
+
#TODO figure out why I can't add these here.
|
|
34
|
+
# shway_helper :test_shway_helper_with_style, :padding_right => 15
|
|
35
|
+
# shway_helper :test_shway_helper_without_style, :padding => 20
|
|
36
|
+
|
|
37
|
+
attr_accessor :foo, :bar
|
|
38
|
+
|
|
39
|
+
def set_something(value)
|
|
40
|
+
@something = value
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def get_something
|
|
44
|
+
@something
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
#define renderers like this
|
|
48
|
+
renderer :default do |options|
|
|
49
|
+
options ||= {}
|
|
50
|
+
options[:text] ||= 'Test Presenter'
|
|
51
|
+
r div(:text => options[:text])
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
renderer :foo do
|
|
55
|
+
r div(:text => 'Foo')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
renderer :nested do
|
|
59
|
+
r div
|
|
60
|
+
r 'Nested'
|
|
61
|
+
r render(:foo)
|
|
62
|
+
r _div
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
renderer :with_rails_helpers do
|
|
66
|
+
r h(div(:text => "escape me"))
|
|
67
|
+
r link_to('text', 'url')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class ShwayPresenterTest < ActiveSupport::TestCase
|
|
73
|
+
|
|
74
|
+
attr_reader :presenter
|
|
75
|
+
def setup
|
|
76
|
+
@presenter = TestPresenter.new(ActionView::Base.new)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_raises_when_no_template_is_given
|
|
80
|
+
assert_raise ArgumentError do
|
|
81
|
+
ShwayPresenter.new
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_raises_when_something_other_than_a_template_is_given_first
|
|
86
|
+
assert_raise RuntimeError do
|
|
87
|
+
ShwayPresenter.new :key => :value
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_can_render_with_default_renderer
|
|
92
|
+
assert_match 'Test Presenter', presenter.render
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_can_render_with_default_renderer_and_options
|
|
96
|
+
my_test_text = "My Test Text"
|
|
97
|
+
assert_match my_test_text, presenter.render(:text => my_test_text)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_can_access_shared_instance_variable
|
|
101
|
+
presenter = TestPresenter.new(new_test_controller(ShwayPresenterController))
|
|
102
|
+
assert_equal 'foo', presenter.shared_instance_variable(:@foo)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_can_use_presenter_initialized_with_a_controller
|
|
106
|
+
presenter = TestPresenter.new(new_test_controller(ShwayPresenterController))
|
|
107
|
+
assert_match 'Test Presenter', presenter.render
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_can_use_presenter_initialized_with_another_presenter
|
|
111
|
+
presenter = TestPresenter.new(@presenter)
|
|
112
|
+
assert_match 'Test Presenter', presenter.render
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_can_render_other_renderer
|
|
116
|
+
assert_match 'Foo', presenter.render(:foo)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#TODO figure out why I can't add shway_helpers here (see above in the presenter)
|
|
120
|
+
# def test_can_render_shway_helper_from_template
|
|
121
|
+
# @controller = new_test_controller(ShwayPresenterController)
|
|
122
|
+
# @presenter = TestPresenter.new(@controller)
|
|
123
|
+
# get :shway_helper_test
|
|
124
|
+
# assert_response :success
|
|
125
|
+
# end
|
|
126
|
+
|
|
127
|
+
def test_can_render_with_model_renderer
|
|
128
|
+
assert_equal 'Some Model Name', presenter.presenter_for(SomeModel.new).display_name
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_initializing_presenter_with_options_sets_matching_attr_accessors
|
|
132
|
+
@presenter = TestPresenter.new(ActionView::Base.new, :foo => :my_foo, :bar => :my_bar)
|
|
133
|
+
assert_equal :my_foo, presenter.foo
|
|
134
|
+
assert_equal :my_bar, presenter.bar
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def test_initializing_presenter_with_options_sets_matching_settable_methods
|
|
138
|
+
@presenter = TestPresenter.new(ActionView::Base.new, :set_something => :my_something)
|
|
139
|
+
assert_equal :my_something, presenter.get_something
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_initializing_presenter_with_options_places_non_attr_accessor_options_in_the_options_hash
|
|
143
|
+
presenter = TestPresenter.new(ActionView::Base.new, :additional_option => :my_additional_option)
|
|
144
|
+
assert_equal :my_additional_option, presenter.options[:additional_option]
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_initializing_presenter_with_options_places_non_attr_accessor_options_in_the_options_hash_if_method_is_not_settable
|
|
148
|
+
presenter = TestPresenter.new(ActionView::Base.new, :get_something => :my_something)
|
|
149
|
+
assert_equal :my_something, presenter.options[:get_something]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_presenter_passes_method_missing_through_when_nonexistent_method_is_encountered
|
|
153
|
+
assert_raise NoMethodError do
|
|
154
|
+
presenter.nonexistent_method
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_presenter_passes_method_missing_to_controller_when_controller_method_is_encountered
|
|
159
|
+
presenter = TestPresenter.new(new_test_controller(ShwayPresenterController))
|
|
160
|
+
assert_equal :my_controller_method, presenter.controller_method
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_can_render_nested_renderers
|
|
164
|
+
output = presenter.render(:nested)
|
|
165
|
+
assert_match 'Foo', output
|
|
166
|
+
assert_match 'Nested', output
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def uses_rails_helpers
|
|
170
|
+
assert_match '<a href="url">text</a>', presenter.render(:with_rails_helpers)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'shway_test_helper')
|
|
2
|
+
|
|
3
|
+
class ShwayRoutesTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def test_css_route
|
|
6
|
+
assert_route('/stylesheets/global-main.css', 'shway', 'css', :css => 'global-main')
|
|
7
|
+
#running these again doesn't really test anything extra
|
|
8
|
+
# assert_route('/stylesheets/global-ie6.css', 'shway', 'css', :css => 'global-ie6')
|
|
9
|
+
# assert_route('/stylesheets/global-ie.css', 'shway', 'css', :css => 'global-ie7')
|
|
10
|
+
# assert_route('/stylesheets/global-safari.css', 'shway', 'css', :css => 'global-safari')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_css_browser_route
|
|
14
|
+
#this is disabled for now, so we are testing that it is in fact disabled.
|
|
15
|
+
assert_raises RuntimeError do
|
|
16
|
+
get '/css_browser'
|
|
17
|
+
end
|
|
18
|
+
# assert_route('/css_browser', 'shway', 'css_style_browser')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# def test_css_reload_route
|
|
22
|
+
# assert_route('/css_reload', 'shway', 'css_style_reload')
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def assert_route(url, expected_controller, expected_action, expected_params={})
|
|
28
|
+
assert_routing(url, {:controller => expected_controller, :action => expected_action}.merge(expected_params))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MOCK FOOS LIST HEADER
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= list_for(@foo_list, MockFoo, :mock_option => :foo_option) %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= list_item_for(@foo) %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
<%= @presenter.test_shway_helper_with_style :text => 'text for test_shway_helper_with_style', :margin_bottom => 10 %>
|
|
3
|
+
|
|
4
|
+
<%= @presenter.test_shway_helper_without_style :text => 'text for test_shway_helper_without_style', :margin_bottom => 20 %>
|
|
5
|
+
|
|
6
|
+
<% @presenter.test_shway_helper_with_style :margin_bottom => 30 do %>
|
|
7
|
+
block text for test_shway_helper_with_style
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% @presenter.test_shway_helper_without_style :margin_bottom => 40 do %>
|
|
11
|
+
block text for test_shway_helper_without_style
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<%= @presenter.test_shway_helper_with_style :text => 'span for test_shway_helper_with_style', :tag => :span, :padding => 5 %>
|
|
15
|
+
|
|
16
|
+
<%= @presenter.test_shway_helper_without_style :text => 'span for test_shway_helper_without_style', :tag => :span, :padding => 5 %>
|
|
17
|
+
|
|
18
|
+
<% @presenter.test_shway_helper_with_style :tag => :span, :padding => 5 do %>
|
|
19
|
+
block span for test_shway_helper_with_style
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<% @presenter.test_shway_helper_without_style :tag => :span, :padding => 5 do %>
|
|
23
|
+
block span for test_shway_helper_without_style
|
|
24
|
+
<% end %>
|
metadata
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: shway
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: "3.0"
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ryan Owens
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-07-28 00:00:00 -04:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Provides powerful UI programming with dynamic css and presenters..
|
|
17
|
+
email: ryan@infoether.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- CHANGELOG
|
|
24
|
+
- lib/rubygems/commands/shway_init_command.rb
|
|
25
|
+
- lib/rubygems_plugin.rb
|
|
26
|
+
- lib/shway/controllers/shway_controller.rb
|
|
27
|
+
- lib/shway/css/css_helper.rb
|
|
28
|
+
- lib/shway/css/css_parser.rb
|
|
29
|
+
- lib/shway/css/css_styles.rb
|
|
30
|
+
- lib/shway/extensions/routing_extensions.rb
|
|
31
|
+
- lib/shway/helpers/html_helper.rb
|
|
32
|
+
- lib/shway/helpers/shway_controller_helper.rb
|
|
33
|
+
- lib/shway/helpers/shway_helper.rb
|
|
34
|
+
- lib/shway/presenters/shway_model_presenter.rb
|
|
35
|
+
- lib/shway/presenters/shway_presenter.rb
|
|
36
|
+
- lib/shway/test/shway_test_helper.rb
|
|
37
|
+
- lib/shway.rb
|
|
38
|
+
- README
|
|
39
|
+
files:
|
|
40
|
+
- CHANGELOG
|
|
41
|
+
- init.rb
|
|
42
|
+
- install.rb
|
|
43
|
+
- install_files/javascripts/iepngfix.htc
|
|
44
|
+
- install_files/javascripts/iepngfix_tilebg.js
|
|
45
|
+
- install_files/stylesheets/reset.css
|
|
46
|
+
- install_files/templates/example_presenter.rb
|
|
47
|
+
- install_files/templates/example_stylesheet.css.rb
|
|
48
|
+
- lib/rubygems/commands/shway_init_command.rb
|
|
49
|
+
- lib/rubygems_plugin.rb
|
|
50
|
+
- lib/shway/controllers/shway_controller.rb
|
|
51
|
+
- lib/shway/css/css_helper.rb
|
|
52
|
+
- lib/shway/css/css_parser.rb
|
|
53
|
+
- lib/shway/css/css_styles.rb
|
|
54
|
+
- lib/shway/extensions/routing_extensions.rb
|
|
55
|
+
- lib/shway/helpers/html_helper.rb
|
|
56
|
+
- lib/shway/helpers/shway_controller_helper.rb
|
|
57
|
+
- lib/shway/helpers/shway_helper.rb
|
|
58
|
+
- lib/shway/presenters/shway_model_presenter.rb
|
|
59
|
+
- lib/shway/presenters/shway_presenter.rb
|
|
60
|
+
- lib/shway/test/shway_test_helper.rb
|
|
61
|
+
- lib/shway.rb
|
|
62
|
+
- Manifest
|
|
63
|
+
- Rakefile
|
|
64
|
+
- README
|
|
65
|
+
- templates/css.html.erb
|
|
66
|
+
- templates/css.rhtml
|
|
67
|
+
- test/shway_core/css_config_test.rb
|
|
68
|
+
- test/shway_core/css_helper_test.rb
|
|
69
|
+
- test/shway_core/css_parser_test.rb
|
|
70
|
+
- test/shway_core/html_helper_test.rb
|
|
71
|
+
- test/shway_core/shway_controller_test.rb
|
|
72
|
+
- test/shway_core/shway_core_test_helper.rb
|
|
73
|
+
- test/shway_core/shway_helper_test.rb
|
|
74
|
+
- test/shway_core/shway_presenter_test.rb
|
|
75
|
+
- test/shway_core/shway_routes_test.rb
|
|
76
|
+
- test/shway_core/views/mock_foos/_list_header.html.erb
|
|
77
|
+
- test/shway_core/views/mock_foos/_list_item.html.erb
|
|
78
|
+
- test/shway_core/views/model_list/list_for_action.html.erb
|
|
79
|
+
- test/shway_core/views/model_list/list_item_for_action.html.erb
|
|
80
|
+
- test/shway_core/views/shway_helper_test.html.erb
|
|
81
|
+
- shway.gemspec
|
|
82
|
+
has_rdoc: true
|
|
83
|
+
homepage: http://rubyforge.org/projects/shway
|
|
84
|
+
licenses: []
|
|
85
|
+
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options:
|
|
88
|
+
- --line-numbers
|
|
89
|
+
- --inline-source
|
|
90
|
+
- --title
|
|
91
|
+
- Shway
|
|
92
|
+
- --main
|
|
93
|
+
- README
|
|
94
|
+
require_paths:
|
|
95
|
+
- lib
|
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: "0"
|
|
101
|
+
version:
|
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: "1.2"
|
|
107
|
+
version:
|
|
108
|
+
requirements: []
|
|
109
|
+
|
|
110
|
+
rubyforge_project: shway
|
|
111
|
+
rubygems_version: 1.3.5
|
|
112
|
+
signing_key:
|
|
113
|
+
specification_version: 3
|
|
114
|
+
summary: Provides powerful UI programming with dynamic css and presenters..
|
|
115
|
+
test_files:
|
|
116
|
+
- test/shway_core/css_config_test.rb
|
|
117
|
+
- test/shway_core/css_helper_test.rb
|
|
118
|
+
- test/shway_core/css_parser_test.rb
|
|
119
|
+
- test/shway_core/html_helper_test.rb
|
|
120
|
+
- test/shway_core/shway_controller_test.rb
|
|
121
|
+
- test/shway_core/shway_helper_test.rb
|
|
122
|
+
- test/shway_core/shway_presenter_test.rb
|
|
123
|
+
- test/shway_core/shway_routes_test.rb
|