locomotivecms_steam 1.0.0.rc4 → 1.0.0.rc6

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: a09d7e73bc37c30f64b170c09a38a6761db8788f
4
- data.tar.gz: 6611a2cd44128874452e1172ad77a1b38e128134
3
+ metadata.gz: 73dc9ea0190083dd20c33f5e820da421b36d11b4
4
+ data.tar.gz: 5e74931081e00c151d857c449f0c14c3219e0f67
5
5
  SHA512:
6
- metadata.gz: b759d95e386dd121a7936bb4715ec5fe8d308af8854c4408ff16d0a878dfcc31d50e45e0a16d6847a3360a83d528ddfbc479dbd74ca8f606bb63381f20cc8657
7
- data.tar.gz: 9e51a4924b1f934f08dbd5dd3fc503ef1c18454e753a742009890bbe2abae6e231f8c60ddd39a75bb253f3a136e69976ad48f4ca7ae1fbda3d0aaa654e5aeb12
6
+ metadata.gz: b4e2759d7ab8798c17f8a4a40b0779228410c8b0f0fb96b4aad83dd7589a2059e1baae8dae58be3f448ccd07ca2933e1ddd2a8a1e918924f3fb44a730825a4f9
7
+ data.tar.gz: 7b443e9021b581bd62cee286dd74bb02ee966086064313866f1379055069d23a30f5b198de07aa9da308772eb89003f0e5ae6f6eef07b317c4e2bcbed6d728c8
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  services: mongodb
3
3
  before_script: ./script/ci/before_build.sh
4
4
  rvm:
5
- - 2.2.2
5
+ - 2.2.3
6
6
  env:
7
7
  - CODECLIMATE_REPO_TOKEN=3fa74f2ade25037fccd7261090acbdeae232639c3a83aafb80ee428ec16b8cf9
8
8
  addons:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.0.0.rc4)
4
+ locomotivecms_steam (1.0.0.rc6)
5
5
  RedCloth (~> 4.2.9)
6
6
  chronic (~> 0.10.2)
7
7
  coffee-script (~> 2.4.1)
@@ -120,7 +120,7 @@ GEM
120
120
  mime-types (2.6.1)
121
121
  mimetype-fu (0.1.2)
122
122
  mini_portile (0.6.2)
123
- minitest (5.8.2)
123
+ minitest (5.8.3)
124
124
  moneta (0.8.0)
125
125
  mongo (2.1.2)
126
126
  bson (~> 3.0)
@@ -128,7 +128,7 @@ GEM
128
128
  multi_json (1.11.1)
129
129
  multi_xml (0.5.5)
130
130
  netrc (0.10.3)
131
- nokogiri (1.6.6.2)
131
+ nokogiri (1.6.6.4)
132
132
  mini_portile (~> 0.6.0)
133
133
  nokogumbo (1.4.1)
134
134
  nokogiri
@@ -51,6 +51,14 @@ module Locomotive
51
51
  end
52
52
  end
53
53
 
54
+ def __with_default_locale__(&block)
55
+ if self.__default_locale__
56
+ __with_locale__(self.__default_locale__, &block)
57
+ else
58
+ yield
59
+ end
60
+ end
61
+
54
62
  def __freeze_locale__
55
63
  @__frozen_locale__ = true
56
64
  end
@@ -11,12 +11,16 @@ module Locomotive
11
11
  if respond_to?(:template_path) && template_path
12
12
  source_from_template_file
13
13
  else
14
- self.source
14
+ self.source.blank? ? source_in_default_locale : self.source
15
15
  end
16
16
  end
17
17
 
18
18
  private
19
19
 
20
+ def source_in_default_locale
21
+ self.__with_default_locale__ { self.source }
22
+ end
23
+
20
24
  def source_from_template_file
21
25
  source = File.read(template_path).force_encoding('utf-8')
22
26
 
@@ -23,6 +23,8 @@ module Locomotive
23
23
  protected
24
24
 
25
25
  def fetch_file(source)
26
+ return nil if source.blank?
27
+
26
28
  url_or_path = get_url_or_path(source)
27
29
 
28
30
  if url_or_path =~ Steam::IsHTTP
@@ -13,7 +13,7 @@ module Locomotive
13
13
  # build the url of the theme asset based on the persistence layer
14
14
  _url = repository.url_for(path)
15
15
 
16
- # get a timestamp only the source url does not include a query string
16
+ # get a timestamp only if the source url doesn't include a query string
17
17
  timestamp = query_string.blank? ? checksums[path] : nil
18
18
 
19
19
  # prefix by a asset host if given
@@ -3,6 +3,6 @@
3
3
  # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
4
4
  module Locomotive
5
5
  module Steam
6
- VERSION = '1.0.0.rc4'
6
+ VERSION = '1.0.0.rc6'
7
7
  end
8
8
  end
@@ -46,9 +46,40 @@ describe Locomotive::Steam::Decorators::I18nDecorator do
46
46
 
47
47
  describe 'using the default locale' do
48
48
 
49
- let(:locale) { 'de' }
50
- let(:default_locale) { 'en' }
51
- it { expect(decorated.title).to eq 'Hello world!' }
49
+ let(:default_locale) { 'en' }
50
+
51
+ context 'unknown locale' do
52
+
53
+ let(:locale) { 'de' }
54
+
55
+ it { expect(decorated.title).to eq 'Hello world!' }
56
+
57
+ end
58
+
59
+ context 'existing locale' do
60
+
61
+ let(:locale) { 'fr' }
62
+
63
+ it 'uses the default locale and get back to the previous one' do
64
+ decorated.__with_default_locale__ do
65
+ expect(decorated.title).to eq 'Hello world!'
66
+ end
67
+ expect(decorated.__locale__).to eq :fr
68
+ end
69
+
70
+ context 'default_locale is nil' do
71
+
72
+ let(:default_locale) { nil }
73
+
74
+ it 'yields the block if no default locale' do
75
+ decorated.__with_default_locale__ do
76
+ expect(decorated.title).to eq 'Bonjour monde'
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+ end
52
83
 
53
84
  end
54
85
 
@@ -5,7 +5,7 @@ describe Locomotive::Steam::Decorators::TemplateDecorator do
5
5
  let(:template_path) { 'template.liquid' }
6
6
  let(:page) { instance_double('Page', localized_attributes: [], template_path: template_path) }
7
7
  let(:locale) { 'fr' }
8
- let(:default_locale) { nil }
8
+ let(:default_locale) { 'en' }
9
9
  let(:decorated) { described_class.new(page, locale, default_locale) }
10
10
 
11
11
  describe '#liquid_source' do
@@ -18,6 +18,14 @@ describe Locomotive::Steam::Decorators::TemplateDecorator do
18
18
 
19
19
  it { is_expected.to eq 'Lorem ipsum' }
20
20
 
21
+ context 'Raw template' do
22
+
23
+ let(:page) { instance_double('Page', localized_attributes: [:source], source: { en: 'Lorem ipsum [EN]', fr: '' }) }
24
+
25
+ it { is_expected.to eq 'Lorem ipsum [EN]' }
26
+
27
+ end
28
+
21
29
  context 'HAML file' do
22
30
 
23
31
  let(:template_path) { 'template.liquid.haml' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_steam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc4
4
+ version: 1.0.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-11-16 00:00:00.000000000 Z
14
+ date: 2015-11-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler