themes_for_rails 0.4.3 → 0.5.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +2 -0
  3. data/Gemfile.lock +40 -35
  4. data/README.textile +11 -235
  5. data/Rakefile +1 -0
  6. data/doc/README.textile +363 -0
  7. data/{REVIEW_NOTES → doc/REVIEW_NOTES} +0 -0
  8. data/{RMU_REVIEW → doc/RMU_REVIEW} +0 -0
  9. data/{TODO.textile → doc/TODO.textile} +0 -0
  10. data/lib/themes_for_rails.rb +7 -6
  11. data/lib/themes_for_rails/{controller_methods.rb → action_controller.rb} +15 -9
  12. data/lib/themes_for_rails/action_mailer.rb +22 -0
  13. data/lib/themes_for_rails/action_view.rb +59 -0
  14. data/lib/themes_for_rails/assets_controller.rb +12 -13
  15. data/lib/themes_for_rails/common_methods.rb +28 -10
  16. data/lib/themes_for_rails/config.rb +44 -7
  17. data/lib/themes_for_rails/interpolation.rb +11 -0
  18. data/lib/themes_for_rails/railtie.rb +13 -2
  19. data/lib/themes_for_rails/routes.rb +15 -4
  20. data/lib/themes_for_rails/url_helpers.rb +16 -12
  21. data/lib/themes_for_rails/version.rb +2 -1
  22. data/test/lib/{controller_methods_test.rb → action_controller_test.rb} +59 -9
  23. data/test/lib/{mailer_methods_test.rb → action_mailer_test.rb} +2 -1
  24. data/test/lib/action_view_test.rb +54 -0
  25. data/test/lib/assets_controller_test.rb +11 -2
  26. data/test/lib/common_methods_test.rb +12 -6
  27. data/test/lib/config_test.rb +3 -2
  28. data/test/lib/integration_test.rb +12 -0
  29. data/test/lib/routes_test.rb +3 -2
  30. data/test/lib/themes_for_rails_test.rb +3 -2
  31. data/test/support/extensions.rb +1 -0
  32. data/test/test_helper.rb +1 -0
  33. data/themes_for_rails.gemspec +1 -0
  34. metadata +44 -28
  35. data/lib/themes_for_rails/mailer_methods.rb +0 -21
  36. data/lib/themes_for_rails/view_helpers.rb +0 -51
  37. data/test/lib/view_helpers_test.rb +0 -38
@@ -1,21 +0,0 @@
1
- module ThemesForRails
2
- module MailerMethods
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- alias_method_chain :mail, :theme
7
- end
8
-
9
- module InstanceMethods
10
-
11
- def mail_with_theme(headers = {}, &block)
12
- theme_opts = headers[:theme] || self.class.default[:theme]
13
- theme(theme_opts) if theme_opts
14
-
15
- mail_without_theme(headers, &block)
16
- end
17
- end
18
- end
19
- end
20
-
21
- ActiveSupport.on_load(:action_mailer) { include ThemesForRails::MailerMethods }
@@ -1,51 +0,0 @@
1
- module ThemesForRails
2
- module ViewHelpers
3
-
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- include ThemesForRails::CommonMethods
8
- end
9
- module InstanceMethods
10
- def current_theme_stylesheet_path(asset)
11
- base_theme_stylesheet_path(:theme => self.theme_name, :asset => "#{asset}.css")
12
- end
13
- def current_theme_javascript_path(asset)
14
- base_theme_javascript_path(:theme => self.theme_name, :asset => "#{asset}.js")
15
- end
16
- def current_theme_image_path(asset)
17
- base_theme_image_path(:theme => self.theme_name, :asset => asset)
18
- end
19
-
20
- def theme_stylesheet_path(asset, new_theme_name = self.theme_name)
21
- base_theme_stylesheet_path(:theme => new_theme_name, :asset => "#{asset}.css")
22
- end
23
-
24
- def theme_javascript_path(asset, new_theme_name = self.theme_name)
25
- base_theme_javascript_path(:theme => new_theme_name, :asset => "#{asset}.js")
26
- end
27
-
28
- def theme_image_path(asset, new_theme_name = self.theme_name)
29
- base_theme_image_path(:theme => new_theme_name, :asset => asset)
30
- end
31
-
32
- def theme_image_tag(source, options = {})
33
- image_tag(theme_image_path(source), options)
34
- end
35
-
36
- def theme_javascript_include_tag(*files)
37
- files.collect! {|file| theme_javascript_path(file) }
38
- javascript_include_tag *files
39
- end
40
-
41
- def theme_stylesheet_link_tag(*files)
42
- options = files.extract_options!
43
- files.collect! {|file| theme_stylesheet_path(file) }
44
- files << options
45
- stylesheet_link_tag(*files)
46
- end
47
- end
48
- end
49
- end
50
-
51
- ActiveSupport.on_load(:action_view) { include ThemesForRails::ViewHelpers }
@@ -1,38 +0,0 @@
1
- require "test_helper"
2
-
3
- module ThemesForRails
4
- class ViewHelpersTest < ActionController::IntegrationTest
5
- include ThemesForRails::ViewHelpers
6
-
7
- include ActionView::Helpers::AssetTagHelper
8
- include ERB::Util
9
- include ActionView::Helpers::TagHelper
10
-
11
- def theme_name
12
- 'default'
13
- end
14
-
15
- def config
16
- @config ||= stub({:perform_caching => false, :asset_path => "/assets", :asset_host => ''})
17
- end
18
-
19
- should "provide path helpers for a given theme name" do
20
-
21
- assert_equal "/themes/sometheme/stylesheets/style.css", theme_stylesheet_path('style', "sometheme")
22
- assert_equal "/themes/sometheme/javascripts/app.js", theme_javascript_path('app', "sometheme")
23
- assert_equal "/themes/sometheme/images/logo.png", theme_image_path('logo.png', "sometheme")
24
-
25
- end
26
-
27
- should 'delegate to stylesheet_link_tag' do
28
- assert_match /media=.screen/, theme_stylesheet_link_tag('cuac.css')
29
- end
30
-
31
- should 'delegate options (lazy testing, I know)' do
32
- assert_match /media=.print/, theme_stylesheet_link_tag('cuac.css', :media => 'print')
33
- end
34
- should 'delegate options in image_tag' do
35
- assert_match /width=.40/, theme_image_tag('image.css', :size => '40x50')
36
- end
37
- end
38
- end