middleman-title 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8890ac07e237420852ff05324a82f3b437eb00f4
4
- data.tar.gz: ca350f34ed2c92bfaaaf26118b9c9d79d438fd18
3
+ metadata.gz: 1fb2a922916b5111439d744037d6d6b1e1777569
4
+ data.tar.gz: e891cad4a69d680472768b16e2e2aa49fffde704
5
5
  SHA512:
6
- metadata.gz: cafb5818c7b23d812ae006102612d9a2822f587924b65c2505d908d3dda7b7ba7189be29917850c69a262ad94a9d246f337404de0d2dda9e5f9b5ed02ff368f9
7
- data.tar.gz: d09d8e9543b8a1b56fe0f353bf8c4c518f026f21ea2b7d1d4297c76ee52440dd885a505ed56c9ad841de3432d529137eaead0e5879aec0046216920624ec2a46
6
+ metadata.gz: a7a7675a4d9ff10dac71cd054f731877fdb1ad38deb353b2f3408b65e589c9a8e379c60b8f857ac5e72529c97c3430aa946fe8777c19daee07eb9115855d3ac5
7
+ data.tar.gz: bce2a8617200ac8352028c5ae89cb8c0e6ed337b4bca9a4767cbf77e93afa158cb2965be62f5f4edccd6ded48bb57635a0a156f3cf13f896cfc17e6500aa43ea
data/.travis.yml CHANGED
@@ -2,5 +2,7 @@ rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
4
  - 2.1.0
5
-
6
- script: 'bundle exec rspec'
5
+ script: 'bundle exec rspec'
6
+ addons:
7
+ code_climate:
8
+ repo_token: 96d351848c244b986b3888fd13d12b6e916dcfbc83474c8a7a2c03d1c7827ecf
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.2
2
+ * Fix conflict with options set for middleman-deploy
3
+ * Allow options to be passed in as hash or block
4
+
5
+ ## 0.0.1
6
+ * Initial release
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ gem 'bundler', '~> 1.6'
6
+ gem 'rake', '~> 10.3'
7
+ gem 'rspec', '~> 2.14'
8
+
9
+ gem 'codeclimate-test-reporter', require: nil
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
-
2
1
  # Middleman Title
