jekyll-msgcat 0.0.2 → 1.0.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: bd1c394a9012e2a4e4dc70eb60bf122c6c65b4b9
4
- data.tar.gz: 00b325db55ee9a2f1a079310e9e70ebe4da15e41
3
+ metadata.gz: 8612d0a2fc3c09579441d4d149812aa8c8012037
4
+ data.tar.gz: 1f2f8ebc959ca985d52280e7319ee4810ae096fb
5
5
  SHA512:
6
- metadata.gz: 5da70d037575e0fd62b853495b4e0dbbc80be866faba1ddacd4c245d846d3a2a844df1f767a77991c7edcba2d1da72bc531fb5faa6de835674649a53ec38190d
7
- data.tar.gz: c43d6388ce8beaab68754b8c378fc0f14e4572df0014ebd79419541571faa1925b7a1971adf5bd2929bcc3046bcc030671f195a3556471281956e06f5cdb9805
6
+ metadata.gz: 859a6d39c139a34f477dc3fedda54c9d4b63ab71a585da96dfd05bd038f2734f0e5c4e629255cab2bbe6de5596fc9bac2e09186cf8244102ecb695cb1551b2ff
7
+ data.tar.gz: 78d3b08c0314c5864f50a65aa197d841835f44b89a9882824338730d60309c360659e35a2241b740408e8e85c26f8af7b4fc175581cae24556a34a6af4592667
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- #ruby=ruby-2.0.0
1
+ #ruby=ruby-2.1.3
2
2
  #ruby-gemset=msgcat
3
3
  source 'https://rubygems.org'
4
4
 
data/README.md CHANGED
@@ -2,21 +2,21 @@
2
2
 
3
3
  Multi-lingual interface with Jekyll via .yaml message catalogs.
4
4
 
5
- Tested with Jekyll 1.2.1.
5
+ Updated for Jekyll 2.5.3.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'jekyll-msgcat'
11
+ gem 'jekyll-msgcat'
12
12
 
13
13
  And then execute:
14
14
 
15
- $ bundle
15
+ $ bundle
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install jekyll-msgcat
19
+ $ gem install jekyll-msgcat
20
20
 
21
21
  ## Usage
22
22
 
@@ -37,6 +37,10 @@ Create ``_msgcat.yaml``:
37
37
  uk:
38
38
  'Home': На головну сторiнку
39
39
 
40
+ ``_msgcat.yaml`` file **must** be in a directory where the site
41
+ sources are (e.g. the same directory you provide in ``jekyll -s
42
+ foo/bar`` command).
43
+
40
44
  And use in Liquid templates:
41
45
 
42
46
  {{ 'Home' | mc }}
@@ -44,7 +48,19 @@ And use in Liquid templates:
44
48
  If 'Home' key wasn't found anywhere in the message catalog, or you
45
49
  didn't select any locale, a string 'Home' will be used.
46
50
 
