moirai 0.4.5 → 0.4.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 775bc4dc3ad8a1021e5f9fc135e911f15347a169763a37785df5f88c79c7f2ec
4
- data.tar.gz: b06e0bb4358f53307ff4be4455edce37c2438161670adfb92169b071efa805cf
3
+ metadata.gz: bcf7d211078453364a7a3ca5204323c965ea6e09e5b205fba26ea9bf9ef3d207
4
+ data.tar.gz: 774cb76d82a08a3eb8871aceb8870c0082c7d6d14c1a17bcc95ca799e043c3b7
5
5
  SHA512:
6
- metadata.gz: 5399d555d3e9c7cd53e9388a366d8653b4fbec5289cc1ee9fda529150a2d09269e3af8945eae6fb8327169263bfe8fe7bdf8df8ff914f3fb0899a12835e0e240
7
- data.tar.gz: 4040556f71c127529bb4b30f6342d8cdf13add2d6b2cc9f98eb704a46ead8e3490243c0aca8c1dc1756bd3445643d076c6244b5b32ef16c0554445d015feb7e2
6
+ metadata.gz: 7135800ff08e27916dcb69e95c63744e95d0c46e6c71e0bb6a36b1c22b2677a0dc8acef5f9579b8d795316ce1200d392306b21e67ab0d3ec028875fddf7f9f2d
7
+ data.tar.gz: 07ad0bf102451aeaace50563cbf8e83f57dd6c202903ad0fb71b3f64d0b745754a330f61d7fa08dcac49cf82406b56b087bc26f24747dbf418f29f0b3d8a0a0c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## Unreleased
2
+
3
+ ## 0.4.6
4
+
5
+ * Allows to access `current_user` and other controller available methods in the `enable_inline_editing` function. ([@coorasse][])
6
+ * Improved project setup. ([@simon-isler][])
7
+ * Various bug fixes
8
+
1
9
  ## 0.4.5
2
10
 
3
11
  * Fixes issue when inline editing is disabled. ([@nicogaldamez][])
@@ -68,3 +76,5 @@ move in here the conditions you had previously defined in the helper.
68
76
  [@CuddlyBunion341]: https://github.com/CuddlyBunion341
69
77
 
70
78
  [@nicogaldamez]: https://github.com/nicogaldamez
79
+
80
+ [@simon-isler]: https://github.com/simon-isler
data/README.md CHANGED
@@ -43,11 +43,12 @@ bin/rails db:migrate
43
43
 
44
44
  ### Mount path
45
45
 
46
- By default, Moirai is mounted under `/moirai`. You can change it by specifying the `root_path` option in `config/initializers/moirai.rb`:
46
+ By default, Moirai is mounted under `/moirai`. You can change it by specifying the `root_path` option in
47
+ `config/initializers/moirai.rb`:
47
48
 
48
49
  ```ruby
49
50
  # config/initializers/moirai.rb
50
- config.root_path = '/my_translations'
51
+ config.root_path = "/my_translations"
51
52
  ```
52
53
 
53
54
  ### How to change translations
@@ -62,7 +63,7 @@ on the application.
62
63
  By default, inline editing is disabled. To enable it, specify the following in `application.rb`:
63
64
 
64
65
  ```ruby
65
- config.moirai.enable_inline_editing = ->(params:) { params[:moirai] == 'true' }
66
+ config.moirai.enable_inline_editing = ->(params:) { params[:moirai] == "true" }
66
67
  ```
67
68
 
68
69
  If you set `moirai=true` query parameter in the URL, inline editing will appear in your page.
@@ -70,7 +71,7 @@ If you set `moirai=true` query parameter in the URL, inline editing will appear
70
71
  You probably want to only allow specific users to perform inline editing, this is an example of how you can do it:
71
72
 
72
73
  ```ruby
73
- config.moirai.enable_inline_editing = ->(params:) { (params[:moirai] == 'true') && current_user&.admin? }
74
+ config.moirai.enable_inline_editing = ->(params:) { (params[:moirai] == "true") && current_user&.admin? }
74
75
  ```
75
76
 
76
77
  You also need to have the moirai_translations_controller.js Stimulus Controller initialized. Read below how to:
@@ -103,7 +104,7 @@ You will also need to create a **Personal Access Token** on GitHub, and configur
103
104
  First, add Octokit to your project’s Gemfile:
