smart_titles 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +42 -0
- data/Gemfile +2 -10
- data/Gemfile.lock +18 -61
- data/Rakefile +1 -48
- data/lib/smart_titles.rb +2 -24
- data/lib/smart_titles/helper.rb +20 -0
- data/lib/smart_titles/railtie.rb +1 -0
- data/lib/smart_titles/version.rb +3 -0
- data/smart_titles.gemspec +23 -0
- data/spec/smart_titles_helper_spec.rb +22 -0
- metadata +22 -66
- data/spec/smart_titles_spec.rb +0 -15
data/.gitignore
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
#
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
#
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
#
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
data/Gemfile
CHANGED
@@ -1,12 +1,4 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
|
-
group :development do
|
8
|
-
gem "rspec-rails"
|
9
|
-
gem "bundler", "~> 1.0.0"
|
10
|
-
gem "jeweler", "~> 1.5.1"
|
11
|
-
gem "rcov", ">= 0"
|
12
|
-
end
|
3
|
+
# Specify your gem's dependencies in smart_titles.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,71 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
smart_titles (0.1.2.pre)
|
5
|
+
actionpack
|
6
|
+
activesupport
|
7
|
+
|
1
8
|
GEM
|
2
9
|
remote: http://rubygems.org/
|
3
10
|
specs:
|
4
11
|
abstract (1.0.0)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
actionpack (3.0.3)
|
9
|
-
activemodel (= 3.0.3)
|
10
|
-
activesupport (= 3.0.3)
|
12
|
+
actionpack (3.0.5)
|
13
|
+
activemodel (= 3.0.5)
|
14
|
+
activesupport (= 3.0.5)
|
11
15
|
builder (~> 2.1.2)
|
12
16
|
erubis (~> 2.6.6)
|
13
17
|
i18n (~> 0.4)
|
14
18
|
rack (~> 1.2.1)
|
15
19
|
rack-mount (~> 0.6.13)
|
16
|
-
rack-test (~> 0.5.
|
20
|
+
rack-test (~> 0.5.7)
|
17
21
|
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.
|
19
|
-
activesupport (= 3.0.
|
22
|
+
activemodel (3.0.5)
|
23
|
+
activesupport (= 3.0.5)
|
20
24
|
builder (~> 2.1.2)
|
21
25
|
i18n (~> 0.4)
|
22
|
-
|
23
|
-
activemodel (= 3.0.3)
|
24
|
-
activesupport (= 3.0.3)
|
25
|
-
arel (~> 2.0.2)
|
26
|
-
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.3)
|
28
|
-
activemodel (= 3.0.3)
|
29
|
-
activesupport (= 3.0.3)
|
30
|
-
activesupport (3.0.3)
|
31
|
-
arel (2.0.6)
|
26
|
+
activesupport (3.0.5)
|
32
27
|
builder (2.1.2)
|
33
28
|
diff-lcs (1.1.2)
|
34
29
|
erubis (2.6.6)
|
35
30
|
abstract (>= 1.0.0)
|
36
|
-
git (1.2.5)
|
37
31
|
i18n (0.5.0)
|
38
|
-
jeweler (1.5.1)
|
39
|
-
bundler (~> 1.0.0)
|
40
|
-
git (>= 1.2.5)
|
41
|
-
rake
|
42
|
-
mail (2.2.11)
|
43
|
-
activesupport (>= 2.3.6)
|
44
|
-
i18n (~> 0.5.0)
|
45
|
-
mime-types (~> 1.16)
|
46
|
-
treetop (~> 1.4.8)
|
47
|
-
mime-types (1.16)
|
48
|
-
polyglot (0.3.1)
|
49
32
|
rack (1.2.1)
|
50
33
|
rack-mount (0.6.13)
|
51
34
|
rack (>= 1.0.0)
|
52
|
-
rack-test (0.5.
|
35
|
+
rack-test (0.5.7)
|
53
36
|
rack (>= 1.0)
|
54
|
-
rails (3.0.3)
|
55
|
-
actionmailer (= 3.0.3)
|
56
|
-
actionpack (= 3.0.3)
|
57
|
-
activerecord (= 3.0.3)
|
58
|
-
activeresource (= 3.0.3)
|
59
|
-
activesupport (= 3.0.3)
|
60
|
-
bundler (~> 1.0)
|
61
|
-
railties (= 3.0.3)
|
62
|
-
railties (3.0.3)
|
63
|
-
actionpack (= 3.0.3)
|
64
|
-
activesupport (= 3.0.3)
|
65
|
-
rake (>= 0.8.7)
|
66
|
-
thor (~> 0.14.4)
|
67
|
-
rake (0.8.7)
|
68
|
-
rcov (0.9.9)
|
69
37
|
rspec (2.2.0)
|
70
38
|
rspec-core (~> 2.2)
|
71
39
|
rspec-expectations (~> 2.2)
|
@@ -74,22 +42,11 @@ GEM
|
|
74
42
|
rspec-expectations (2.2.0)
|
75
43
|
diff-lcs (~> 1.1.2)
|
76
44
|
rspec-mocks (2.2.0)
|
77
|
-
|
78
|
-
actionpack (~> 3.0)
|
79
|
-
activesupport (~> 3.0)
|
80
|
-
railties (~> 3.0)
|
81
|
-
rspec (~> 2.2.0)
|
82
|
-
thor (0.14.6)
|
83
|
-
treetop (1.4.9)
|
84
|
-
polyglot (>= 0.3.1)
|
85
|
-
tzinfo (0.3.23)
|
45
|
+
tzinfo (0.3.24)
|
86
46
|
|
87
47
|
PLATFORMS
|
88
48
|
ruby
|
89
49
|
|
90
50
|
DEPENDENCIES
|
91
|
-
|
92
|
-
|
93
|
-
rails (>= 2.3.5)
|
94
|
-
rcov
|
95
|
-
rspec-rails
|
51
|
+
rspec
|
52
|
+
smart_titles!
|
data/Rakefile
CHANGED
@@ -1,49 +1,2 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler'
|
3
|
-
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
11
|
-
|
12
|
-
require 'jeweler'
|
13
|
-
Jeweler::Tasks.new do |gem|
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
-
gem.name = "smart_titles"
|
16
|
-
gem.homepage = "http://github.com/semaperepelitsa/smart_titles"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{Really convenient way to set up page titles in Rails application.}
|
19
|
-
gem.email = "sema@sema.in"
|
20
|
-
gem.authors = ["Semyon Perepelitsa"]
|
21
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
22
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
23
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
24
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core'
|
29
|
-
require 'rspec/core/rake_task'
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
-
spec.rcov = true
|
37
|
-
end
|
38
|
-
|
39
|
-
task :default => :spec
|
40
|
-
|
41
|
-
require 'rake/rdoctask'
|
42
|
-
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "smart_titles #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
end
|
2
|
+
Bundler::GemHelper.install_tasks
|
data/lib/smart_titles.rb
CHANGED
@@ -1,24 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
def page_title(default = nil)
|
5
|
-
title if @page_title.nil?
|
6
|
-
@page_title != MISSING_TRANSLATION ? @page_title : default
|
7
|
-
end
|
8
|
-
|
9
|
-
def title(str = nil)
|
10
|
-
if str.nil?
|
11
|
-
str = t('.title')
|
12
|
-
@page_title = t('.title', :default => [:title, MISSING_TRANSLATION])
|
13
|
-
else
|
14
|
-
@page_title = str
|
15
|
-
end
|
16
|
-
content_tag(:h1, str)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module ActionView
|
21
|
-
class Base
|
22
|
-
include SmartTitlesHelper
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require "smart_titles/helper"
|
2
|
+
require "smart_titles/railtie"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SmartTitles
|
2
|
+
module Helper
|
3
|
+
MISSING_TRANSLATION = 0
|
4
|
+
|
5
|
+
def page_title(default = nil)
|
6
|
+
title if @page_title.nil?
|
7
|
+
@page_title != MISSING_TRANSLATION ? @page_title : default
|
8
|
+
end
|
9
|
+
|
10
|
+
def title(str = nil)
|
11
|
+
if str.nil?
|
12
|
+
str = t('.title')
|
13
|
+
@page_title = t('.title', :default => [:title, MISSING_TRANSLATION])
|
14
|
+
else
|
15
|
+
@page_title = str
|
16
|
+
end
|
17
|
+
content_tag(:h1, str)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ActionView::Helpers.send :include, SmartTitles::Helper
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "smart_titles/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "smart_titles"
|
7
|
+
s.version = SmartTitles::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.author = "Semyon Perepelitsa"
|
10
|
+
s.email = "sema@sema.in"
|
11
|
+
s.homepage = "http://github.com/semaperepelitsa/smart_titles"
|
12
|
+
s.license = "MIT"
|
13
|
+
s.summary = %q{Really convenient way to set up page titles in Rails application.}
|
14
|
+
|
15
|
+
s.add_dependency 'activesupport'
|
16
|
+
s.add_dependency 'actionpack'
|
17
|
+
s.add_development_dependency 'rspec'
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe SmartTitles::Helper do
|
4
|
+
include ActionView::Helpers
|
5
|
+
|
6
|
+
before do
|
7
|
+
@sample = 'Hello World!'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#page_title' do
|
11
|
+
it 'returns the title set by #title' do
|
12
|
+
title(@sample)
|
13
|
+
page_title.should == @sample
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#title' do
|
18
|
+
it 'returns the title in h1 tag' do
|
19
|
+
title(@sample).should == "<h1>#{@sample}</h1>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_titles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Semyon Perepelitsa
|
@@ -14,92 +10,53 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-03-14 00:00:00 +07:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
17
|
+
name: activesupport
|
18
|
+
prerelease: false
|
22
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
20
|
none: false
|
24
21
|
requirements:
|
25
22
|
- - ">="
|
26
23
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 2
|
29
|
-
- 3
|
30
|
-
- 5
|
31
|
-
version: 2.3.5
|
24
|
+
version: "0"
|
32
25
|
type: :runtime
|
33
|
-
prerelease: false
|
34
26
|
version_requirements: *id001
|
35
27
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
28
|
+
name: actionpack
|
29
|
+
prerelease: false
|
37
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
31
|
none: false
|
39
32
|
requirements:
|
40
33
|
- - ">="
|
41
34
|
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 0
|
44
35
|
version: "0"
|
45
|
-
type: :
|
46
|
-
prerelease: false
|
36
|
+
type: :runtime
|
47
37
|
version_requirements: *id002
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
50
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 1
|
57
|
-
- 0
|
58
|
-
- 0
|
59
|
-
version: 1.0.0
|
60
|
-
type: :development
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: jeweler
|
65
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ~>
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
segments:
|
71
|
-
- 1
|
72
|
-
- 5
|
73
|
-
- 1
|
74
|
-
version: 1.5.1
|
75
|
-
type: :development
|
39
|
+
name: rspec
|
76
40
|
prerelease: false
|
77
|
-
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rcov
|
80
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
81
42
|
none: false
|
82
43
|
requirements:
|
83
44
|
- - ">="
|
84
45
|
- !ruby/object:Gem::Version
|
85
|
-
segments:
|
86
|
-
- 0
|
87
46
|
version: "0"
|
88
47
|
type: :development
|
89
|
-
|
90
|
-
version_requirements: *id005
|
48
|
+
version_requirements: *id003
|
91
49
|
description:
|
92
50
|
email: sema@sema.in
|
93
51
|
executables: []
|
94
52
|
|
95
53
|
extensions: []
|
96
54
|
|
97
|
-
extra_rdoc_files:
|
98
|
-
|
99
|
-
- README.md
|
100
|
-
- TODO
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
101
57
|
files:
|
102
58
|
- .document
|
59
|
+
- .gitignore
|
103
60
|
- .rspec
|
104
61
|
- Gemfile
|
105
62
|
- Gemfile.lock
|
@@ -109,7 +66,11 @@ files:
|
|
109
66
|
- TODO
|
110
67
|
- VERSION
|
111
68
|
- lib/smart_titles.rb
|
112
|
-
-
|
69
|
+
- lib/smart_titles/helper.rb
|
70
|
+
- lib/smart_titles/railtie.rb
|
71
|
+
- lib/smart_titles/version.rb
|
72
|
+
- smart_titles.gemspec
|
73
|
+
- spec/smart_titles_helper_spec.rb
|
113
74
|
- spec/spec_helper.rb
|
114
75
|
has_rdoc: true
|
115
76
|
homepage: http://github.com/semaperepelitsa/smart_titles
|
@@ -125,25 +86,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
86
|
requirements:
|
126
87
|
- - ">="
|
127
88
|
- !ruby/object:Gem::Version
|
128
|
-
hash: -3542820655159299872
|
129
|
-
segments:
|
130
|
-
- 0
|
131
89
|
version: "0"
|
132
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
91
|
none: false
|
134
92
|
requirements:
|
135
93
|
- - ">="
|
136
94
|
- !ruby/object:Gem::Version
|
137
|
-
segments:
|
138
|
-
- 0
|
139
95
|
version: "0"
|
140
96
|
requirements: []
|
141
97
|
|
142
98
|
rubyforge_project:
|
143
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.6.1
|
144
100
|
signing_key:
|
145
101
|
specification_version: 3
|
146
102
|
summary: Really convenient way to set up page titles in Rails application.
|
147
103
|
test_files:
|
148
|
-
- spec/
|
104
|
+
- spec/smart_titles_helper_spec.rb
|
149
105
|
- spec/spec_helper.rb
|
data/spec/smart_titles_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "SmartTitles" do
|
4
|
-
include ActionView::Helpers
|
5
|
-
include SmartTitlesHelper
|
6
|
-
|
7
|
-
it "#title sets up and #page_title returns the title" do
|
8
|
-
title 'Hello World!'
|
9
|
-
page_title.should == 'Hello World!'
|
10
|
-
end
|
11
|
-
|
12
|
-
it "#title returns the title in h1 tag" do
|
13
|
-
title('Hello World!').should == '<h1>Hello World!</h1>'
|
14
|
-
end
|
15
|
-
end
|