stationed 0.3.0 → 0.4.0

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: 86a07ab2c8293fd8cc8575df86dd92d6754d9082
4
- data.tar.gz: 3cae3f13454df7072d2f7cf77d34bcf74435972b
3
+ metadata.gz: cd0eef67b43417e7fd36f910d756d88eb01be768
4
+ data.tar.gz: 86a8f6cce7c8084573de3c9228b592bed0b1ef83
5
5
  SHA512:
6
- metadata.gz: 3efc2cc9a7ce774e617d0cb4c04a58371066d9903686db47d1f9d406304c063b8f518d22ac67f3e2845b4046258498e470f447877ca044101649f7f2627208f9
7
- data.tar.gz: ad1a6a9f6cf5a104312316d66c5773911fd4223b7bfae1643c5916bb8c06fde70867c2bfb2e240d64a35c8385250d907041ed519222cbc069d3a6e2db04a4b59
6
+ metadata.gz: 64faf83906f6206d63eda4c13e8232b8492dfcbcc4cd503bd911d01de0456503737d1ff2bc4fd84e6bb62401adbcb6efe40c0c21527b653a47e91816401440dd
7
+ data.tar.gz: a87de8d7e9358cf86f7ffb9df76cf244b737edff1eb6d43ebf01bb525928186053d3da024ecc058a962f00973b0d2c55d2d5c5aebbe473d59ea41903cca5b069
data/HISTORY.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # HISTORY
2
2
 
3
+ ## 0.4.0
4
+
5
+ * Improve default layout and actually remove Erb layout file
6
+ * Prevent load order issue with i18n-spec matchers
7
+ * Allow passing additional interpolation arguments to record-based page titles
8
+ * Add extra action-default record page title translation key
9
+ * Use regular translate helper rather than directly accessing I18n
10
+
3
11
  ## 0.3.0
4
12
 
5
13
  * Properly installed stationed executable [ariejan]
@@ -23,14 +23,16 @@ module PageTitleHelper
23
23
  # @example Set the page title based on a model name
24
24
  # page_title Post.find(1)
25
25
  # # example translation key: 'Editing %{singular} %{id}'
26
+ # @example Pass along extra arguments to interpolate
27
+ # page_title @post, author: @post.author.name
26
28
  # @example Show the page title
27
29
  # <title><%= title %></title>
28
30
  #
29
31
  # @param [String, #model_name] String or ActiveModel-compliant object
30
32
  # @return [String] page title component or formatted page title
31
- def page_title(new_title = nil)
33
+ def page_title(new_title = nil, options = {})
32
34
  if new_title
33
- title_from_string_or_record_or_class(new_title).tap do |str|
35
+ title_from_string_or_record_or_class(new_title, options).tap do |str|
34
36
  content_for :page_title, str
35
37
  end
36
38
  elsif content_for? :page_title
@@ -43,14 +45,14 @@ module PageTitleHelper
43
45
  private
44
46
 
45
47
  def standard_title