104
105
 
105
106
  ```
106
- gem 'octokit'
107
+ gem "octokit"
107
108
  ```
108
109
 
109
110
  Then run `bundle install`.
@@ -169,7 +170,7 @@ See the following example:
169
170
 
170
171
  ```ruby
171
172
  authenticated :user, lambda { |u| u.role == "admin" } do
172
- mount Moirai::Engine => '/moirai', as: 'moirai'
173
+ mount Moirai::Engine => "/moirai", as: "moirai"
173
174
  end
174
175
  ```
175
176
 
@@ -181,19 +182,16 @@ end
181
182
  cd moirai
182
183
  ```
183
184
 
184
- 2. Run the setup script to install dependencies:
185
+ 2. Run the setup script to install dependencies and prepare the env variables:
185
186
  ```bash
186
187
  bin/setup
187
188
  ```
188
189
 
189
- 3. Copy the example environment variables file to create your own `.env` file:
190
- ```bash
191
- cp .env.example .env
192
- ```
190
+ 3. Set your environment variables using the newly created `.env` file.
193
191
 
194
- 4. Set your environment variables using the newly created `.env` file.
195
-
196
- You will need a repository to test against and a token. Generate a new Fine-GRained Personal access token and give the
192
+ You will need a repository to test against and a token. The repository is just a dummy repo. It does not need anything
193
+ special.
194
+ Generate a new Fine-Grained Personal access token and give the
197
195
  necessary permissions to your repository.
198
196
  See the image below as an example:
199
197
 
@@ -204,6 +202,10 @@ See the image below as an example:
204
202
  bin/check
205
203
  ```
206
204
 
205
+ > ⚠️ **Note:** The first time you run the tests, one test will fail because the Italian translation file is missing by default in the dummy app.
206
+ > But don't worry, a pull request should now be created on your repository with the missing translations.
207
+ > After merging the pull request, all the tests should pass.
208
+
207
209
  6. To view the engine in a dummy app:
