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 +4 -4
- data/HISTORY.md +8 -0
- data/app/helpers/page_title_helper.rb +11 -8
- data/lib/stationed/generators/plugins/i18n_spec.rb +1 -1
- data/lib/stationed/generators/plugins/layout.rb +1 -1
- data/lib/stationed/generators/templates/application.html.haml +3 -2
- data/lib/stationed/generators/templates/i18n_spec.rb +3 -0
- data/lib/stationed/version.rb +1 -1
- data/spec/dummy/log/test.log +162 -0
- data/spec/helpers/page_title_helper_spec.rb +27 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0eef67b43417e7fd36f910d756d88eb01be768
|
4
|
+
data.tar.gz: 86a8f6cce7c8084573de3c9228b592bed0b1ef83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
data/lib/stationed/version.rb
CHANGED
data/spec/dummy/log/test.log
CHANGED
@@ -1578,3 +1578,165 @@
|
|
1578
1578
|
[1m[35m (0.0ms)[0m rollback transaction
|
1579
1579
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1580
1580
|
[1m[35m (0.0ms)[0m rollback transaction
|
1581
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
1582
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1583
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1584
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1585
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1586
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1587
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1588
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1589
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1590
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1591
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1592
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1593
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1594
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1595
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1596
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1597
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1598
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1599
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1600
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1601
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1602
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1603
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1604
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1605
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1606
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1607
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1608
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1609
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1610
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1611
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1612
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1613
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1614
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1615
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1616
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1617
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1618
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1619
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1620
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1621
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1622
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1623
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1624
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1625
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1626
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1627
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1628
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1629
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1630
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1631
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1632
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1633
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1634
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1635
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1636
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1637
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1638
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1639
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1640
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1641
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
1642
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1643
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1644
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1645
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1646
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1647
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1648
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1649
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1650
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1651
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1652
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1653
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1654
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1655
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1656
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1657
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1658
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1659
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1660
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1661
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1662
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1663
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1664
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1665
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1666
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1667
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1668
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1669
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1670
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1671
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1672
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1673
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1674
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1675
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1676
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1677
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1678
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1679
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1680
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1681
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1682
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1683
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1684
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1685
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1686
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1687
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1688
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1689
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1690
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1691
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1692
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1693
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1694
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1695
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1696
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1697
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1698
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1699
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1700
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1701
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1702
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1703
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1704
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1705
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1706
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1707
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1708
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1709
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1710
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1711
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1712
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1713
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1714
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1715
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1716
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1717
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1718
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1719
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1720
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1721
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1722
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1723
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1724
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1725
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1726
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1727
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1728
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1729
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1730
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1731
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1732
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1733
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1734
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1735
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1736
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1737
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1738
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1739
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1740
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1741
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1742
|
+
[1m[35m (0.0ms)[0m 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(
|
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(
|
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(
|
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(
|
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.
|
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-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|