Hello community, here is the log from the commit of package rubygem-gettext_i18n_rails_js for openSUSE:Factory checked in at 2015-04-12 00:11:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-gettext_i18n_rails_js (Old) and /work/SRC/openSUSE:Factory/.rubygem-gettext_i18n_rails_js.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-gettext_i18n_rails_js" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-gettext_i18n_rails_js/rubygem-gettext_i18n_rails_js.changes 2015-02-27 10:59:39.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-gettext_i18n_rails_js.new/rubygem-gettext_i18n_rails_js.changes 2015-04-12 00:11:09.000000000 +0200 @@ -1,0 +2,8 @@ +Sat Apr 11 06:09:02 UTC 2015 - coolo@suse.com + +- updated to version 1.0.2 + * Fixes exception when parsing empty js/coffee files + * Avoid methods defined in rake task exposing globally + * Added better configuration options + +------------------------------------------------------------------- Old: ---- gettext_i18n_rails_js-1.0.1.gem New: ---- gettext_i18n_rails_js-1.0.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-gettext_i18n_rails_js.spec ++++++ --- /var/tmp/diff_new_pack.4N7To8/_old 2015-04-12 00:11:10.000000000 +0200 +++ /var/tmp/diff_new_pack.4N7To8/_new 2015-04-12 00:11:10.000000000 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-gettext_i18n_rails_js -Version: 1.0.1 +Version: 1.0.2 Release: 0 %define mod_name gettext_i18n_rails_js %define mod_full_name %{mod_name}-%{version} ++++++ gettext_i18n_rails_js-1.0.1.gem -> gettext_i18n_rails_js-1.0.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2015-02-24 20:48:08.000000000 +0100 +++ new/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,11 @@ # Changelog +## [1.0.2](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.0.2) - 2015-03-30 + +* Fixes exception when parsing empty js/coffee files +* Avoid methods defined in rake task exposing globally +* Added better configuration options + ## [1.0.1](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.0.1) - 2015-02-24 * Added missing javascripts to the gemspec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2015-02-24 20:48:08.000000000 +0100 +++ new/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -82,6 +82,22 @@ pretty: false ``` +If you prefer an initializer file within your rails application you can use +that in favor of the YML configuration as well: + +```ruby +GettextI18nRailsJs.config do |config| + config.output_path = "app/assets/javascripts/locale" + + config.handlebars_function = "__" + config.javascript_function = "__" + + config.jed_options = { + pretty: false + } +end +``` + ## Todo Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/assets/javascripts/gettext/all.js new/lib/assets/javascripts/gettext/all.js --- old/lib/assets/javascripts/gettext/all.js 2015-02-24 20:48:08.000000000 +0100 +++ new/lib/assets/javascripts/gettext/all.js 1970-01-01 01:00:00.000000000 +0100 @@ -26,7 +26,7 @@ //= require_self (function() { - var locales = locales || {}; + var locales = this.locales || {}; var locale = document.getElementsByTagName('html')[0].lang; if(!locale) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/gettext_i18n_rails_js/config.rb new/lib/gettext_i18n_rails_js/config.rb --- old/lib/gettext_i18n_rails_js/config.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/gettext_i18n_rails_js/config.rb 1970-01-01 01:00:00.000000000 +0100 @@ -0,0 +1,75 @@ +# -*- coding: UTF-8 -*- +# +# 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. +# + +module GettextI18nRailsJs + class Config + attr_accessor :output_path + attr_accessor :handlebars_function + attr_accessor :javascript_function + attr_accessor :jed_options + + def initialize(&block) + @output_path = defaults[:output_path] + @handlebars_function = defaults[:handlebars_function] + @javascript_function = defaults[:javascript_function] + @jed_options = defaults[:jed_options].symbolize_keys + + instance_eval(&block) if block_given? + end + + protected + + def defaults + file = ::Rails.root.join( + "config", + "gettext_i18n_rails_js.yml" + ) + + values = { + output_path: File.join( + "app", + "assets", + "javascripts", + "locale" + ), + handlebars_function: "__", + javascript_function: "__", + jed_options: { + pretty: false + } + } + + if file.exist? + yaml = YAML.load_file(file) || {} + + values.deep_merge( + yaml + ).with_indifferent_access + else + values.with_indifferent_access + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/gettext_i18n_rails_js/parser/javascript.rb new/lib/gettext_i18n_rails_js/parser/javascript.rb --- old/lib/gettext_i18n_rails_js/parser/javascript.rb 2015-02-24 20:48:08.000000000 +0100 +++ new/lib/gettext_i18n_rails_js/parser/javascript.rb 1970-01-01 01:00:00.000000000 +0100 @@ -43,13 +43,13 @@ protected def collect_for(value) - ::File.new( - value - ).each_line.each_with_index.collect do |line, idx| - line.scan(invoke_regex).collect do |function, arguments| - yield(function, arguments, idx + 1) - end - end.inject(:+).compact + ::File.open(value) do |f| + f.each_line.each_with_index.collect do |line, idx| + line.scan(invoke_regex).collect do |function, arguments| + yield(function, arguments, idx + 1) + end + end.inject([], :+).compact + end end def invoke_regex diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/gettext_i18n_rails_js/task.rb new/lib/gettext_i18n_rails_js/task.rb --- old/lib/gettext_i18n_rails_js/task.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/gettext_i18n_rails_js/task.rb 1970-01-01 01:00:00.000000000 +0100 @@ -0,0 +1,98 @@ +# -*- coding: UTF-8 -*- +# +# 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. +# + +module GettextI18nRailsJs + module Task + extend self + + def po_to_json + GettextI18nRailsJs::Parser::Javascript + .gettext_function = GettextI18nRailsJs.config.javascript_function + + GettextI18nRailsJs::Parser::Handlebars + .gettext_function = GettextI18nRailsJs.config.handlebars_function + + if files_list.empty? + puts "Couldn't find PO files in #{locale_path}, run 'rake gettext:find'" + else + files_list.each do |input| + # Language is used for filenames, while language code is used as the + # in-app language code. So for instance, simplified chinese will live + # in app/assets/locale/zh_CN/app.js but inside the file the language + # will be referred to as locales['zh-CN']. This is to adapt to the + # existing gettext_rails convention. + + language = input.dirname.basename.to_s + language_code = language.gsub("_", "-") + + destination = output_path.join(language) + destination.mkpath + + json = PoToJson.new( + input.to_s + ).generate_for_jed( + language_code, + GettextI18nRailsJs.config.jed_options + ) + + destination.join("app.js").open("w") do |f| + f.rewind + f.write(json) + end + + puts "Created app.js in #{destination}" + end + + puts + puts "All files created, make sure they are being added to your assets." + puts "If they are not, you can add them with this line (configurable):" + puts + puts "//= require_tree ./locale" + puts "//= require gettext/all" + puts + end + end + + protected + + def files_list + require "gettext_i18n_rails/tasks" + + ::Pathname.glob( + ::File.join( + locale_path, + "**", + "*.po" + ) + ) + end + + def output_path + ::Rails.root.join( + GettextI18nRailsJs.config.output_path + ) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/gettext_i18n_rails_js/version.rb new/lib/gettext_i18n_rails_js/version.rb --- old/lib/gettext_i18n_rails_js/version.rb 2015-02-24 20:48:08.000000000 +0100 +++ new/lib/gettext_i18n_rails_js/version.rb 1970-01-01 01:00:00.000000000 +0100 @@ -27,7 +27,7 @@ class Version MAJOR = 1 MINOR = 0 - PATCH = 1 + PATCH = 2 PRE = nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/gettext_i18n_rails_js.rb new/lib/gettext_i18n_rails_js.rb --- old/lib/gettext_i18n_rails_js.rb 2015-02-24 20:48:08.000000000 +0100 +++ new/lib/gettext_i18n_rails_js.rb 1970-01-01 01:00:00.000000000 +0100 @@ -42,7 +42,13 @@ require_relative "gettext_i18n_rails_js/version" require_relative "gettext_i18n_rails_js/parser" +require_relative "gettext_i18n_rails_js/config" require_relative "gettext_i18n_rails_js/engine" module GettextI18nRailsJs + class << self + def config(&block) + @config ||= GettextI18nRailsJs::Config.new(&block) + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tasks/gettext_i18n_rails_js_tasks.rake new/lib/tasks/gettext_i18n_rails_js_tasks.rake --- old/lib/tasks/gettext_i18n_rails_js_tasks.rake 2015-02-24 20:48:08.000000000 +0100 +++ new/lib/tasks/gettext_i18n_rails_js_tasks.rake 1970-01-01 01:00:00.000000000 +0100 @@ -24,104 +24,12 @@ # require "gettext_i18n_rails/tasks" +require "gettext_i18n_rails_js/task" namespace :gettext do desc "Convert PO files to JS files" task po_to_json: :environment do - GettextI18nRailsJs::Parser::Javascript - .gettext_function = config[:javascript_function] - - GettextI18nRailsJs::Parser::Handlebars - .gettext_function = config[:handlebars_function] - - if files_list.empty? - puts "Couldn't find PO files in #{locale_path}, run 'rake gettext:find'" - else - files_list.each do |input| - # Language is used for filenames, while language code is used as the - # in-app language code. So for instance, simplified chinese will live - # in app/assets/locale/zh_CN/app.js but inside the file the language - # will be referred to as locales['zh-CN']. This is to adapt to the - # existing gettext_rails convention. - - language = input.dirname.basename.to_s - language_code = language.gsub("_", "-") - - destination = output_path.join(language) - destination.mkpath - - json = PoToJson.new( - input.to_s - ).generate_for_jed( - language_code, - config[:jed_options].symbolize_keys - ) - - destination.join("app.js").open("w") do |f| - f.rewind - f.write(json) - end - - puts "Created app.js in #{destination}" - end - - puts - puts "All files created, make sure they are being added to your assets." - puts "If they are not, you can add them with this line (configurable):" - puts - puts "//= require_tree ./locale" - puts "//= require gettext/all" - puts - end - end - - def files_list - Pathname.glob( - ::File.join( - locale_path, - "**", - "*.po" - ) - ) - end - - def output_path - Rails.root.join( - config[:output_path] - ) - end - - def config - @config ||= begin - file = Rails.root.join( - "config", - "gettext_i18n_rails_js.yml" - ) - - defaults = { - output_path: File.join( - "app", - "assets", - "javascripts", - "locale" - ), - handlebars_function: "__", - javascript_function: "__", - jed_options: { - pretty: false - } - } - - if file.exist? - yaml = YAML.load_file(file) || {} - - defaults.deep_merge( - yaml - ).with_indifferent_access - else - defaults.with_indifferent_access - end - end + GettextI18nRailsJs::Task.po_to_json end # Required for gettext to filter the files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-02-24 20:48:08.000000000 +0100 +++ new/metadata 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: gettext_i18n_rails_js version: !ruby/object:Gem::Version - version: 1.0.1 + version: 1.0.2 platform: ruby authors: - Thomas Boerger @@ -9,120 +9,120 @@ autorequire: bindir: bin cert_chain: [] -date: 2015-02-24 00:00:00.000000000 Z +date: 2015-03-30 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: yard requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rails requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 3.2.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 3.2.0 - !ruby/object:Gem::Dependency name: gettext requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 3.0.2 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 3.0.2 - !ruby/object:Gem::Dependency name: gettext_i18n_rails requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 0.7.1 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 0.7.1 - !ruby/object:Gem::Dependency name: po_to_json requirement: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version - version: 0.1.0 + version: 1.0.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version - version: 0.1.0 + version: 1.0.0 description: |2 It will find translations inside your .js and .coffee files, then it will create JSON versions of your .PO files and will let you serve them with the @@ -136,26 +136,28 @@ extra_rdoc_files: [] files: - CHANGELOG.md -- LICENSE - README.md -- lib/assets/javascripts/gettext/all.js +- LICENSE +- lib/tasks/gettext_i18n_rails_js_tasks.rake - lib/gettext_i18n_rails_js.rb +- lib/assets/javascripts/gettext/all.js +- lib/gettext_i18n_rails_js/version.rb +- lib/gettext_i18n_rails_js/config.rb - lib/gettext_i18n_rails_js/engine.rb -- lib/gettext_i18n_rails_js/parser.rb +- lib/gettext_i18n_rails_js/task.rb - lib/gettext_i18n_rails_js/parser/base.rb - lib/gettext_i18n_rails_js/parser/handlebars.rb - lib/gettext_i18n_rails_js/parser/javascript.rb -- lib/gettext_i18n_rails_js/version.rb -- lib/tasks/gettext_i18n_rails_js_tasks.rake +- lib/gettext_i18n_rails_js/parser.rb +- vendor/assets/javascripts/gettext/jed.js +- spec/spec_helper.rb - spec/fixtures/example.coffee -- spec/fixtures/example.handlebars - spec/fixtures/example.js +- spec/fixtures/example.handlebars +- spec/support/with_file.rb +- spec/gettext_i18n_rails_js_spec.rb - spec/gettext_i18n_rails_js/parser/handlebars_spec.rb - spec/gettext_i18n_rails_js/parser/javascript_spec.rb -- spec/gettext_i18n_rails_js_spec.rb -- spec/spec_helper.rb -- spec/support/with_file.rb -- vendor/assets/javascripts/gettext/jed.js homepage: https://github.com/webhippie/gettext_i18n_rails_js licenses: - MIT @@ -166,28 +168,28 @@ - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: 1.9.3 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.5 +rubygems_version: 2.0.3 signing_key: specification_version: 4 summary: Extends gettext_i18n_rails making your .po files available to client side javascript as JSON test_files: +- spec/spec_helper.rb - spec/fixtures/example.coffee -- spec/fixtures/example.handlebars - spec/fixtures/example.js +- spec/fixtures/example.handlebars +- spec/support/with_file.rb +- spec/gettext_i18n_rails_js_spec.rb - spec/gettext_i18n_rails_js/parser/handlebars_spec.rb - spec/gettext_i18n_rails_js/parser/javascript_spec.rb -- spec/gettext_i18n_rails_js_spec.rb -- spec/spec_helper.rb -- spec/support/with_file.rb has_rdoc: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/gettext_i18n_rails_js/parser/javascript_spec.rb new/spec/gettext_i18n_rails_js/parser/javascript_spec.rb --- old/spec/gettext_i18n_rails_js/parser/javascript_spec.rb 2015-02-24 20:48:08.000000000 +0100 +++ new/spec/gettext_i18n_rails_js/parser/javascript_spec.rb 1970-01-01 01:00:00.000000000 +0100 @@ -236,6 +236,16 @@ ) end end + + it "does not parse empty files" do + content = "" + + with_file content do |path| + expect(parser.parse(path, [])).to( + eq([]) + ) + end + end end describe "parses javascript files" do