From d47c08b1250b7aa2ca4f5c9d2f21d141dcee65c8 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:03:11 +0100 Subject: [PATCH 01/12] ci: add separate workflows for testing, rubocop and release --- .github/workflows/CI.yaml | 52 -------------------------------- .github/workflows/release.yml | 22 ++++++++++++++ .github/workflows/rubocop.yml | 18 +++++++++++ .github/workflows/testing.yaml | 55 ++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/CI.yaml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/rubocop.yml create mode 100644 .github/workflows/testing.yaml diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml deleted file mode 100644 index d6e983a..0000000 --- a/.github/workflows/CI.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: CI -on: - pull_request: - push: - branches: - - master -jobs: - rubocop: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.1 - bundler-cache: true - - name: Run rubocop - if: github.event_name != 'push' - run: bundle exec rubocop - test_ruby: - runs-on: ubuntu-latest - needs: rubocop - timeout-minutes: 30 - strategy: - fail-fast: false - matrix: - ruby: [2.1, 2.5, 2.7] - rails: ['3.2', '4.2', '5.2', '6.1'] - exclude: - # excludes new rails on old ruby - - rails: '5.2' - ruby: 2.1 - - rails: '6.1' - ruby: 2.1 - # excludes old rails on new ruby - - rails: '3.2' - ruby: 2.7 - - rails: '4.2' - ruby: 2.7 - steps: - - uses: actions/checkout@v2 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler: 1.17 - bundler-cache: true - env: - RAILS_VERSION: ${{ matrix.rails }} - - name: Run tests - run: | - bundle exec rspec diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6cd217e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +--- +name: release + +"on": + push: + tags: + - v* + +jobs: + release: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Release gem + uses: dawidd6/action-publish-gem@v1 + with: + api_key: ${{ secrets.RUBYGEMS_API_KEY }} + +... diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..ecad9d0 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,18 @@ +--- +name: rubocop + +"on": + pull_request: + +jobs: + release: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Rubocop checks + uses: gimenete/rubocop-action@1.0 + +... diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml new file mode 100644 index 0000000..b0b1c67 --- /dev/null +++ b/.github/workflows/testing.yaml @@ -0,0 +1,55 @@ +--- +name: testing + +"on": + pull_request: + push: + branches: + - master + +jobs: + testing: + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + + matrix: + ruby: + - 2.1 + - 2.5 + - 2.7 + rails: + - 3.2 + - 4.2 + - 5.2 + - 6.1 + exclude: + # excludes new rails on old ruby + - rails: 5.2 + ruby: 2.1 + - rails: 6.1 + ruby: 2.1 + # excludes old rails on new ruby + - rails: 3.2 + ruby: 2.7 + - rails: 4.2 + ruby: 2.7 + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler: 1.17 + bundler-cache: true + env: + RAILS_VERSION: ${{ matrix.rails }} + + - name: Run rspec + run: bundle exec rspec + +... From a86450cffecf8bd3d09a9c273a98f6c346c65d07 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:03:27 +0100 Subject: [PATCH 02/12] ci: add renovate config --- .github/renovate.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/renovate.json diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..30e2f6b --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,11 @@ +{ + "extends": [ + "config:base", + ":semanticCommits", + ":semanticCommitType(deps)", + ":automergePatch" + ], + "labels": [ + "renovate" + ] +} \ No newline at end of file From 27c0ad5efb12b3756bb8bffe151149b40d4d2bf9 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:03:43 +0100 Subject: [PATCH 03/12] ci: add settings app config --- .github/settings.yml | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/settings.yml diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..7858cd1 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,66 @@ +--- +repository: + name: gettext_i18n_rails_js + description: Extends gettext_i18n_rails making your .PO files available to client side javascript as JSON + homepage: https://github.com/webhippie/gettext_i18n_rails_js + topics: ruby, rubygem, gettext, i18n, rails + + private: false + has_issues: true + has_projects: false + has_wiki: false + has_downloads: false + + default_branch: master + + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: true + +labels: + - name: bug + color: d73a4a + description: Something isn't working + - name: documentation + color: 0075ca + description: Improvements or additions to documentation + - name: duplicate + color: cfd3d7 + description: This issue or pull request already exists + - name: enhancement + color: a2eeef + description: New feature or request + - name: good first issue + color: 7057ff + description: Good for newcomers + - name: help wanted + color: 008672 + description: Extra attention is needed + - name: invalid + color: e4e669 + description: This doesn't seem right + - name: question + color: d876e3 + description: Further information is requested + - name: wontfix + color: ffffff + description: This will not be worked on + - name: hacktoberfest-accepted + color: cccccc + description: Accepted as a Hacktoberfest submission + - name: renovate + color: e99695 + description: Automated action from Renovate + +branches: + - name: master + protection: + required_status_checks: + strict: true + contexts: [] + enforce_admins: false + restrictions: + users: [] + teams: [] + +... From 8ba9817afd1de7c7e17537bc43415ace50c3ddbb Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:04:02 +0100 Subject: [PATCH 04/12] docs: update readme content --- README.md | 55 +++++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 7206c3a..732a8f3 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -# GettextI18nRailsJs +# gettext_i18n_rails_js -[![Gem Version](http://img.shields.io/gem/v/gettext_i18n_rails_js.svg)](https://rubygems.org/gems/gettext_i18n_rails_js) -[![Build Status](https://secure.travis-ci.org/webhippie/gettext_i18n_rails_js.svg)](https://travis-ci.org/webhippie/gettext_i18n_rails_js) -[![Code Climate](https://codeclimate.com/github/webhippie/gettext_i18n_rails_js.svg)](https://codeclimate.com/github/webhippie/gettext_i18n_rails_js) -[![Test Coverage](https://codeclimate.com/github/webhippie/gettext_i18n_rails_js/badges/coverage.svg)](https://codeclimate.com/github/webhippie/gettext_i18n_rails_js) -[![Dependency Status](https://gemnasium.com/webhippie/gettext_i18n_rails_js.svg)](https://gemnasium.com/webhippie/gettext_i18n_rails_js) +[![Test Status](https://github.com/webhippie/gettext_i18n_rails_js/actions/workflows/testing.yml/badge.svg)](https://github.com/webhippie/gettext_i18n_rails_js/actions/workflows/testing.yaml) +[![Join the Matrix chat at https://matrix.to/#/#webhippie:matrix.org](https://img.shields.io/badge/matrix-%23webhippie%3Amatrix.org-7bc9a4.svg)](https://matrix.to/#/#webhippie:matrix.org) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/51f241a0f0d7490cae0bdc04387f9d13)](https://www.codacy.com/gh/webhippie/gettext_i18n_rails_js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=webhippie/gettext_i18n_rails_js&utm_campaign=Badge_Grade) +[![Gem Version](https://badge.fury.io/rb/gettext_i18n_rails_js.svg)](https://badge.fury.io/rb/gettext_i18n_rails_js) Extends [gettext_i18n_rails](https://github.com/grosser/gettext_i18n_rails), making your .PO files available to client side javascript as JSON. It will find @@ -13,22 +12,10 @@ will create JSON versions of your .PO files so you can serve them with the rest of your assets, thus letting you access all your translations offline from client side javascript. - ## Versions -This gem is tested on the following versions, it's also possible that it works -with older versions, but because of version bumps at `gettext_i18n_rails` and -`fast_gettext` we have dropped the older versions from the testing matrix: - -* Ruby - * 2.1.0 - * 2.2.0 -* Rails - * 3.2.21 - * 4.0.13 - * 4.1.16 - * 4.2.7 - +For a list of the tested and supported Ruby and Rails versions please take a +look at the [wokflow](https://github.com/webhippie/gettext_i18n_rails_js/blob/master/.github/workflows/testing.yml). ## Installation @@ -38,28 +25,25 @@ gem "gettext_i18n_rails_js", "~> 1.2" ## Versioning -This library aims to adhere to [Semantic Versioning 2.0.0][semver]. -Violations of this scheme should be reported as bugs. Specifically, -if a minor or patch version is released that breaks backward -compatibility, a new version should be immediately released that -restores compatibility. Breaking changes to the public API will -only be introduced with new major versions. +This library aims to adhere to [Semantic Versioning 2.0.0][http://semver.org/]. +Violations of this scheme should be reported as bugs. Specifically, if a minor +or patch version is released that breaks backward compatibility, a new version +should be immediately released that restores compatibility. Breaking changes to +the public API will only be introduced with new major versions. -As a result of this policy, you can (and should) specify a -dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision. +As a result of this policy, you can (and should) specify a dependency on this +gem using the [Pessimistic Version Constraint][http://guides.rubygems.org/patterns/#pessimistic-version-constraint] +with two digits of precision. For example: ```ruby -spec.add_dependency 'gettext_i18n_rails_js', '~> 1.2' +spec.add_dependency "gettext_i18n_rails_js", "~> 1.2" ``` -[semver]: http://semver.org/ -[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint - ## Usage -set up you rails application with gettext support as usual, afterwards just +Set up you rails application with gettext support as usual, afterwards just execute the following rake task to export your translations to JSON: ```bash @@ -119,30 +103,25 @@ GettextI18nRailsJs.config do |config| end ``` - ## Todo * More deep testing against multiple Rails versions * Extend the current test suite, especially handlebars - ## 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/gettext_i18n_rails_js/graphs/contributors) - ## License MIT - ## Copyright ``` From 8988db74beb16db51d30c703445740ecade55aef Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:04:29 +0100 Subject: [PATCH 05/12] ci: use codacy instead of codeclimate --- spec/spec_helper.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 71d6e26..f7ea972 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,11 +23,13 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -require "simplecov" -require "codeclimate-test-reporter" if ENV["CODECLIMATE_REPO_TOKEN"] - -SimpleCov.start do - add_filter "/spec" +if ENV.key? "CODACY_PROJECT_TOKEN" + begin + require "codacy-coverage" + Codacy::Reporter.start + rescue + puts "Failed to load codacy-coverage gem" + end end require "gettext_i18n_rails_js" From 8efdee8ffae728f8c2581aa1b2d76ecfcde9e7ff Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:05:04 +0100 Subject: [PATCH 06/12] chore: increase patch version, add changelog --- CHANGELOG.md | 6 ++++++ lib/gettext_i18n_rails_js/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b94c54..e30b3d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.3.1](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.4.0) - 2021-12-08 + +* Fixed multiline translation strings (@delxen) +* Switched to Codacy for coverage reports (@tboerger) +* Switched to GitHub actions for CI (@ezr-ondrej) + ## [1.3.0](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.3.0) - 2017-03-16 * Fixed Handlebars translations with options (@mikezaby) diff --git a/lib/gettext_i18n_rails_js/version.rb b/lib/gettext_i18n_rails_js/version.rb index be424fd..daa1127 100644 --- a/lib/gettext_i18n_rails_js/version.rb +++ b/lib/gettext_i18n_rails_js/version.rb @@ -27,7 +27,7 @@ module GettextI18nRailsJs class Version MAJOR = 1 MINOR = 3 - PATCH = 0 + PATCH = 1 PRE = nil From 3727f519606b9ff0f432691dd14e2aef31400f4b Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:06:44 +0100 Subject: [PATCH 07/12] ci: fix naming for workflow --- .github/workflows/rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index ecad9d0..f15af70 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -5,7 +5,7 @@ name: rubocop pull_request: jobs: - release: + rubocop: runs-on: ubuntu-20.04 steps: From 66771b0999cd31d3dea28eb551a6c3b0065d7387 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:10:24 +0100 Subject: [PATCH 08/12] ci: fix secret for rubocop action --- .github/workflows/rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index f15af70..a5fdf0a 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -14,5 +14,7 @@ jobs: - name: Rubocop checks uses: gimenete/rubocop-action@1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ... From fe8c0fa14c6acb31f2288b7d2f1fe502272b4217 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 00:16:32 +0100 Subject: [PATCH 09/12] ci: put rubocop back into testing workflow --- .github/workflows/rubocop.yml | 20 -------------------- .github/workflows/testing.yaml | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 .github/workflows/rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml deleted file mode 100644 index a5fdf0a..0000000 --- a/.github/workflows/rubocop.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: rubocop - -"on": - pull_request: - -jobs: - rubocop: - runs-on: ubuntu-20.04 - - steps: - - name: Checkout source - uses: actions/checkout@v2 - - - name: Rubocop checks - uses: gimenete/rubocop-action@1.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -... diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index b0b1c67..f45e54e 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -8,7 +8,22 @@ name: testing - master jobs: - testing: + lint: + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.1 + bundler: 1.17 + bundler-cache: true + + - name: Run rubocop + run: bundle exec rubocop + + spec: runs-on: ubuntu-20.04 strategy: From 81c37adf4395f0e208a33c24e6853d7e64ee49c4 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 01:00:00 +0100 Subject: [PATCH 10/12] ci: make linting happy again --- .rubocop.yml | 23 ++++++++--- .rubocop_todo.yml | 30 -------------- CHANGELOG.md | 40 +++++++++---------- Gemfile | 3 +- README.md | 29 ++++++++------ Rakefile | 3 +- gettext_i18n_rails_js.gemspec | 9 +++-- lib/gettext_i18n_rails_js.rb | 3 +- lib/gettext_i18n_rails_js/config.rb | 11 ++--- lib/gettext_i18n_rails_js/engine.rb | 3 +- lib/gettext_i18n_rails_js/parser.rb | 3 +- lib/gettext_i18n_rails_js/parser/base.rb | 6 ++- .../parser/handlebars.rb | 3 +- .../parser/javascript.rb | 5 ++- lib/gettext_i18n_rails_js/task.rb | 3 +- lib/gettext_i18n_rails_js/version.rb | 3 +- lib/tasks/gettext_i18n_rails_js_tasks.rake | 3 +- .../parser/handlebars_spec.rb | 11 +++-- .../parser/javascript_spec.rb | 15 +++---- spec/gettext_i18n_rails_js_spec.rb | 3 +- spec/spec_helper.rb | 7 ++-- spec/support/with_file.rb | 3 +- 22 files changed, 114 insertions(+), 105 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index ebf5b06..dd965dc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,9 @@ -inherit_from: .rubocop_todo.yml +--- +Gemspec/RequiredRubyVersion: + Enabled: false + +Naming/HeredocDelimiterNaming: + Enabled: false Layout/ElseAlignment: Enabled: false @@ -30,19 +35,27 @@ Style/Next: Style/RegexpLiteral: Enabled: false +Style/SymbolArray: + EnforcedStyle: brackets + Metrics/MethodLength: CountComments: false Max: 30 -Style/SymbolArray: - EnforcedStyle: brackets - Metrics/ClassLength: Max: 300 +Metrics/AbcSize: + Max: 25 + +Metrics/PerceivedComplexity: + Max: 10 + Metrics/BlockLength: Exclude: - "gettext_i18n_rails_js.gemspec" - "**/*_spec.rb" - ExcludedMethods: + IgnoredMethods: - namespace + +... diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 89032cc..0000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,30 +0,0 @@ -Gemspec/OrderedDependencies: - Enabled: false - -Gemspec/RequiredRubyVersion: - Enabled: false - -Lint/DuplicateMethods: - Enabled: false - -Metrics/AbcSize: - Max: 22 - -Metrics/LineLength: - Exclude: - - spec/gettext_i18n_rails_js/parser/javascript_spec.rb - -Naming/HeredocDelimiterNaming: - Enabled: false - -Style/Encoding: - Enabled: false - -Style/ExpandPathArguments: - Enabled: false - -Style/FormatStringToken: - Enabled: false - -Style/TrailingCommaInArrayLiteral: - Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index e30b3d1..acc20aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,47 +2,47 @@ ## [1.3.1](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.4.0) - 2021-12-08 -* Fixed multiline translation strings (@delxen) -* Switched to Codacy for coverage reports (@tboerger) -* Switched to GitHub actions for CI (@ezr-ondrej) +* Fixed multiline translation strings (@delxen) +* Switched to Codacy for coverage reports (@tboerger) +* Switched to GitHub actions for CI (@ezr-ondrej) ## [1.3.0](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.3.0) - 2017-03-16 -* Fixed Handlebars translations with options (@mikezaby) -* Fixed latest Rubocop offenses (@mikezaby) -* Dropped failing coveralls, fixed codeclimate (@tboerger) +* Fixed Handlebars translations with options (@mikezaby) +* Fixed latest Rubocop offenses (@mikezaby) +* Dropped failing coveralls, fixed codeclimate (@tboerger) ## [1.2.0](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.2.0) - 2016-06-02 -* Support for JSX files (@artemv) -* Fixed test suite, reduced test matrix (@tboerger) +* Support for JSX files (@artemv) +* Fixed test suite, reduced test matrix (@tboerger) ## [1.1.0](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.1.0) - 2016-06-02 -* Replace hyphens with underscores in locale var from DOM (@filib) +* Replace hyphens with underscores in locale var from DOM (@filib) ## [1.0.4](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.0.4) - 2016-05-31 -* Support ES2015 template strings (@bradbarrow) +* Support ES2015 template strings (@bradbarrow) ## [1.0.3](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.0.3) - 2015-11-03 -* Stop using bundler within the core lib (@domcleal) +* Stop using bundler within the core lib (@domcleal) ## [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 (@tboerger) -* Avoid methods defined in rake task exposing globally (@tboerger) -* Added better configuration options (@tboerger) +* Fixes exception when parsing empty js/coffee files (@tboerger) +* Avoid methods defined in rake task exposing globally (@tboerger) +* Added better configuration options (@tboerger) ## [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 (@tboerger) +* Added missing javascripts to the gemspec (@tboerger) ## [1.0.0](https://github.com/webhippie/gettext_i18n_rails_js/releases/tag/v1.0.0) - 2015-02-24 -* Transfer from github.com/nubis/gettext_i18n_rails_js (@tboerger) -* Added TravisCI, Rubocop and Coveralls (@tboerger) -* Updated structure to my opinionated gem style (@tboerger) -* Changed default handlebars function to ```__``` (@tboerger) -* Added extended ```gettext_i18n_rails_js.yml``` (@tboerger) +* Transfer from github.com/nubis/gettext_i18n_rails_js (@tboerger) +* Added TravisCI, Rubocop and Coveralls (@tboerger) +* Updated structure to my opinionated gem style (@tboerger) +* Changed default handlebars function to ```__``` (@tboerger) +* Added extended ```gettext_i18n_rails_js.yml``` (@tboerger) diff --git a/Gemfile b/Gemfile index 06ae5c7..da1bff1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/README.md b/README.md index 732a8f3..a04b971 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ client side javascript. ## Versions For a list of the tested and supported Ruby and Rails versions please take a -look at the [wokflow](https://github.com/webhippie/gettext_i18n_rails_js/blob/master/.github/workflows/testing.yml). +look at the [wokflow][workflow]. ## Installation @@ -25,15 +25,14 @@ gem "gettext_i18n_rails_js", "~> 1.2" ## Versioning -This library aims to adhere to [Semantic Versioning 2.0.0][http://semver.org/]. -Violations of this scheme should be reported as bugs. Specifically, if a minor -or patch version is released that breaks backward compatibility, a new version -should be immediately released that restores compatibility. Breaking changes to -the public API will only be introduced with new major versions. +This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations +of this scheme should be reported as bugs. Specifically, if a minor or patch +version is released that breaks backward compatibility, a new version should be +immediately released that restores compatibility. Breaking changes to the public +API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this -gem using the [Pessimistic Version Constraint][http://guides.rubygems.org/patterns/#pessimistic-version-constraint] -with two digits of precision. +gem using the [Pessimistic Version Constraint][pvc] with two digits of precision. For example: @@ -105,8 +104,8 @@ end ## Todo -* More deep testing against multiple Rails versions -* Extend the current test suite, especially handlebars +* More deep testing against multiple Rails versions +* Extend the current test suite, especially handlebars ## Contributing @@ -114,9 +113,9 @@ Fork -> Patch -> Spec -> Push -> Pull Request ## Authors -* [Thomas Boerger](https://github.com/tboerger) -* [Nubis](https://github.com/nubis) -* [Other contributors](https://github.com/webhippie/gettext_i18n_rails_js/graphs/contributors) +* [Thomas Boerger](https://github.com/tboerger) +* [Nubis](https://github.com/nubis) +* [Other contributors](https://github.com/webhippie/gettext_i18n_rails_js/graphs/contributors) ## License @@ -128,3 +127,7 @@ MIT Copyright (c) 2012-2015 Dropmysite.com Copyright (c) 2015 Webhippie ``` + +[workflow]: https://github.com/webhippie/gettext_i18n_rails_js/blob/master/.github/workflows/testing.yml +[semver]: http://semver.org +[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint diff --git a/Rakefile b/Rakefile index e3139e2..dd6f059 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/gettext_i18n_rails_js.gemspec b/gettext_i18n_rails_js.gemspec index 2fd4dd3..c4c92ce 100644 --- a/gettext_i18n_rails_js.gemspec +++ b/gettext_i18n_rails_js.gemspec @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -23,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -$LOAD_PATH.push File.expand_path("../lib", __FILE__) +$LOAD_PATH.push File.expand_path("lib", __dir__) require "gettext_i18n_rails_js/version" Gem::Specification.new do |s| @@ -62,11 +63,11 @@ Gem::Specification.new do |s| s.add_development_dependency "bundler" s.add_development_dependency "rake" - s.add_development_dependency "yard" s.add_development_dependency "rspec" + s.add_development_dependency "yard" - s.add_dependency "rails", ">= 3.2.0" s.add_dependency "gettext", ">= 3.0.2" s.add_dependency "gettext_i18n_rails", ">= 0.7.1" s.add_dependency "po_to_json", ">= 1.0.0" + s.add_dependency "rails", ">= 3.2.0" end diff --git a/lib/gettext_i18n_rails_js.rb b/lib/gettext_i18n_rails_js.rb index d07fd0f..fe3f273 100644 --- a/lib/gettext_i18n_rails_js.rb +++ b/lib/gettext_i18n_rails_js.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/lib/gettext_i18n_rails_js/config.rb b/lib/gettext_i18n_rails_js/config.rb index e35e730..7456ce2 100644 --- a/lib/gettext_i18n_rails_js/config.rb +++ b/lib/gettext_i18n_rails_js/config.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -25,10 +26,10 @@ module GettextI18nRailsJs class Config - attr_accessor :output_path - attr_accessor :handlebars_function - attr_accessor :javascript_function - attr_accessor :jed_options + attr_accessor :output_path, + :handlebars_function, + :javascript_function, + :jed_options def initialize(&block) @output_path = defaults[:output_path] diff --git a/lib/gettext_i18n_rails_js/engine.rb b/lib/gettext_i18n_rails_js/engine.rb index 1656f64..fdd8cbb 100644 --- a/lib/gettext_i18n_rails_js/engine.rb +++ b/lib/gettext_i18n_rails_js/engine.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/lib/gettext_i18n_rails_js/parser.rb b/lib/gettext_i18n_rails_js/parser.rb index bb92949..dcacefe 100644 --- a/lib/gettext_i18n_rails_js/parser.rb +++ b/lib/gettext_i18n_rails_js/parser.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/lib/gettext_i18n_rails_js/parser/base.rb b/lib/gettext_i18n_rails_js/parser/base.rb index b7df35e..b88ff6f 100644 --- a/lib/gettext_i18n_rails_js/parser/base.rb +++ b/lib/gettext_i18n_rails_js/parser/base.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -36,7 +37,7 @@ module Base # conflicts with other javascript libraries. You only need to define # the base function name to replace "_" and all the other variants # (s_, n_, N_) will be deduced automatically. - attr_accessor :gettext_function + attr_writer :gettext_function def gettext_function @gettext_function ||= "__" @@ -79,6 +80,7 @@ def parse(file, _msgids = []) end.join(separator_for(function)) next if key == "" + results_for(key, file, line) end end diff --git a/lib/gettext_i18n_rails_js/parser/handlebars.rb b/lib/gettext_i18n_rails_js/parser/handlebars.rb index 851616c..74a56b2 100644 --- a/lib/gettext_i18n_rails_js/parser/handlebars.rb +++ b/lib/gettext_i18n_rails_js/parser/handlebars.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/lib/gettext_i18n_rails_js/parser/javascript.rb b/lib/gettext_i18n_rails_js/parser/javascript.rb index 98cbaec..77a3724 100644 --- a/lib/gettext_i18n_rails_js/parser/javascript.rb +++ b/lib/gettext_i18n_rails_js/parser/javascript.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -121,7 +122,7 @@ def arg_regex '(?:[^'\\]|\\.)*?'| "(?:[^"\\]|\\.)*?"| `(?:[^`\\]|\\.)*?`| - [a-zA-Z0-9_\.()]*? + [a-zA-Z0-9_.()]*? ) \s* /xm diff --git a/lib/gettext_i18n_rails_js/task.rb b/lib/gettext_i18n_rails_js/task.rb index ee631b0..3b5cb44 100644 --- a/lib/gettext_i18n_rails_js/task.rb +++ b/lib/gettext_i18n_rails_js/task.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/lib/gettext_i18n_rails_js/version.rb b/lib/gettext_i18n_rails_js/version.rb index daa1127..5504dd4 100644 --- a/lib/gettext_i18n_rails_js/version.rb +++ b/lib/gettext_i18n_rails_js/version.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/lib/tasks/gettext_i18n_rails_js_tasks.rake b/lib/tasks/gettext_i18n_rails_js_tasks.rake index 235f248..d09883e 100644 --- a/lib/tasks/gettext_i18n_rails_js_tasks.rake +++ b/lib/tasks/gettext_i18n_rails_js_tasks.rake @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/spec/gettext_i18n_rails_js/parser/handlebars_spec.rb b/spec/gettext_i18n_rails_js/parser/handlebars_spec.rb index 29df3f0..ff4b14a 100644 --- a/spec/gettext_i18n_rails_js/parser/handlebars_spec.rb +++ b/spec/gettext_i18n_rails_js/parser/handlebars_spec.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -150,6 +151,7 @@ # end # end + # rubocop:disable Style/TrailingCommaInArrayLiteral it "finds interpolated multi-line messages" do content = <<-EOF
{{{__ 'Hello, my name is John Doe @@ -166,6 +168,7 @@ ) end end + # rubocop:enable Style/TrailingCommaInArrayLiteral # with_file content do |path| # expect(parser.parse(path, [])).to( @@ -260,6 +263,7 @@ end end + # rubocop:disable Style/FormatStringToken it "does not parse options" do content = <<-EOF
@@ -277,6 +281,7 @@ ) end end + # rubocop:enable Style/FormatStringToken # it "does not parse internal functions" do # content = <<-EOF @@ -295,8 +300,8 @@ describe "parses handlebars files" do let(:example) do File.expand_path( - "../../../fixtures/example.handlebars", - __FILE__ + "../../fixtures/example.handlebars", + __dir__ ) end diff --git a/spec/gettext_i18n_rails_js/parser/javascript_spec.rb b/spec/gettext_i18n_rails_js/parser/javascript_spec.rb index d0d6643..d85a62c 100644 --- a/spec/gettext_i18n_rails_js/parser/javascript_spec.rb +++ b/spec/gettext_i18n_rails_js/parser/javascript_spec.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -294,8 +295,8 @@ describe "parses vue files" do let(:example) do File.expand_path( - "../../../fixtures/example.vue", - __FILE__ + "../../fixtures/example.vue", + __dir__ ) end @@ -339,8 +340,8 @@ describe "parses javascript files" do let(:example) do File.expand_path( - "../../../fixtures/example.js", - __FILE__ + "../../fixtures/example.js", + __dir__ ) end @@ -389,8 +390,8 @@ describe "parses coffee files" do let(:example) do File.expand_path( - "../../../fixtures/example.coffee", - __FILE__ + "../../fixtures/example.coffee", + __dir__ ) end diff --git a/spec/gettext_i18n_rails_js_spec.rb b/spec/gettext_i18n_rails_js_spec.rb index cb363e8..df52852 100644 --- a/spec/gettext_i18n_rails_js_spec.rb +++ b/spec/gettext_i18n_rails_js_spec.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f7ea972..d2b5fe0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie @@ -27,7 +28,7 @@ begin require "codacy-coverage" Codacy::Reporter.start - rescue + rescue StandardError puts "Failed to load codacy-coverage gem" end end @@ -35,7 +36,7 @@ require "gettext_i18n_rails_js" require "rspec" -Dir[File.expand_path("../support/**/*.rb", __FILE__)].each do |file| +Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each do |file| require file end diff --git a/spec/support/with_file.rb b/spec/support/with_file.rb index 120cbe6..e66b422 100644 --- a/spec/support/with_file.rb +++ b/spec/support/with_file.rb @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# frozen_string_literal: true + # # Copyright (c) 2012-2015 Dropmysite.com # Copyright (c) 2015 Webhippie From ec16ab16c59f72c6d87d5046f13a04ece27b4b6c Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 01:01:59 +0100 Subject: [PATCH 11/12] ci: fix runs-on for testing workflow --- .github/workflows/{testing.yaml => testing.yml} | 2 ++ .rubocop.yml | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) rename .github/workflows/{testing.yaml => testing.yml} (97%) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yml similarity index 97% rename from .github/workflows/testing.yaml rename to .github/workflows/testing.yml index f45e54e..1475339 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yml @@ -9,6 +9,8 @@ name: testing jobs: lint: + runs-on: ubuntu-20.04 + steps: - name: Checkout source uses: actions/checkout@v2 diff --git a/.rubocop.yml b/.rubocop.yml index dd965dc..0c6f7d4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -52,10 +52,12 @@ Metrics/PerceivedComplexity: Max: 10 Metrics/BlockLength: + Max: 35 + Exclude: + - "**/*_spec.rb" + +Metrics/LineLength: Exclude: - - "gettext_i18n_rails_js.gemspec" - "**/*_spec.rb" - IgnoredMethods: - - namespace ... From a25fdaceb0101e8ce8f4efbb33c27cb1342cd2be Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 9 Dec 2021 01:13:13 +0100 Subject: [PATCH 12/12] ci: rename linting step to rubocop and depend on it --- .github/workflows/testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1475339..548fcf4 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -8,7 +8,7 @@ name: testing - master jobs: - lint: + rubocop: runs-on: ubuntu-20.04 steps: @@ -27,6 +27,7 @@ jobs: spec: runs-on: ubuntu-20.04 + needs: rubocop strategy: fail-fast: false