script_helpers 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 592058ec6dc3b5b3534ace553e6fc89f82a3e360
4
+ data.tar.gz: 555dd972ada41744b8954c86086b9fd9eab99536
5
+ SHA512:
6
+ metadata.gz: 60d41dd7ee03464a42bce220f416303cd8cc3fb4cfdfda4f6b603f24afa4cd313e84021691f3ecd25d43a7e6321da1fcff909181a78583f00b52e8e03a72cc4f
7
+ data.tar.gz: 9ffb4c23f807a5790fb45c14bc9c654a181e323d9c26c95a5d4137d96316b907b6486ca310e974c894069f321f5ff17dce4c2c111eb50459e553c4eeddc6d8df
@@ -1,18 +1,20 @@
1
1
  module ScriptHelpers
2
- module HelperAdditions
2
+ module ScriptAndCssHelper
3
3
  def script(options = {}, &block)
4
4
  if options.include? :src
5
5
  @_script_helpers_script ||= {}
6
6
 
7
7
  unless @_script_helpers_script[options[:src]]
8
8
  @_script_helpers_script[options[:src]] = true
9
- content_for :script_tags, "\n#{javascript_include_tag options[:src]}".html_safe
9
+ content_for :script_tags, "\n"
10
+ content_for :script_tags, javascript_include_tag(options[:src])
10
11
  end
11
12
  end
12
13
 
13
14
  if block
14
15
  return javascript_tag &block if options[:inline]
15
- content_for :script, "\n#{capture &block}".html_safe
16
+ content_for :script, "\n"
17
+ content_for :script, capture(&block)
16
18
  end
17
19
 
18
20
  nil
@@ -25,10 +27,8 @@ module ScriptHelpers
25
27
  def script_contents
26
28
  contents = content_for :script
27
29
 
28
- if contents
29
- javascript_tag do
30
- contents
31
- end
30
+ if contents.present?
31
+ javascript_tag contents
32
32
  end
33
33
  end
34
34
 
@@ -38,12 +38,14 @@ module ScriptHelpers
38
38
 
39
39
  unless @_script_helpers_css[options[:src]]
40
40
  @_script_helpers_css[options[:src]] = true
41
- content_for :css_tags, "\n#{stylesheet_link_tag options[:src]}".html_safe
41
+ content_for :css_tags, "\n"
42
+ content_for :css_tags, stylesheet_link_tag(options[:src])
42
43
  end
43
44
  end
44
45
 
45
46
  if block
46
- content_for :css, "\n#{capture &block}".html_safe
47
+ content_for :css, "\n"
48
+ content_for :css, capture(&block)
47
49
  end
48
50
  end
49
51
 
@@ -54,13 +56,9 @@ module ScriptHelpers
54
56
  def css_contents
55
57
  contents = content_for :css
56
58
 
57
- if contents
58
- "<style type=\"text/css\">#{contents}</style>".html_safe
59
+ if contents.present?
60
+ content_tag :style, contents, :type => "text/css"
59
61
  end
60
62
  end
61
63
  end
62
64
  end
63
-
64
- module ApplicationHelper
65
- include ScriptHelpers::HelperAdditions
66
- end
@@ -7,12 +7,16 @@ module ScriptHelpers
7
7
  modified_application_layout = false
8
8
 
9
9
  unless application_layout_contents.include?("<%= script_contents %>") || application_layout_contents.include?("<%= script_tag_contents %>")
10
- gsub_file application_layout, /<\/body>/, "<%= script_tag_contents %>\n<%= script_contents %>\n</body>"
10
+ gsub_file application_layout, /( *)<\/body>/, ' \1<%= script_tag_contents %>
11
+ \1<%= script_contents %>
12
+ \1</body>'
11
13
  modified_application_layout = true
12
14
  end
13
15
 
14
16
  unless application_layout_contents.include?("<%= css_contents %>") || application_layout_contents.include?("<%= css_tag_contents %>")
15
- gsub_file application_layout, /<\/head>/, " <%= css_tag_contents %>\n <%= css_contents %>\n</head>"
17
+ gsub_file application_layout, /( *)<\/head>/, ' \1<%= css_tag_contents %>
18
+ \1<%= css_contents %>
19
+ \1</head>'
16
20
  modified_application_layout = true
17
21
  end
18
22
 
@@ -1 +1,12 @@
1
- require "script_helpers/helper_additions"
1
+ require "script_helpers/version"
2
+ require File.expand_path("../../app/helpers/script_helpers/script_and_css_helper.rb", __FILE__)
3
+
4
+ module ScriptHelpers
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ config.to_prepare do
8
+ ActionController::Base.helper ScriptHelpers::ScriptAndCssHelper
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module ScriptHelpers
2
+ class Version
3
+ class << self
4
+ def to_s
5
+ "0.3.0"
6
+ end
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,64 +1,67 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: script_helpers
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
10
5
  platform: ruby
11
- authors:
12
- - Mike Stone
6
+ authors:
7
+ - Mike Virata-Stone
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2011-07-19 00:00:00 -07:00
18
- default_executable:
19
- dependencies: []
20
-
11
+ date: 2013-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
21
33
  description: A Rails 3 gem that allows easy inlining of css and JavaScript
22
- email: stonemj@gmail.com
34
+ email: mike@virata-stone.com
23
35
  executables: []
24
-
25
36
  extensions: []
26
-
27
37
  extra_rdoc_files: []
28
-
29
- files:
38
+ files:
30
39
  - lib/generators/script_helpers/install/install_generator.rb
31
40
  - lib/script_helpers.rb
32
- - lib/script_helpers/helper_additions.rb
33
- has_rdoc: true
41
+ - lib/script_helpers/version.rb
42
+ - app/helpers/script_helpers/script_and_css_helper.rb
34
43
  homepage: https://github.com/mikestone/Script-Helpers
35
- licenses: []
36
-
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
37
47
  post_install_message:
38
48
  rdoc_options: []
39
-
40
- require_paths:
49
+ require_paths:
41
50
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- segments:
47
- - 0
48
- version: "0"
49
- required_rubygems_version: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
56
61
  requirements: []
57
-
58
62
  rubyforge_project:
59
- rubygems_version: 1.3.6
63
+ rubygems_version: 2.0.3
60
64
  signing_key:
61
- specification_version: 3
65
+ specification_version: 4
62
66
  summary: Script Helpers
63
67
  test_files: []
64
-