guard-i18n-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Dingding Ye
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # Guard::I18nJs
2
+
3
+ i18n-js guard runs the i18n-js exporter to generate the new
4
+ translations js when needed
5
+
6
+ - Compatible with i18n-js 3.0.0.rc*
7
+ - Tested on Ruby 1.8.7, 1.9.2 & 1.9.3
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'guard-i18n-js'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+
25
+ ```bash
26
+ $ gem install guard-i18n-js
27
+ ```
28
+
29
+ Add guard definitions to your Guardfile by running:
30
+
31
+ ```bash
32
+ $ guard init i18n-js
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ Please read the {Guard usage docs}[https://github.com/guard/guard#readme]
38
+
39
+ ### Standard Ruby on Rails project
40
+
41
+ ```ruby
42
+ guard 'i18n-js' do
43
+ watch(%r{config/locales/.+\.yml})
44
+ end
45
+ ```
46
+
47
+ ## Development
48
+
49
+ * Source hosted at [GitHub](https://github.com/sishen/guard-i18n-js)
50
+ * Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/sishen/guard-i18n-js/issues)
51
+
52
+ ## Authors
53
+
54
+ [Dingding Ye](https://github.com/sishen) ([@yedingding](https://twitter.com/yedingding))
@@ -0,0 +1 @@
1
+ require 'guard/i18n_js'
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ module Guard
4
+ class I18nJS
5
+ class Notifier
6
+ class << self
7
+ def guard_message(result, duration)
8
+ case result
9
+ when true
10
+ "I18n::JS translations has been exported\nin %.1f seconds." % [duration]
11
+ else
12
+ "I18n::JS translations can't be exported,\nplease check manually."
13
+ end
14
+ end
15
+
16
+ # failed | success
17
+ def guard_image(result)
18
+ icon = if result
19
+ :success
20
+ else
21
+ :failed
22
+ end
23
+ end
24
+
25
+ def notify(result, duration)
26
+ message = guard_message(result, duration)
27
+ image = guard_image(result)
28
+
29
+ ::Guard::Notifier.notify(message, :title => 'I18n::JS export', :image => image)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ guard 'i18n-js' do
2
+ watch( %r{config/locales/.+\.yml} )
3
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module I18nJSVersion
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'i18n-js'
4
+
5
+ module Guard
6
+ class I18nJS < Guard
7
+ autoload :Notifier, 'guard/i18n-js/notifier'
8
+
9
+ def start
10
+ refresh_translations
11
+ end
12
+
13
+ def reload
14
+ refresh_translations
15
+ end
16
+
17
+ def run_all
18
+ true
19
+ end
20
+
21
+ def stop
22
+ true
23
+ end
24
+
25
+ def run_on_additions(paths = [])
26
+ refresh_translations
27
+ end
28
+
29
+ def run_on_modifications(paths = [])
30
+ refresh_translations
31
+ end
32
+
33
+ private
34
+
35
+ def refresh_translations
36
+ ::Guard::UI.info 'Refresh I18n::JS translations', :reset => true
37
+ start_at = Time.now
38
+ @result = system("bundle exec rails runner I18n::JS.export")
39
+ Notifier.notify(@result, Time.now - start_at)
40
+ @result
41
+ end
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-i18n-js
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dingding Ye
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: i18n-js
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.0.rc3
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.0.rc3
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ description: Guard::I18nJS automatically export your i18n js transations when needed
79
+ email:
80
+ - yedingding@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - lib/guard/i18n-js/notifier.rb
86
+ - lib/guard/i18n-js/templates/Guardfile
87
+ - lib/guard/i18n-js/version.rb
88
+ - lib/guard/i18n-js.rb
89
+ - lib/guard/i18n_js.rb
90
+ - LICENSE
91
+ - README.md
92
+ homepage: http://rubygems.org/gems/guard-i18n-js
93
+ licenses: []
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --charset=UTF-8
97
+ - --main=README.md
98
+ - --exclude='(lib|test|spec)|(Gem|Guard|Rake)file'
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: 1.3.6
113
+ requirements: []
114
+ rubyforge_project: guard-i18n-js
115
+ rubygems_version: 1.8.23
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Guard gem for i18n-js
119
+ test_files: []
120
+ has_rdoc: