wordchuck 0.0.16

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,15 @@
1
+
2
+ Copyright (c) Wordchuck Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+
2
+ = Wordchuck
3
+
4
+ More details TBA.
5
+
6
+ == Copyright
7
+
8
+ Copyright (c) 2010 Wordchuck Inc. See LICENSE for details. http://wordchuck.com.
9
+
10
+ == License
11
+
12
+ Copyright (c) Wordchuck Inc.
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
15
+ files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
16
+ modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
17
+ Software is furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
20
+ Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
24
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,75 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ require 'rubygems'
19
+ require 'rake'
20
+
21
+ begin
22
+ require 'jeweler'
23
+ Jeweler::Tasks.new do |gem|
24
+ gem.name = "wordchuck"
25
+ gem.summary = %Q{gem for the Wordchuck website translation service}
26
+ gem.description = %Q{gem for the Wordchuck website translation service for locale file generation}
27
+
28
+ gem.email = "shelly@wordchuck.com"
29
+ gem.homepage = "http://github.com/shellyroche/wordchuck"
30
+ gem.authors = ["Shelly Roche"]
31
+ gem.rubyforge_project = "wordchuck"
32
+ gem.files = FileList['[A-Z]*', 'lib/**/*.rb', 'lib/tasks/*.rake', 'test/**/*.rb']
33
+
34
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
35
+ gem.add_dependency 'rest-client', '~> 1.6.0'
36
+ gem.add_dependency 'json_pure', '>= 1.4.4'
37
+ gem.add_dependency 'human_hash', '>= 0.2.1'
38
+ end
39
+ Jeweler::GemcutterTasks.new
40
+ rescue LoadError
41
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
42
+ end
43
+
44
+ require 'rake/testtask'
45
+ Rake::TestTask.new(:test) do |test|
46
+ test.libs << 'lib' << 'test'
47
+ test.pattern = 'test/**/test_*.rb'
48
+ test.verbose = true
49
+ end
50
+
51
+ begin
52
+ require 'rcov/rcovtask'
53
+ Rcov::RcovTask.new do |test|
54
+ test.libs << 'test'
55
+ test.pattern = 'test/**/test_*.rb'
56
+ test.verbose = true
57
+ end
58
+ rescue LoadError
59
+ task :rcov do
60
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
61
+ end
62
+ end
63
+
64
+ task :test => :check_dependencies
65
+ task :default => :test
66
+
67
+ require 'rake/rdoctask'
68
+ Rake::RDocTask.new do |rdoc|
69
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
70
+
71
+ rdoc.rdoc_dir = 'rdoc'
72
+ rdoc.title = "wordchuck #{version}"
73
+ rdoc.rdoc_files.include('README*')
74
+ rdoc.rdoc_files.include('lib/**/*.rb')
75
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.16
@@ -0,0 +1,23 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ namespace :wordchuck do
19
+ desc "Generates the project's locale files with the latest content and translations at wordchuck.com."
20
+ task :generate => :environment do
21
+ Wordchuck::Chucker.generate
22
+ end
23
+ end
@@ -0,0 +1,61 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ require 'rubygems'
19
+ require 'active_support'
20
+ require 'json'
21
+ require 'rest-client'
22
+ require 'human_hash'
23
+
24
+ module Wordchuck
25
+ class << self
26
+ #
27
+ # = Wordchuck Configuraton
28
+ #
29
+ # Call the configure method within a application configuration initializer to set your project key (and other goodies):
30
+ # Wordchuck.configure do |chuck|
31
+ # chuck.project_key = 'from.wordhuck.com.members.area'
32
+ # chuck.quiet = true
33
+ # end
34
+ #
35
+
36
+ attr_accessor :configuration
37
+ def configure
38
+ self.configuration ||= Configuration.new
39
+ yield(configuration)
40
+ end
41
+ def has_project_key?
42
+ self.configuration ||= Configuration.new
43
+ configuration.has_project_key?
44
+ end
45
+
46
+ def no_project_key
47
+ "No project key configured. A project key is needed to identify the project in question with the Wordchuck API."
48
+ end
49
+ def api_failure
50
+ "There was an unexpected API response code. Not HTTP 200. Failed."
51
+ end
52
+ end
53
+
54
+ class Error < RuntimeError
55
+ end
56
+ end
57
+
58
+ require 'wordchuck/configuration'
59
+ require 'wordchuck/client'
60
+ require 'wordchuck/chucker'
61
+ require 'wordchuck/railtie' if defined?(Rails::Railtie)
@@ -0,0 +1,91 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ ##
19
+ # The thinking behind this class name for putting the locales in .rb for i18n simple backend ingestion is obvious enough,
20
+ # at least to us:
21
+ # http://www.youtube.com/watch?v=DjGwusHrOtk
22
+ ##
23
+
24
+ module Wordchuck
25
+ class Chucker
26
+ class << self
27
+ def generate
28
+ if Wordchuck.has_project_key?
29
+ begin
30
+ puts "Acquiring Locales List [production|development]..." unless Wordchuck.configuration.quiet?
31
+ if locales = Wordchuck::Client.get_locales
32
+ puts "DONE."
33
+ locales['development']['locales'].each do |locale|
34
+
35
+ puts "Acquiring Locale for Simple Backend [#{locale['code']}]..." unless Wordchuck.configuration.quiet?
36
+ Wordchuck::Client.get_locale(locale['code']) do |rh|
37
+ Wordchuck::Chucker.set_locale(locale['code'], rh['content'][locale['code']])
38
+ end
39
+
40
+ end
41
+ puts "DONE"
42
+ end
43
+ rescue Wordchuck::Error => error
44
+ puts error.message
45
+ end
46
+
47
+ else
48
+ puts Wordchuck.no_project_key end
49
+ end
50
+
51
+ def set_locale(locale, content)
52
+ set_locale_in_simple_backend(locale, content)
53
+ end
54
+
55
+ protected
56
+ def set_locale_in_simple_backend(locale, content)
57
+ ln = "#{Rails.root}/config/locales/#{locale}.rb"
58
+ File.rename(ln, "#{locale_pathname}.wcbak") if Wordchuck.configuration.backups? && File.exist?(ln)
59
+ File.open(ln, 'w') do |fd|
60
+ set_locale_header(fd, locale)
61
+ set_locale_start(fd, locale)
62
+ fd.write(content.human_inspect)
63
+ set_locale_end(fd)
64
+ end
65
+ end
66
+
67
+ private
68
+ def set_locale_header(fd, locale)
69
+ tmps = "# encoding: UTF-8\n"
70
+ tmps << "#\n"
71
+ tmps << "# DO NOT EDIT THIS FILE.\n"
72
+ tmps << "# This locale file is auto-generated from the Wordchuck API by the Wordchuck Ruby gem. Any manual\n"
73
+ tmps << "# updates to an rb file will be lost when this file is regenerated. This current file will be only\n"
74
+ tmps << "# versioned once, or discarded.\n"
75
+ tmps << "# http://wordchuck.com\n"
76
+ tmps << "#\n"
77
+ tmps << "##\n\n"
78
+ fd.write(tmps)
79
+ end
80
+ def set_locale_start(fd, locale)
81
+ fd.write("{\n :'#{locale}' =>\n\n")
82
+ end
83
+ def set_locale_end(fd)
84
+ fd.write("\n}\n\n")
85
+ end
86
+ def move_files_to_old
87
+ ## TBD
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,57 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ module Wordchuck
19
+ class Client
20
+ class << self
21
+ def get_locales
22
+ rh = submit_request('/v1/project/locales')
23
+ yield(rh) if (not rh.nil?) && block_given?
24
+ rh
25
+ end
26
+
27
+ def get_locale(locale)
28
+ rh = submit_request("/v1/project/content/#{locale}")
29
+ yield(rh) if (not rh.nil?) && block_given?
30
+ rh
31
+ end
32
+
33
+ protected
34
+ def submit_request(rs)
35
+ rh = nil
36
+ begin
37
+ rsce = RestClient::Resource.new(Wordchuck.configuration.api_host_url)
38
+ resp = rsce["#{rs}?api_key=#{Wordchuck.configuration.project_key}"].get
39
+ case resp.code
40
+ when 200
41
+ rh = JSON.parse(resp.body)
42
+ raise Wordchuck::Error, "A fatal Wordchuck API problem -> [#{rh['status']['message']}]." unless rh['status']['code'] == 200
43
+ end
44
+
45
+ ## We have some ideas for error reporting back to us automatically, but we will see when we can get to it,
46
+ ## after adding lots of other cool stuff first.
47
+
48
+ rescue JSON::ParserError
49
+ raise Wordchuck::Error, "Bad JSON! [#{resp.body}]"
50
+ rescue RestClient::InternalServerError
51
+ raise Wordchuck::Error, "There was a fatal and server error at wordchuck.com of an unknown nature. Stopped."
52
+ end
53
+ rh
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,49 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ module Wordchuck
19
+ class Configuration
20
+ attr_accessor :project_key, :quiet, :backups, :ssl
21
+
22
+ API_HOSTNAME = "www.wordchuck.com"
23
+ API_PROJECT_KEY_LENGTH = 18
24
+
25
+ def initialize
26
+ @project_key = nil
27
+ @quiet = false
28
+ @backups = false
29
+ @ssl = false
30
+ end
31
+
32
+ def has_project_key?
33
+ (not @project_key.nil?) && @project_key.is_a?(String) && @project_key.length == API_PROJECT_KEY_LENGTH
34
+ end
35
+ def quiet?
36
+ @quiet
37
+ end
38
+ def backups?
39
+ @backups
40
+ end
41
+ def ssl?
42
+ @ssl
43
+ end
44
+
45
+ def api_host_url
46
+ ssl? ? "https://#{API_HOSTNAME}" : "http://#{API_HOSTNAME}"
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,27 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ require 'wordchuck'
19
+ require 'rails'
20
+
21
+ module Wordchuck
22
+ class Railtie < Rails::Railtie
23
+ rake_tasks do
24
+ load "tasks/generate.rake"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
7
+ # is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
12
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
13
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
14
+ # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ ##
16
+
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require 'rubygems'
21
+ require 'test/unit'
22
+ require 'shoulda'
23
+ require 'wordchuck'
24
+
25
+ class Test::Unit::TestCase
26
+ DEMO_PROJECT_KEY = '1b1b3d2a73c4bcbb68'
27
+
28
+ def setup
29
+ Wordchuck.configure do |chuck|
30
+ chuck.project_key = DEMO_PROJECT_KEY
31
+ chuck.quiet = true
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,41 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
7
+ # is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
12
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
13
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
14
+ # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ ##
16
+
17
+ require 'helper'
18
+
19
+ class TestLocales < Test::Unit::TestCase
20
+ should "get english" do
21
+ en = Wordchuck::Client.get_locale('en')
22
+ puts en.inspect
23
+ assert_not_nil en['content']['en']['nav']
24
+ #assert_not_nil es['models']['en'][':activerecord']
25
+ end
26
+
27
+ should "get spanish" do
28
+ es = Wordchuck::Client.get_locale('es')
29
+ puts es.inspect
30
+ assert_not_nil es['content']['es']['nav']
31
+ #assert_not_nil es['models']['es'][':activerecord']
32
+ end
33
+
34
+ should "get french" do
35
+ fr = Wordchuck::Client.get_locale('fr')
36
+ puts fr.inspect
37
+ assert_not_nil fr['content']['fr']['nav']
38
+ #assert_not_nil es['models']['es'][':activerecord']
39
+ end
40
+
41
+ end
@@ -0,0 +1,27 @@
1
+ ##
2
+ # Copyright (c) Wordchuck Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
7
+ # is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
12
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
13
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
14
+ # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ ##
16
+
17
+ require 'helper'
18
+
19
+ class TestSelections < Test::Unit::TestCase
20
+ should "get demo locales list" do
21
+ locales = Wordchuck::Client.get_locales
22
+ puts locales.human_inspect
23
+ assert_equal 'en', locales['default']['locale']
24
+ assert_equal 3, locales['development']['locales'].length
25
+ assert_equal 3, locales['development']['selection'].length
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wordchuck
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 16
9
+ version: 0.0.16
10
+ platform: ruby
11
+ authors:
12
+ - Shelly Roche
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-26 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thoughtbot-shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rest-client
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 6
44
+ - 0
45
+ version: 1.6.0
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: json_pure
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 4
59
+ - 4
60
+ version: 1.4.4
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: human_hash
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ - 2
74
+ - 1
75
+ version: 0.2.1
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ description: gem for the Wordchuck website translation service for locale file generation
79
+ email: shelly@wordchuck.com
80
+ executables: []
81
+
82
+ extensions: []
83
+
84
+ extra_rdoc_files:
85
+ - LICENSE
86
+ - README.rdoc
87
+ files:
88
+ - LICENSE
89
+ - README.rdoc
90
+ - Rakefile
91
+ - VERSION
92
+ - lib/tasks/generate.rake
93
+ - lib/wordchuck.rb
94
+ - lib/wordchuck/chucker.rb
95
+ - lib/wordchuck/client.rb
96
+ - lib/wordchuck/configuration.rb
97
+ - lib/wordchuck/railtie.rb
98
+ - test/helper.rb
99
+ - test/test_locales.rb
100
+ - test/test_selections.rb
101
+ has_rdoc: true
102
+ homepage: http://github.com/shellyroche/wordchuck
103
+ licenses: []
104
+
105
+ post_install_message:
106
+ rdoc_options:
107
+ - --charset=UTF-8
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ segments:
124
+ - 0
125
+ version: "0"
126
+ requirements: []
127
+
128
+ rubyforge_project: wordchuck
129
+ rubygems_version: 1.3.7
130
+ signing_key:
131
+ specification_version: 3
132
+ summary: gem for the Wordchuck website translation service
133
+ test_files:
134
+ - test/helper.rb
135
+ - test/test_locales.rb
136
+ - test/test_selections.rb