46
- I18n.translate(
48
+ translate(
47
49
  standard_defaults.first,
48
50
  default: standard_defaults.drop(1)
49
51
  )
50
52
  end
51
53
 
52
54
  def formatted_title
53
- I18n.translate(
55
+ translate(
54
56
  formatted_defaults.first,
55
57
  title: content_for(:page_title),
56
58
  default: formatted_defaults.drop(1)
@@ -63,14 +65,14 @@ module PageTitleHelper
63
65
  singular: klass.model_name.human,
64
66
  plural: klass.model_name.human.pluralize
65
67
  )
66
- I18n.translate model_defaults.first, options
68
+ translate model_defaults.first, options
67
69
  end
68
70
 
69
- def title_from_string_or_record_or_class(object)
71
+ def title_from_string_or_record_or_class(object, options)
70
72
  if object.respond_to?(:model_name)
71
- title_for_class(object)
73
+ title_for_class(object, options)
72
74
  elsif object.class.respond_to?(:model_name)
73
- title_for_class(object.class, id: object.to_param)
75
+ title_for_class(object.class, options.reverse_merge(id: object.to_param))
74
76
  else
75
77
  object
76
78
  end
@@ -99,6 +101,7 @@ module PageTitleHelper
99
101
  [
100
102
  :"page_title.#{controller_name}.#{action_name}.model",
101
103
  :"page_title.#{controller_name}.model",
104
+ :"page_title.default.#{action_name}.model",
102
105
  :'page_title.default.model',
103
106
  :'page_title.default.standard',
104
107
  ::Rails.application.class.parent_name
@@ -11,7 +11,7 @@ module Stationed
11
11
 
12
12
  def finish_template
13
13
  return super unless options[:i18n_spec]
14
- gem 'i18n-spec', group: :test
14
+ gem 'i18n-spec', group: :test, require: false
15
15
  copy_file 'i18n_spec.rb', 'spec/locales/i18n_spec.rb'
16
16
  uncomment_lines 'config/environments/development.rb', /raise_on_missing_translations/
17
17
  uncomment_lines 'config/environments/test.rb', /raise_on_missing_translations/
@@ -11,7 +11,7 @@ module Stationed
11
11
 
12
12
  def finish_template
13
13
  return super unless options[:layout]
14
- remove_file 'app/views/layouts/application.html.haml'
14
+ remove_file 'app/views/layouts/application.html.erb'
15
15
  copy_file 'application.html.haml', 'app/views/layouts/application.html.haml'
16
16
  super
17
17
  end
@@ -7,6 +7,7 @@
7
7
  = stylesheet_link_tag 'application'
8
8
  = csrf_meta_tags
9
9
  %body
10
- = render 'flashes'
11
- = yield
10
+ #page
11
+ = render 'flashes'
12
+ = yield
12
13
  = javascript_include_tag 'application'
@@ -1,3 +1,6 @@
1
+ require 'spec_helper'
2
+ require 'i18n-spec'
3
+
1
4
  Dir.glob('config/locales/*.yml') do |locale_file|
2
5
  describe locale_file do
3
6
  it { should be_parseable }
@@ -1,3 +1,3 @@
1
1
  module Stationed
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -1578,3 +1578,165 @@
1578
1578
   (0.0ms) rollback transaction
1579
1579
   (0.0ms) begin transaction
1580
1580
   (0.0ms) rollback transaction
1581
+  (0.3ms) begin transaction
1582
+  (0.1ms) rollback transaction
1583
+  (0.0ms) begin transaction
1584
+  (0.0ms) rollback transaction
1585
+  (0.0ms) begin transaction
1586
+  (0.0ms) rollback transaction
1587
+  (0.0ms) begin transaction
1588
+  (0.0ms) rollback transaction
1589
+  (0.0ms) begin transaction
1590
+  (0.1ms) rollback transaction
1591
+  (0.0ms) begin transaction
1592
+  (0.0ms) rollback transaction
1593
+  (0.2ms) begin transaction
1594
+  (0.0ms) rollback transaction
1595
+  (0.0ms) begin transaction
1596
+  (0.1ms) rollback transaction
1597
+  (0.0ms) begin transaction
1598
+  (0.1ms) rollback transaction
1599
+  (0.1ms) begin transaction
1600
+  (0.0ms) rollback transaction
1601
+  (0.0ms) begin transaction
1602
+  (0.0ms) rollback transaction
1603
+  (0.0ms) begin transaction
1604
+  (0.0ms) rollback transaction
1605
+  (0.2ms) begin transaction
1606
+  (0.0ms) rollback transaction
1607
+  (0.0ms) begin transaction
1608
+  (0.0ms) rollback transaction
1609
+  (0.0ms) begin transaction
1610
+  (0.0ms) rollback transaction
1611
+  (0.1ms) begin transaction
1612
+  (0.1ms) rollback transaction
1613
+  (0.0ms) begin transaction
1614
+  (0.0ms) rollback transaction
1615
+  (0.0ms) begin transaction
1616
+  (0.0ms) rollback transaction
1617
+  (0.2ms) begin transaction
1618
+  (0.1ms) rollback transaction
1619
+  (0.0ms) begin transaction
1620
+  (0.0ms) rollback transaction
1621
+  (0.1ms) begin transaction
1622
+  (0.0ms) rollback transaction
1623
+  (0.1ms) begin transaction
1624
+  (0.0ms) rollback transaction
1625
+  (0.0ms) begin transaction
1626
+  (0.0ms) rollback transaction
1627
+  (0.0ms) begin transaction
1628
+  (0.1ms) rollback transaction
1629
+  (0.2ms) begin transaction
1630
+  (0.1ms) rollback transaction
1631
+  (0.0ms) begin transaction
1632
+  (0.0ms) rollback transaction
1633
+  (0.0ms) begin transaction
1634
+  (0.0ms) rollback transaction
1635
+  (0.0ms) begin transaction
1636
+  (0.0ms) rollback transaction
1637
+  (0.0ms) begin transaction
1638
+  (0.0ms) rollback transaction
1639
+  (0.0ms) begin transaction
1640
+  (0.0ms) rollback transaction
1641
+  (0.3ms) begin transaction
1642
+  (0.1ms) rollback transaction
1643
+  (0.1ms) begin transaction
1644
+  (0.0ms) rollback transaction
1645
+  (0.0ms) begin transaction
1646
+  (0.0ms) rollback transaction
1647
+  (0.1ms) begin transaction
1648
+  (0.0ms) rollback transaction
1649
+  (0.0ms) begin transaction
1650
+  (0.0ms) rollback transaction
1651
+  (0.0ms) begin transaction
1652
+  (0.0ms) rollback transaction
1653
+  (0.2ms) begin transaction
1654
+  (0.0ms) rollback transaction
1655
+  (0.0ms) begin transaction
1656
+  (0.0ms) rollback transaction
1657
+  (0.0ms) begin transaction
1658
+  (0.0ms) rollback transaction
1659
+  (0.0ms) begin transaction
1660
+  (0.0ms) rollback transaction
1661
+  (0.0ms) begin transaction
1662
+  (0.1ms) rollback transaction
1663
+  (0.0ms) begin transaction
1664
+  (0.0ms) rollback transaction
1665
+  (0.2ms) begin transaction
1666
+  (0.0ms) rollback transaction
1667
+  (0.0ms) begin transaction
1668
+  (0.1ms) rollback transaction
1669
+  (0.0ms) begin transaction
1670
+  (0.0ms) rollback transaction
1671
+  (0.0ms) begin transaction
1672
+  (0.0ms) rollback transaction
1673
+  (0.0ms) begin transaction
1674
+  (0.0ms) rollback transaction
1675
+  (0.0ms) begin transaction
1676
+  (0.0ms) rollback transaction
1677
+  (0.2ms) begin transaction
1678
+  (0.1ms) rollback transaction
1679
+  (0.0ms) begin transaction
1680
+  (0.0ms) rollback transaction
1681
+  (0.0ms) begin transaction
1682
+  (0.0ms) rollback transaction
1683
+  (0.0ms) begin transaction
1684
+  (0.0ms) rollback transaction
1685
+  (0.0ms) begin transaction
1686
+  (0.0ms) rollback transaction
1687
+  (0.0ms) begin transaction
1688
+  (0.1ms) rollback transaction
1689
+  (0.2ms) begin transaction
1690
+  (0.1ms) rollback transaction
1691
+  (0.0ms) begin transaction
1692
+  (0.0ms) rollback transaction
1693
+  (0.0ms) begin transaction
1694
+  (0.0ms) rollback transaction
1695
+  (0.0ms) begin transaction
1696
+  (0.0ms) rollback transaction
1697
+  (0.0ms) begin transaction
1698
+  (0.0ms) rollback transaction
1699
+  (0.0ms) begin transaction
1700
+  (0.0ms) rollback transaction
1701
+  (0.2ms) begin transaction
1702
+  (0.0ms) rollback transaction
1703
+  (0.0ms) begin transaction
1704
+  (0.0ms) rollback transaction
1705
+  (0.0ms) begin transaction
1706
+  (0.0ms) rollback transaction
1707
+  (0.1ms) begin transaction
1708
+  (0.0ms) rollback transaction
1709
+  (0.0ms) begin transaction
1710
+  (0.0ms) rollback transaction
1711
+  (0.0ms) begin transaction
1712
+  (0.0ms) rollback transaction
1713
+  (0.0ms) begin transaction
1714
+  (0.1ms) rollback transaction
1715
+  (0.0ms) begin transaction
1716
+  (0.0ms) rollback transaction
1717
+  (0.0ms) begin transaction
1718
+  (0.0ms) rollback transaction
1719
+  (0.0ms) begin transaction
1720
+  (0.1ms) rollback transaction
1721
+  (0.0ms) begin transaction
1722
+  (0.1ms) rollback transaction
1723
+  (0.0ms) begin transaction
1724
+  (0.0ms) rollback transaction
1725
+  (0.0ms) begin transaction
1726
+  (0.0ms) rollback transaction
1727
+  (0.0ms) begin transaction
1728
+  (0.1ms) rollback transaction
1729
+  (0.0ms) begin transaction
1730
+  (0.0ms) rollback transaction
1731
+  (0.0ms) begin transaction
1732
+  (0.0ms) rollback transaction
1733
+  (0.0ms) begin transaction
1734
+  (0.0ms) rollback transaction
1735
+  (0.0ms) begin transaction
1736
+  (0.0ms) rollback transaction
1737
+  (0.0ms) begin transaction
1738
+  (0.0ms) rollback transaction
1739
+  (0.0ms) begin transaction
1740
+  (0.0ms) rollback transaction
1741
+  (0.0ms) begin transaction
1742
+  (0.0ms) rollback transaction
@@ -15,13 +15,14 @@ describe PageTitleHelper do
15
15
  name = double human: 'Post'
16
16
  model = double model_name: name
17
17
  record = double class: model, to_param: '1'
18
- expect(I18n).to receive(:translate).with(
18
+ expect(helper).to receive(:translate).with(
19
19
  :'page_title.controller.action.model',
20
20
  singular: 'Post',
21
21
  plural: 'Posts',
22
22
  id: '1',
23
23
  default: [
24
24
  :'page_title.controller.model',
25
+ :'page_title.default.action.model',
25
26
  :'page_title.default.model',
26
27
  :'page_title.default.standard',
27
28
  'Dummy'
@@ -30,15 +31,37 @@ describe PageTitleHelper do
30
31
  helper.page_title record
31
32
  end
32
33
 
34
+ it 'passes additional options along to helper.translate when setting a record title' do
35
+ name = double human: 'Post'
36
+ model = double model_name: name
37
+ record = double class: model, to_param: '1'
38
+ expect(helper).to receive(:translate).with(
39
+ :'page_title.controller.action.model',
40
+ singular: 'Post',
41
+ plural: 'Posts',
42
+ id: '1',
43
+ extra_argument: 'foobar',
44
+ default: [
45
+ :'page_title.controller.model',
46
+ :'page_title.default.action.model',
47
+ :'page_title.default.model',
48
+ :'page_title.default.standard',
49
+ 'Dummy'
50
+ ]
51
+ ).and_return('bla')
52
+ helper.page_title record, extra_argument: 'foobar'
53
+ end
54
+
33
55
  it 'interpolates plural and singular names into the formatted default given a model' do
34
56
  name = double human: 'Post'
35
57
  model = double model_name: name
36
- expect(I18n).to receive(:translate).with(
58
+ expect(helper).to receive(:translate).with(
37
59
  :'page_title.controller.action.model',
38
60
  singular: 'Post',
39
61
  plural: 'Posts',
40
62
  default: [
41
63
  :'page_title.controller.model',
64
+ :'page_title.default.action.model',
42
65
  :'page_title.default.model',
43
66
  :'page_title.default.standard',
44
67
  'Dummy'
@@ -53,7 +76,7 @@ describe PageTitleHelper do
53
76
  end
54
77
 
55
78
  it 'inserts it into the default format' do
56
- expect(I18n).to receive(:translate).with(
79
+ expect(helper).to receive(:translate).with(
57
80
  :'page_title.controller.action.formatted',
58
81
  default: [
59
82
  :'page_title.controller.formatted',
@@ -69,7 +92,7 @@ describe PageTitleHelper do
69
92
 
70
93
  context 'when no title has been set' do
71
94
  it 'returns the default page title' do
72
- expect(I18n).to receive(:translate).with(
95
+ expect(helper).to receive(:translate).with(
73
96
  :'page_title.controller.action.standard',
74
97
  default: [
75
98
  :'page_title.controller.standard',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stationed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arjan van der Gaag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails