headliner 0.1.2 → 0.1.3

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/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rdoc/task'
3
- require File.join(File.dirname(__FILE__), 'lib', 'headliner')
3
+ require File.join(File.dirname(__FILE__), 'lib', 'headliner', 'version')
4
4
 
5
5
  require 'rspec/core'
6
6
  require 'rspec/core/rake_task'
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "headliner"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Patrick Crowley", "Alexander Shcherban"]
@@ -23,7 +23,9 @@ Gem::Specification.new do |s|
23
23
  "headliner.gemspec",
24
24
  "init.rb",
25
25
  "lib/headliner.rb",
26
- "pkg/headliner-0.1.1.gem",
26
+ "lib/headliner/action_view.rb",
27
+ "lib/headliner/railtie.rb",
28
+ "lib/headliner/version.rb",
27
29
  "spec/headliner_spec.rb",
28
30
  "spec/spec_helper.rb"
29
31
  ]
data/init.rb CHANGED
@@ -1,2 +1 @@
1
1
  require 'headliner'
2
- ActionView::Base.send :include, Headliner
@@ -1,71 +1,4 @@
1
1
  module Headliner
2
- VERSION = "0.1.2".freeze
3
-
4
- def title(options, headline='')
5
- if options.is_a? String
6
- save_title(options, headline)
7
- else
8
- display_title(options)
9
- end
10
- end
11
-
12
- def save_title(title, headline)
13
- @title = title.gsub(/<\/?[^>]*>/, '')
14
- headline.blank? ? title : headline
15
- end
16
-
17
- def display_title(options)
18
- # Prefix (leading space)
19
- if options[:prefix]
20
- prefix = options[:prefix]
21
- elsif options[:prefix] == false
22
- prefix = ''
23
- else
24
- prefix = ' '
25
- end
26
-
27
- # Separator
28
- unless options[:separator].blank?
29
- separator = options[:separator]
30
- else
31
- separator = '|'
32
- end
33
-
34
- # Suffix (trailing space)
35
- if options[:suffix]
36
- suffix = options[:suffix]
37
- elsif options[:suffix] == false
38
- suffix = ''
39
- else
40
- suffix = ' '
41
- end
42
-
43
- # Lowercase title?
44
- if options[:lowercase] == true
45
- @title = @title.downcase unless @title.blank?
46
- end
47
-
48
- # Default page title
49
- if @title.blank? && options[:default]
50
- @title = options[:default]
51
- end
52
-
53
- # Set website/page order
54
- unless @title.blank?
55
- if options[:reverse] == true
56
- # Reverse order => "Page : Website"
57
- return content_tag(:title, @title + prefix + separator + suffix + options[:site])
58
- else
59
- # Standard order => "Website : Page"
60
- return content_tag(:title, options[:site] + prefix + separator + suffix + @title)
61
- end
62
- end
63
-
64
- # If title is blank, return only website name
65
- content_tag :title, options[:site]
66
- end
67
-
68
- # Mr. T says, "Use my method, fool!"
69
- alias pt title
70
-
71
- end
2
+ autoload :ActionView, 'headliner/action_view'
3
+ end
4
+ require 'headliner/railtie'
@@ -0,0 +1,70 @@
1
+ module Headliner
2
+ module ActionView
3
+ def title(options, headline='')
4
+ if options.is_a? String
5
+ save_title(options, headline)
6
+ else
7
+ display_title(options)
8
+ end
9
+ end
10
+
11
+ def save_title(title, headline)
12
+ @title = title.gsub(/<\/?[^>]*>/, '')
13
+ headline.blank? ? title : headline
14
+ end
15
+
16
+ def display_title(options)
17
+ # Prefix (leading space)
18
+ if options[:prefix]
19
+ prefix = options[:prefix]
20
+ elsif options[:prefix] == false
21
+ prefix = ''
22
+ else
23
+ prefix = ' '
24
+ end
25
+
26
+ # Separator
27
+ unless options[:separator].blank?
28
+ separator = options[:separator]
29
+ else
30
+ separator = '|'
31
+ end
32
+
33
+ # Suffix (trailing space)
34
+ if options[:suffix]
35
+ suffix = options[:suffix]
36
+ elsif options[:suffix] == false
37
+ suffix = ''
38
+ else
39
+ suffix = ' '
40
+ end
41
+
42
+ # Lowercase title?
43
+ if options[:lowercase] == true
44
+ @title = @title.downcase unless @title.blank?
45
+ end
46
+
47
+ # Default page title
48
+ if @title.blank? && options[:default]
49
+ @title = options[:default]
50
+ end
51
+
52
+ # Set website/page order
53
+ unless @title.blank?
54
+ if options[:reverse] == true
55
+ # Reverse order => "Page : Website"
56
+ return content_tag(:title, @title + prefix + separator + suffix + options[:site])
57
+ else
58
+ # Standard order => "Website : Page"
59
+ return content_tag(:title, options[:site] + prefix + separator + suffix + @title)
60
+ end
61
+ end
62
+
63
+ # If title is blank, return only website name
64
+ content_tag :title, options[:site]
65
+ end
66
+
67
+ # Mr. T says, "Use my method, fool!"
68
+ alias pt title
69
+ end
70
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails'
2
+ require 'headliner'
3
+
4
+ module Headliner
5
+ class Railtie < Rails::Railtie
6
+ config.before_configuration do
7
+ ::ActionView::Base.send(:include, Headliner::ActionView)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Headliner
2
+ VERSION = "0.1.3".freeze
3
+ end
@@ -3,13 +3,13 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "Headliner" do
4
4
 
5
5
  before(:each) do
6
- @view = ActionView::Base.new
6
+ @view = ::ActionView::Base.new
7
7
  end
8
8
 
9
9
  describe "loading plugin" do
10
10
 
11
11
  it "should be mixed into ActionView::Base" do
12
- ActionView::Base.included_modules.include?(Headliner).should be_true
12
+ ::ActionView::Base.included_modules.include?(Headliner).should be_true
13
13
  end
14
14
 
15
15
  it "should respond to 'title' helper" do
@@ -1,8 +1,9 @@
1
1
  require 'rubygems'
2
+ require 'rails'
2
3
  require 'action_controller'
3
4
  require 'action_view'
4
5
  require File.join(File.dirname(__FILE__), "../lib/headliner")
5
6
 
6
- ActionView::Base.class_eval do
7
- include Headliner
7
+ ::ActionView::Base.class_eval do
8
+ include Headliner
8
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headliner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Crowley
@@ -35,7 +35,9 @@ files:
35
35
  - headliner.gemspec
36
36
  - init.rb
37
37
  - lib/headliner.rb
38
- - pkg/headliner-0.1.1.gem
38
+ - lib/headliner/action_view.rb
39
+ - lib/headliner/railtie.rb
40
+ - lib/headliner/version.rb
39
41
  - spec/headliner_spec.rb
40
42
  - spec/spec_helper.rb
41
43
  homepage: http://github.com/shura71/headliner
Binary file