47
- More info [here](http://gromnitsky.blogspot.com/2013/10/multi-lingual-interface-with-jekyll.html).
51
+ More info (for version 0.0.2)
52
+ [here](http://gromnitsky.blogspot.com/2013/10/multi-lingual-interface-with-jekyll.html).
53
+
54
+ ## News
55
+
56
+ * 1.0.0
57
+
58
+ - The 2nd parameter for `cur_page_in_another_locale` filter in not a
59
+ class name, but an anchor name. The optional class name is a 3rd
60
+ parameter now.
61
+
62
+ - ``_msgcat.yaml`` file must be in a site source directory (see Usage
63
+ section).
48
64
 
49
65
  ## License
50
66
 
@@ -13,9 +13,10 @@ module Jekyll
13
13
  return @@__msgcat if @@__msgcat
14
14
 
15
15
  begin
16
- @@__msgcat = YAML.load_file MSGCAT_DB, :safe => false
16
+ file = File.join (__get_site["source"] || "./"), MSGCAT_DB
17
+ @@__msgcat = YAML.load_file file, :safe => false
17
18
  rescue
18
- $stderr.puts "msgcat warning: #{MSGCAT_DB} not found"
19
+ $stderr.puts "msgcat warning: `#{file}` not found: #{$!}"
19
20
  return nil
20
21
  end
21
22
 
@@ -45,11 +46,11 @@ module Jekyll
45
46
  (msg = msgcat[locale][input]) ? msg : input
46
47
  end
47
48
 
48
- def cur_page_in_another_locale targetLocale, cssClass = 'btn btn-primary btn-xs'
49
+ def cur_page_in_another_locale targetLocale, label = nil, cssClass = nil
49
50
  raise 'target locale requred' if targetLocale =~ /^\s*$/
50
51
 
51
52
  site = __get_site
52
- pattern = "<a href='%s' class='#{cssClass} %s'>#{targetLocale}</a>"
53
+ pattern = "<a href='%s' class='#{cssClass} %s'>#{label || targetLocale}</a>"
53
54
  locale = __get_locale || 'en'
54
55
 
55
56
  # current site
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "bundler", "~> 1.3"
21
+ spec.add_dependency "bundler", "~> 1.7"
22
22
  spec.add_dependency "andand", "~> 1.3.3"
23
23
  spec.add_dependency "safe_yaml"
24
24
 
data/lib/jekyll/msgcat.rb CHANGED
@@ -13,9 +13,10 @@ module Jekyll
13
13
  return @@__msgcat if @@__msgcat
14
14
 
15
15
  begin
16
- @@__msgcat = YAML.load_file MSGCAT_DB, :safe => false
16
+ file = File.join (__get_site["source"] || "./"), MSGCAT_DB
17
+ @@__msgcat = YAML.load_file file, :safe => false
17
18
  rescue
18
- $stderr.puts "msgcat warning: #{MSGCAT_DB} not found"
19
+ $stderr.puts "msgcat warning: `#{file}` not found: #{$!}"
19
20
  return nil
20
21
  end
21
22
 
@@ -45,11 +46,11 @@ module Jekyll
45
46
  (msg = msgcat[locale][input]) ? msg : input
46
47
  end
47
48
 
48
- def cur_page_in_another_locale targetLocale, cssClass = 'btn btn-primary btn-xs'
49
+ def cur_page_in_another_locale targetLocale, label = nil, cssClass = nil
49
50
  raise 'target locale requred' if targetLocale =~ /^\s*$/
50
51
 
51
52
  site = __get_site
52
- pattern = "<a href='%s' class='#{cssClass} %s'>#{targetLocale}</a>"
53
+ pattern = "<a href='%s' class='#{cssClass} %s'>#{label || targetLocale}</a>"
53
54
  locale = __get_locale || 'en'
54
55
 
55
56
  # current site
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Msgcat
3
- VERSION = "0.0.2"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
data/test/test_msgcat.rb CHANGED
@@ -26,7 +26,7 @@ end
26
26
 
27
27
  require 'minitest/autorun'
28
28
 
29
- class MsgcatTest < Minitest::Test
29
+ class MsgcatTest < Minitest::Unit::TestCase
30
30
  include Site_ru
31
31
  include Jekyll::Msgcat
32
32
 
@@ -62,11 +62,15 @@ class MsgcatTest < Minitest::Test
62
62
 
63
63
 
64
64
  def test_cur_page_in_another_locale__this_locale
65
- assert_equal "<a href='#' class='btn btn-primary btn-xs disabled'>ru</a>", cur_page_in_another_locale('ru')
65
+ assert_equal "<a href='#' class=' disabled'>ru</a>", cur_page_in_another_locale('ru')
66
+ end
67
+
68
+ def test_cur_page_in_another_locale__this_locale_custom_label
69
+ assert_equal "<a href='#' class=' disabled'>Booo</a>", cur_page_in_another_locale('ru', 'Booo')
66
70
  end
67
71
 
68
72
  def test_cur_page_in_another_locale__this_locale_custom_class
69
- assert_equal "<a href='#' class='myclass1 myclass2 disabled'>ru</a>", cur_page_in_another_locale('ru', "myclass1 myclass2")
73
+ assert_equal "<a href='#' class='myclass1 myclass2 disabled'>ru</a>", cur_page_in_another_locale('ru', nil, "myclass1 myclass2")
70
74
  end
71
75
 
72
76
  def test_cur_page_in_another_locale__no_url_in_config
@@ -81,19 +85,19 @@ class MsgcatTest < Minitest::Test
81
85
  def test_cur_page_in_another_locale__domain_no_deploy
82
86
  @context.registers[:site].config['msgcat']['deploy'] = nil
83
87
  @context.registers[:site].config['url'] = 'http://lt.example.com'
84
- assert_equal "<a href='http://lt.example.com/foo/bar' class='btn btn-primary btn-xs '>lt</a>", cur_page_in_another_locale('lt')
88
+ assert_equal "<a href='http://lt.example.com/foo/bar' class=' '>lt</a>", cur_page_in_another_locale('lt')
85
89
  end
86
90
 
87
91
  def test_cur_page_in_another_locale__domain_no_deploy_no_msgcat
88
92
  @context.registers[:site].config['msgcat'] = nil
89
93
  @context.registers[:site].config['url'] = 'http://lt.example.com'
90
- assert_equal "<a href='http://lt.example.com/foo/bar' class='btn btn-primary btn-xs '>lt</a>", cur_page_in_another_locale('lt')
94
+ assert_equal "<a href='http://lt.example.com/foo/bar' class=' '>lt</a>", cur_page_in_another_locale('lt')
91
95
  end
92
96
 
93
97
  def test_cur_page_in_another_locale__domain
94
98
  @context.registers[:site].config['msgcat']['deploy'] = 'domain'
95
99
  @context.registers[:site].config['url'] = 'http://lt.example.com'
96
- assert_equal "<a href='http://lt.example.com/foo/bar' class='btn btn-primary btn-xs '>lt</a>", cur_page_in_another_locale('lt')
100
+ assert_equal "<a href='http://lt.example.com/foo/bar' class=' '>lt</a>", cur_page_in_another_locale('lt')
97
101
  end
98
102
 
99
103
  def test_cur_page_in_another_locale__nearby_no_baseurl
@@ -109,7 +113,7 @@ class MsgcatTest < Minitest::Test
109
113
  @context.registers[:site].config['msgcat']['locale'] = 'uk'
110
114
  @context.registers[:site].config['msgcat']['deploy'] = 'nearby'
111
115
  @context.registers[:site].config['baseurl'] = '/blog/lt'
112
- assert_equal "<a href='/blog/lt/foo/bar' class='btn btn-primary btn-xs '>lt</a>", cur_page_in_another_locale('lt')
116
+ assert_equal "<a href='/blog/lt/foo/bar' class=' '>lt</a>", cur_page_in_another_locale('lt')
113
117
  end
114
118
 
115
119
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-msgcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Gromnitsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: andand
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: safe_yaml
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Multi-Lingual Interface With Jekyll
@@ -87,7 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
90
+ - ".gitignore"
91
91
  - Gemfile
92
92
  - LICENSE.txt
93
93
  - README.md
@@ -120,17 +120,17 @@ require_paths:
120
120
  - lib
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - '>='
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.0.7
133
+ rubygems_version: 2.4.2
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Multi-lingual interface with Jekyll via .yaml message catalogs.