208
210
  ```bash
209
211
  bin/rails s
@@ -216,6 +218,7 @@ See the image below as an example:
216
218
  * Support for count variants
217
219
  * Better inline editing tool
218
220
  * Support for fallbacks: it should detect when a fallback string is in use and prevent attempts to override its value.
221
+ * Support inline editing when translation is used as a value of an attribute
219
222
 
220
223
  ## License
221
224
 
data/lib/moirai/engine.rb CHANGED
@@ -12,7 +12,8 @@ module Moirai
12
12
 
13
13
  def self.on_sqlite?
14
14
  defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) &&
15
- ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
15
+ ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) &&
16
+ ActiveRecord::Base.connection.table_exists?("moirai_translations")
16
17
  end
17
18
 
18
19
  def self.on_postgres?
@@ -27,7 +27,7 @@ module ActionView::Helpers::TranslationHelper # rubocop:disable Lint/ConstantDef
27
27
  def moirai_edit_enabled?
28
28
  return false unless Moirai.enable_inline_editing.present?
29
29
 
30
- Moirai.enable_inline_editing.call(params: defined?(params) ? (params || {}) : {})
30
+ instance_exec(params: defined?(params) ? (params || {}) : {}, &Moirai.enable_inline_editing)
31
31
  end
32
32
 
33
33
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moirai
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moirai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2025-01-30 00:00:00.000000000 Z
13
+ date: 2025-08-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -37,28 +37,17 @@ executables: []
37
37
  extensions: []
38
38
  extra_rdoc_files: []
39
39
  files:
40
- - ".github/CODEOWNERS"
41
- - ".gitignore"
42
- - ".ruby-version"
43
- - ".semaphore/main-deploy.yml"
44
- - ".semaphore/semaphore.yml"
45
- - Appraisals
46
40
  - CHANGELOG.md
47
- - Gemfile
48
41
  - README.md
49
- - Rakefile
50
42
  - app/assets/config/moirai_manifest.js
51
- - app/assets/images/moirai/.keep
52
43
  - app/assets/javascripts/moirai_translation_controller.js
53
44
  - app/assets/stylesheets/moirai/application.css
54
45
  - app/assets/stylesheets/translation_files.css
55
- - app/controllers/concerns/.keep
56
46
  - app/controllers/moirai/application_controller.rb
57
47
  - app/controllers/moirai/translation_files_controller.rb
58
48
  - app/controllers/moirai/translations_controller.rb
59
49
  - app/helpers/moirai/application_helper.rb
60
50
  - app/jobs/moirai/application_job.rb
61
- - app/models/concerns/.keep
62
51
  - app/models/moirai/application_record.rb
63
52
  - app/models/moirai/change.rb
64
53
  - app/models/moirai/key_finder.rb
@@ -72,11 +61,6 @@ files:
72
61
  - app/views/moirai/translation_files/index.html.erb
73
62
  - app/views/moirai/translation_files/show.html.erb
74
63
  - app/views/moirai/translations/index.html.erb
75
- - bin/check
76
- - bin/console
77
- - bin/fastcheck
78
- - bin/rails
79
- - bin/setup
80
64
  - config/routes.rb
81
65
  - lib/generators/moirai/install_generator.rb
82
66
  - lib/generators/moirai/migration_generator.rb
@@ -91,7 +75,6 @@ files:
91
75
  - lib/moirai/pull_request_creator.rb
92
76
  - lib/moirai/translation_helper.rb
93
77
  - lib/moirai/version.rb
94
- - moirai.gemspec
95
78
  homepage: https://github.com/renuo/moirai
96
79
  licenses:
97
80
  - MIT
@@ -116,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
99
  - !ruby/object:Gem::Version
117
100
  version: '0'
118
101
  requirements: []
119
- rubygems_version: 3.3.27
102
+ rubygems_version: 3.4.6
120
103
  signing_key:
121
104
  specification_version: 4
122
105
  summary: Manage translation strings in real time
data/.github/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- * @renuo/moirai
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /log/*.log
7
- /pkg/
8
- /tmp/
9
- /test/dummy/db/*.sqlite3
10
- /test/dummy/db/*.sqlite3-*
11
- /test/dummy/log/*.log
12
- /test/dummy/storage/
13
- /test/dummy/tmp/
14
-
15
- .env
16
- /Gemfile.lock
17
- *.gem
18
- .idea/
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.2.1
@@ -1,18 +0,0 @@
1
- version: v1.0
2
- name: main-deploy
3
- agent:
4
- machine:
5
- type: e1-standard-2
6
- os_image: ubuntu2004
7
-
8
- blocks:
9
- - name: main-deploy
10
- task:
11
- secrets:
12
- - name: rubygems-deploy
13
- jobs:
14
- - name: main-deploy
15
- commands:
16
- - checkout --use-cache
17
- - gem build moirai
18
- - gem push moirai-*.gem
@@ -1,82 +0,0 @@
1
- version: "v1.0"
2
- name: moirai
3
- agent:
4
- machine:
5
- type: e1-standard-2
6
- os_image: ubuntu2004
7
- auto_cancel:
8
- running:
9
- when: "true"
10
-
11
- blocks:
12
- - name: linter
13
- execution_time_limit:
14
- minutes: 10
15
- dependencies: []
16
- task:
17
- secrets:
18
- - name: moirai
19
- prologue:
20
- commands:
21
- - checkout --use-cache
22
- - cache restore
23
- - bundle config set path 'vendor/bundle'
24
- - bundle install -j 4
25
- - cache store
26
- jobs:
27
- - name: linter
28
- commands:
29
- - bundle exec standardrb
30
- - name: tests sqlite
31
- execution_time_limit:
32
- minutes: 10
33
- dependencies: []
34
- task:
35
- secrets:
36
- - name: moirai
37
- prologue:
38
- commands:
39
- - checkout --use-cache
40
- - cache restore
41
- - bundle config set path 'vendor/bundle'
42
- - bundle install -j 4
43
- - cache store
44
- jobs:
45
- - name: tests sqlite
46
- env_vars:
47
- - name: TARGET_DB
48
- value: sqlite
49
- - name: RAILS_ENV
50
- value: test
51
- commands:
52
- - bin/rails db:create db:schema:load
53
- - bin/check
54
- - name: tests postgres
55
- execution_time_limit:
56
- minutes: 10
57
- dependencies:
58
- - 'tests sqlite'
59
- task:
60
- secrets:
61
- - name: moirai
62
- prologue:
63
- commands:
64
- - checkout --use-cache
65
- - cache restore
66
- - bundle config set path 'vendor/bundle'
67
- - bundle install -j 4
68
- - cache store
69
- jobs:
70
- - name: tests postgres
71
- env_vars:
72
- - name: TARGET_DB
73
- value: postgres
74
- - name: RAILS_ENV
75
- value: test
76
- commands:
77
- - sem-service start postgres 14 --username=semaphore
78
- - bin/rails db:create db:schema:load
79
- - bin/check
80
- promotions:
81
- - name: main
82
- pipeline_file: main-deploy.yml
data/Appraisals DELETED
@@ -1,15 +0,0 @@
1
- appraise "rails_7_2" do
2
- gem "rails", "~> 7.2"
3
- end
4
-
5
- appraise "rails_7_1" do
6
- gem "rails", "~> 7.1"
7
- end
8
-
9
- appraise "rails_7_0" do
10
- gem "rails", "~> 7.0"
11
- end
12
-
13
- appraise "rails_6_1" do
14
- gem "rails", "~> 6.1"
15
- end
data/Gemfile DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec
6
-
7
- gem "rails", "~> 7.2.0"
8
- gem "octokit", ">= 4.0"
9
- gem "importmap-rails"
10
- gem "stimulus-rails"
11
-
12
- group :development, :test do
13
- gem "puma"
14
- gem "sqlite3"
15
- gem "pg"
16
- gem "rake"
17
- gem "dotenv"
18
- gem "minitest"
19
- gem "standard"
20
- gem "appraisal"
21
- gem "better_errors"
22
- gem "binding_of_caller"
23
- gem "sprockets-rails"
24
- end
25
-
26
- group :test do
27
- gem "capybara"
28
- gem "selenium-webdriver"
29
- end
data/Rakefile DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- require "bundler/gem_tasks"
5
- require "rake/testtask"
6
-
7
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
8
- load "rails/tasks/engine.rake"
9
- load "rails/tasks/statistics.rake"
10
-
11
- Rake::TestTask.new(:test) do |t|
12
- t.libs << "test"
13
- t.libs << "lib"
14
- t.test_files = FileList["test/**/test_*.rb"]
15
- end
16
-
17
- task default: :test
File without changes
File without changes
File without changes
data/bin/check DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- bundle exec rails test
6
- bundle exec rails test:system
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'moirai'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/fastcheck DELETED
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- if ! bundle exec standardrb
6
- then
7
- echo '\n Standard detected issues! Attempting to fix...'
8
-
9
- if ! bundle exec standardrb --fix
10
- then
11
- echo '\n Tried to auto correct the issues, but some must be reviewed manually. Commit aborted.'
12
- exit 1
13
- fi
14
-
15
- echo '\n Auto-corrected issues, but you should review changes before committing.'
16
- exit 1
17
- fi
data/bin/rails DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # This command will automatically be run when you run "rails" with Rails gems
5
- # installed from the root of your application.
6
-
7
- ENGINE_ROOT = File.expand_path('..', __dir__)
8
- ENGINE_PATH = File.expand_path('../lib/moirai/engine', __dir__)
9
- APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
10
-
11
- # Set up gems listed in the Gemfile.
12
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
13
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
14
-
15
- require 'rails/all'
16
- require 'rails/engine/commands'
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/moirai.gemspec DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/moirai/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "moirai"
7
- spec.version = Moirai::VERSION
8
- spec.authors = ["Alessandro Rodi", "Oliver Anthony", "Daniel Bengl"]
9
- spec.email = %w[alessandro.rodi@renuo.ch oliver.anthony@renuo.ch daniel.bengl@renuo.ch]
10
-
11
- spec.summary = "Manage translation strings in real time"
12
- spec.description = 'This gem allows you to manage translation strings in real time,
13
- viewing the live changes in the browser, with the changes then converted to a PR opened on the repository.'
14
- spec.homepage = "https://github.com/renuo/moirai"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/renuo/moirai"
18
- spec.metadata["changelog_uri"] = "https://github.com/renuo/moirai/CHANGELOG.md"
19
- spec.metadata["steep_types"] = "sig"
20
-
21
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|docs)/}) || f.end_with?(".gem") }
23
- end
24
- spec.bindir = "exe"
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
- spec.require_paths = ["lib"]
27
-
28
- spec.required_ruby_version = ">= 2.7.0"
29
- spec.add_dependency "rails", ">= 6.1"
30
-
31
- spec.license = "MIT"
32
- spec.metadata["rubygems_mfa_required"] = "true"
33
- end