-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite/refactor of the full code base
- Loading branch information
Thomas Boerger
committed
Feb 20, 2015
1 parent
7c56637
commit 10414e4
Showing
18 changed files
with
893 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.DS_Store | ||
|
||
/.idea | ||
/.yardoc | ||
/.bundle | ||
/.vagrant | ||
|
||
/coverage | ||
/pkg | ||
/doc | ||
/vendor | ||
|
||
/Gemfile.lock | ||
/Gemfile.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour --format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Style/StringLiterals: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringLiteralsInInterpolation: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/AlignParameters: | ||
EnforcedStyle: with_fixed_indentation | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Style/ModuleFunction: | ||
Enabled: false | ||
|
||
Style/WordArray: | ||
Enabled: false | ||
|
||
Style/PerlBackrefs: | ||
Enabled: false | ||
|
||
Style/ElseAlignment: | ||
Enabled: false | ||
|
||
Style/Next: | ||
Enabled: false | ||
|
||
Metrics/MethodLength: | ||
CountComments: false | ||
Max: 30 | ||
|
||
Metrics/ClassLength: | ||
Max: 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
language: ruby | ||
|
||
rvm: | ||
- 2.1.0 | ||
- 2.0.0 | ||
- 1.9.3 | ||
|
||
env: | ||
- JSON_VERSION=1.6.8 | ||
- JSON_VERSION=1.7.7 | ||
- JSON_VERSION=1.8.2 | ||
|
||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
on_success: change | ||
on_failure: always | ||
|
||
irc: | ||
channels: | ||
- "irc.freenode.net#webhippie" | ||
template: | ||
- "%{repository_slug} (%{commit}) : %{message} by %{author}" | ||
- "You can see details at %{build_url}" | ||
on_success: change | ||
on_failure: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## [0.1.0](https://github.com/webhippie/po_to_json/releases/tag/v0.1.0) - 2015-02-19 | ||
|
||
* Transfer from github.com/nubis/po_to_json | ||
* Added TravisCI, Rubocop and Coveralls | ||
* Updated structure to my opinionated gem style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,43 @@ | ||
source "http://rubygems.org" | ||
# | ||
# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com> | ||
# Copyright (c) 2015 Webhippie <http://www.webhippie.de> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be | ||
# included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
|
||
source "http://rubygems.org" | ||
gemspec | ||
|
||
gem "json", "~> #{ENV["JSON_VERSION"]}" if ENV["JSON_VERSION"] | ||
|
||
group :development do | ||
gem 'rspec' | ||
gem "guard", require: false | ||
gem "guard-rubocop", require: false | ||
gem "guard-rspec", require: false | ||
end | ||
|
||
group :test do | ||
gem "simplecov", require: false | ||
gem "coveralls", require: false | ||
gem "codeclimate-test-reporter", require: false | ||
gem "rubocop", require: false | ||
end | ||
|
||
instance_eval(File.read("Gemfile.local")) if File.exist? "Gemfile.local" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com> | ||
# Copyright (c) 2015 Webhippie <http://www.webhippie.de> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be | ||
# included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
|
||
guard :rspec, cmd: "bundle exec rspec", all_on_start: true do | ||
watch(/^spec\/.+_spec\.rb$/) | ||
watch(/^lib\/(.+)\.rb$/) { |m| "spec/lib/#{m[1]}_spec.rb" } | ||
watch("spec/spec_helper.rb") { "spec" } | ||
end | ||
|
||
guard :rubocop, all_on_start: true do | ||
watch(/.+\.rb$/) | ||
watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com> | ||
Copyright (c) 2015 Webhippie <http://www.webhippie.de> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,87 @@ | ||
## po_to_json | ||
# PoToJson | ||
|
||
Convert gettext PO files to json to use in your javascript app, based po2json.pl (by DuckDuckGo, Inc. http://duckduckgo.com/, Torsten Raudssus <[email protected]>. | ||
[](https://rubygems.org/gems/po_to_json) | ||
[](https://travis-ci.org/webhippie/po_to_json) | ||
[](https://codeclimate.com/github/webhippie/po_to_json) | ||
[](https://codeclimate.com/github/webhippie/po_to_json) | ||
[](https://gemnasium.com/webhippie/po_to_json) | ||
|
||
Ideally you'll use this on a rake task that creates json versions of your po files, which can later be used from javascript | ||
with Jed ( http://slexaxton.github.com/Jed/ ) | ||
Convert gettext PO files to JSON to use in your javascript app, based on | ||
po2json.pl by [DuckDuckGo, Inc.](http://duckduckgo.com/). Ideally you'll use | ||
this on a Rake task that creates JSON versions of your PO files, which can | ||
later be used from javascript with [Jed](http://slexaxton.github.io/Jed/) | ||
|
||
## Installing | ||
|
||
Via rubygems: | ||
```ruby | ||
gem install po_to_json | ||
``` | ||
## Versions | ||
|
||
This gem is tested on the following versions automated through TravisCI: | ||
|
||
* Ruby | ||
* 1.9.3 | ||
* 2.0.0 | ||
* 2.1.0 | ||
* Json | ||
* 1.6.8 | ||
* 1.7.7 | ||
* 1.8.2 | ||
|
||
|
||
## Installation | ||
|
||
In your gemfile: | ||
```ruby | ||
gem 'po_to_json' | ||
gem "po_to_json", "~> 0.1.0" | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
Most common use would be to generate a Jed ready javascript file. For example, in a Rails 3 project: | ||
Most common use would be to generate a Jed ready javascript file. For example, | ||
in a Rails project: | ||
|
||
```ruby | ||
require 'po_to_json' | ||
json_string = PoToJson.new("#{Rails.root}/locale/es/app.po").generate_for_jed('es') | ||
File.open("#{Rails.root}/app/assets/javascripts/locale/es/app.js",'w').write(json_string) | ||
require "po_to_json" | ||
|
||
json = PoToJson.new(Rails.root.join("locale", "de", "app.po").generate_for_jed("de") | ||
Rails.root.join("app", "assets", "javascripts", "locale", "de", "app.js").write(json) | ||
``` | ||
|
||
If you need a pretty json, add `:pretty => true` to `generate_for_jed`, like | ||
If you need a pretty json, add `pretty: true` to `generate_for_jed`, like the | ||
following example: | ||
|
||
```ruby | ||
json_string = PoToJson.new("#{Rails.root}/locale/es/app.po").generate_for_jed('es', :pretty => true) | ||
require "po_to_json" | ||
|
||
json = PoToJson.new(Rails.root.join("locale", "de", "app.po").generate_for_jed("de", pretty: true) | ||
Rails.root.join("app", "assets", "javascripts", "locale", "de", "app.js").write(json) | ||
``` | ||
|
||
The javascript file generated has a global 'locales' object with an attribute corresponding to the generated language: | ||
The javascript file generated has a global "locales" object with an attribute | ||
corresponding to the generated language: | ||
|
||
```javascript | ||
i18n = new Jed(locales['es']) | ||
i18n.gettext('Hello World') // Should evaluate to 'Hola Mundo' | ||
i18n = new Jed(locales["de"]) | ||
i18n.gettext("Hello World") // Should evaluate to "Hallo Welt" | ||
``` | ||
|
||
## Maintainers | ||
|
||
* eromirou (https://github.com/eromirou) | ||
* Nubis (https://github.com/nubis) | ||
## Contributing | ||
|
||
Fork -> Patch -> Spec -> Push -> Pull Request | ||
|
||
|
||
## Authors | ||
|
||
* [Thomas Boerger](https://github.com/tboerger) | ||
* [Nubis](https://github.com/nubis) | ||
* [Other contributors](https://github.com/webhippie/po_to_json/graphs/contributors) | ||
|
||
|
||
## License | ||
|
||
MIT License. Copyright 2012 Dropmysite.com. https://dropmyemail.com | ||
MIT | ||
|
||
|
||
## Copyright | ||
|
||
Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com> | ||
Copyright (c) 2015 Webhippie <http://www.webhippie.de> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com> | ||
# Copyright (c) 2015 Webhippie <http://www.webhippie.de> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be | ||
# included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
|
||
begin | ||
require "bundler" | ||
Bundler::GemHelper.install_tasks | ||
rescue LoadError | ||
warn "Failed to load bundler tasks" | ||
end | ||
|
||
require "rubocop/rake_task" | ||
RuboCop::RakeTask.new | ||
|
||
require "yard" | ||
YARD::Rake::YardocTask.new | ||
|
||
require "rspec/core/rake_task" | ||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task default: [:spec, :rubocop] |
Oops, something went wrong.