3
2
  [![Build Status](https://travis-ci.org/jcypret/middleman-title.svg?branch=master)](https://travis-ci.org/jcypret/middleman-title)
3
+ [![Code Climate](https://codeclimate.com/github/jcypret/middleman-title.png)](https://codeclimate.com/github/jcypret/middleman-title)
4
4
 
5
5
  This Middleman extension allows you to easily set page titles for your website.
6
6
 
@@ -75,7 +75,7 @@ This would output:
75
75
 
76
76
  ## Contributing
77
77
 
78
- 1. Fork it ( https://github.com/[my-github-username]/middleman-title/fork )
78
+ 1. Fork it ( https://github.com/jcypret/middleman-title/fork )
79
79
  2. Create your feature branch (`git checkout -b my-new-feature`)
80
80
  3. Commit your changes (`git commit -am 'Add some feature'`)
81
81
  4. Push to the branch (`git push origin my-new-feature`)
@@ -2,17 +2,34 @@ require 'middleman-title/helpers'
2
2
 
3
3
  module Middleman
4
4
  module Title
5
- class << self
6
5
 
7
- def registered(app, options_hash = {}, &block)
8
- app.helpers Helpers
9
- @@options = options_hash
6
+ class Options < Struct.new(:site, :separator, :reverse)
7
+ def initialize(h)
8
+ super(*h.values_at(:site, :separator, :reverse))
10
9
  end
10
+ end
11
+
12
+ class << self
11
13
 
12
14
  def options
13
15
  @@options
14
16
  end
15
17
 
18
+ def registered(app, options_hash = {}, &block)
19
+ options = Options.new(options_hash)
20
+ yield options if block_given?
21
+
22
+ # default options
23
+ options.separator ||= ' &mdash; '
24
+ options.site = false if options.site.nil?
25
+ options.reverse = false if options.reverse.nil?
26
+
27
+ @@options = options
28
+ app.helpers Helpers
29
+ end
30
+ alias :included :registered
31
+
16
32
  end
33
+
17
34
  end
18
35
  end
@@ -10,23 +10,23 @@ module Middleman
10
10
  end
11
11
 
12
12
  private
13
- def options
14
- Title.options
13
+ def title_options
14
+ ::Middleman::Title.options
15
15
  end
16
16
 
17
17
  def website_name
18
- current_page.data.title_site || options[:site]
18
+ current_page.data.title_site || title_options.site
19
19
  end
20
20
 
21
21
  def title_separator
22
- options[:separator] || ' &mdash; '
22
+ title_options.separator
23
23
  end
24
24
 
25
25
  def title_reverse
26
- if current_page.data.title_reverse == false
27
- false
26
+ if current_page.data.title_reverse.nil? == false
27
+ current_page.data.title_reverse
28
28
  else
29
- current_page.data.title_reverse || options[:reverse]
29
+ title_options.reverse
30
30
  end
31
31
  end
32
32
 
@@ -41,7 +41,7 @@ module Middleman
41
41
  end
42
42
 
43
43
  def add_website_name_to_title(title)
44
- if current_page.data.title_site == false || website_name.nil?
44
+ if current_page.data.title_site == false || website_name == false
45
45
  title
46
46
  elsif website_name_first?
47
47
  title.unshift(website_name)
@@ -58,10 +58,6 @@ module Middleman
58
58
  title_reverse
59
59
  end
60
60
 
61
- def hide_website_name?
62
- current_page.data.title_site == false
63
- end
64
-
65
61
  end
66
62
  end
67
- end
63
+ end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Title
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
- end
5
+ end
@@ -19,8 +19,4 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'middleman-core', '~> 3.2'
22
-
23
- spec.add_development_dependency 'bundler', '~> 1.6'
24
- spec.add_development_dependency 'rake', '~> 10.3', '>= 10.3.1'
25
- spec.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
26
22
  end
@@ -5,13 +5,17 @@ describe Middleman::Title::Helpers do
5
5
 
6
6
  describe '#page_title' do
7
7
  before(:each) do
8
+ h.stub_chain(:options, :site).and_return(false)
9
+ h.stub_chain(:options, :separator).and_return(' &mdash; ')
10
+ h.stub_chain(:options, :reverse).and_return(false)
11
+
8
12
  h.stub_chain(:current_page, :data, :title).and_return(nil)
9
13
  h.stub_chain(:current_page, :data, :title_site).and_return(nil)
10
14
  h.stub_chain(:current_page, :data, :title_reverse).and_return(nil)
11
15
  end
12
16
 
13
17
  context 'website name is set' do
14
- before(:each) { h.stub(:options) { { site: 'Website Name' } } }
18
+ before(:each) { h.stub_chain(:options, :site).and_return('Website Name') }
15
19
 
16
20
  context 'page name is set' do
17
21
  before(:each) { h.stub_chain(:current_page, :data, :title).and_return('How to Say Hello to the World') }
@@ -31,19 +35,20 @@ describe Middleman::Title::Helpers do
31
35
  end
32
36
 
33
37
  it 'puts website name first when activate reverse is true' do
34
- h.stub(:options) { { site: 'Website Name', reverse: true } }
38
+ h.stub_chain(:options, :reverse).and_return(true)
35
39
  expect(h.page_title).to eq 'Website Name &mdash; How to Say Hello to the World'
36
40
  end
37
41
 
38
42
  it 'puts website name last when activate reverse is true but frontmatter is false' do
39
- h.stub(:options) { { site: 'Website Name', reverse: true } }
43
+ h.stub_chain(:options, :reverse).and_return(true)
40
44
  h.stub_chain(:current_page, :data, :title_reverse).and_return(false)
41
45
  expect(h.page_title).to eq 'How to Say Hello to the World &mdash; Website Name'
42
46
  end
43
47
 
44
48
  context 'separator is set' do
45
49
  it 'to a vertical bar' do
46
- h.stub(:options) { { site: 'Website Name', separator: ' | ' } }
50
+ h.stub_chain(:options, :site).and_return('Website Name')
51
+ h.stub_chain(:options, :separator).and_return(' | ')
47
52
  expect(h.page_title).to eq 'How to Say Hello to the World | Website Name'
48
53
  end
49
54
  end
@@ -71,7 +76,6 @@ describe Middleman::Title::Helpers do
71
76
  end
72
77
 
73
78
  context 'website name is not set' do
74
- before(:each) { h.stub(:options) { {} } }
75
79
 
76
80
  context 'page name is set' do
77
81
  before(:each) { h.stub_chain(:current_page, :data, :title).and_return('How to Say Hello to the World') }
@@ -90,4 +94,4 @@ describe Middleman::Title::Helpers do
90
94
  end
91
95
 
92
96
  end
93
- end
97
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'bundler/setup'
2
5
  Bundler.setup
3
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-title
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Cypret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -24,60 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.6'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.6'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.3'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 10.3.1
51
- type: :development
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: '10.3'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 10.3.1
61
- - !ruby/object:Gem::Dependency
62
- name: rspec
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '2.14'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 2.14.1
71
- type: :development
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '2.14'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 2.14.1
81
27
  description: A Middleman extension for setting the page title
82
28
  email:
83
29
  - jcypret@gmail.com
@@ -88,8 +34,8 @@ files:
88
34
  - ".gitignore"
89
35
  - ".rspec"
90
36
  - ".travis.yml"
37
+ - CHANGELOG.md
91
38
  - Gemfile
92
- - Gemfile.lock
93
39
  - LICENSE.md
94
40
  - README.md
95
41
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,76 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- middleman-title (0.0.1)
5
- middleman-core (~> 3.2)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activesupport (4.0.5)
11
- i18n (~> 0.6, >= 0.6.9)
12
- minitest (~> 4.2)
13
- multi_json (~> 1.3)
14
- thread_safe (~> 0.1)
15
- tzinfo (~> 0.3.37)
16
- diff-lcs (1.2.5)
17
- erubis (2.7.0)
18
- ffi (1.9.3)
19
- hooks (0.4.0)
20
- uber (~> 0.0.4)
21
- i18n (0.6.9)
22
- listen (1.3.1)
23
- rb-fsevent (>= 0.9.3)
24
- rb-inotify (>= 0.9)
25
- rb-kqueue (>= 0.2)
26
- middleman-core (3.3.2)
27
- activesupport (~> 4.0.1)
28
- bundler (~> 1.1)
29
- erubis
30
- hooks (~> 0.3)
31
- i18n (~> 0.6.9)
32
- listen (~> 1.1)
33
- padrino-helpers (~> 0.12.1)
34
- rack (>= 1.4.5, < 2.0)
35
- rack-test (~> 0.6.2)
36
- thor (>= 0.15.2, < 2.0)
37
- tilt (~> 1.4.1, < 2.0)
38
- minitest (4.7.5)
39
- multi_json (1.10.0)
40
- padrino-helpers (0.12.2)
41
- i18n (~> 0.6, >= 0.6.7)
42
- padrino-support (= 0.12.2)
43
- tilt (~> 1.4.1)
44
- padrino-support (0.12.2)
45
- activesupport (>= 3.1)
46
- rack (1.5.2)
47
- rack-test (0.6.2)
48
- rack (>= 1.0)
49
- rake (10.3.1)
50
- rb-fsevent (0.9.4)
51
- rb-inotify (0.9.4)
52
- ffi (>= 0.5.0)
53
- rb-kqueue (0.2.2)
54
- ffi (>= 0.5.0)
55
- rspec (2.14.1)
56
- rspec-core (~> 2.14.0)
57
- rspec-expectations (~> 2.14.0)
58
- rspec-mocks (~> 2.14.0)
59
- rspec-core (2.14.8)
60
- rspec-expectations (2.14.5)
61
- diff-lcs (>= 1.1.3, < 2.0)
62
- rspec-mocks (2.14.6)
63
- thor (0.19.1)
64
- thread_safe (0.3.3)
65
- tilt (1.4.1)
66
- tzinfo (0.3.39)
67
- uber (0.0.6)
68
-
69
- PLATFORMS
70
- ruby
71
-
72
- DEPENDENCIES
73
- bundler (~> 1.6)
74
- middleman-title!
75
- rake (~> 10.3, >= 10.3.1)
76
- rspec (~> 2.14, >= 2.14.1)