rateaux 1.6.1 → 2.1.0
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 +5 -5
- data/README.md +69 -16
- data/Rakefile +26 -15
- data/lib/rateaux/file_task.rb +32 -35
- data/lib/rateaux/namespaced.rb +36 -40
- data/lib/rateaux/version.rb +3 -1
- data/lib/rateaux.rb +4 -1
- data/lib/tasks/rateaux_add_frozen_string_literal_headers.rake +27 -0
- data/lib/tasks/rateaux_cache_clear.rake +9 -7
- data/lib/tasks/rateaux_copy_non_digested_assets.rake +5 -7
- data/lib/tasks/rateaux_db.rake +3 -3
- data/lib/tasks/rateaux_db_migrate.rake +24 -0
- data/lib/tasks/rateaux_db_schema_view.rake +20 -16
- data/lib/tasks/rateaux_git_checkout.rake +13 -11
- data/lib/tasks/rateaux_i18n_word_count.rake +48 -0
- data/lib/tasks/rateaux_notes_mine.rake +4 -4
- data/lib/tasks/rateaux_sidekiq_flush.rake +23 -0
- metadata +19 -47
- data/lib/tasks/rateaux_encoding_headers.rake +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a99a590fe7f149a351599a6b4b37c49b51c7de1b10b95900a3410c24bce20ca0
|
|
4
|
+
data.tar.gz: d09b6b5a682589c29fc8ddfaf001cd420f6ebbc75e3c25ed48405a5fcc0a7a45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fb58245762852ea2e90b6d0bfe236be451e43c0bfd0d5c906d9d9309e1234f34a14f7cf7ab7b7aed8b5fa03d2307179581f1b7ab2ce6ec261b5638a3356dd6e
|
|
7
|
+
data.tar.gz: 6005f2d8433ef0bffb4e0f35b8b38420a285560bc4e0a86b735e5454f50813c0cbc8b20413a74e6711a26197577a01672c4dec5a95a955f60116f37cef0acbe2
|
data/README.md
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
# Rateaux
|
|
2
2
|
|
|
3
|
-
This is a collection of useful Rake tasks for Rails.
|
|
3
|
+
This is a collection of useful Rake tasks for Ruby on Rails applications.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
_[Hay Rake](https://www.flickr.com/photos/49708076@N05/23047850374/) photo by Larry Lamb_
|
|
4
8
|
|
|
5
9
|
## Install
|
|
6
10
|
|
|
7
|
-
Add
|
|
11
|
+
Add these lines to your app's Gemfile:
|
|
8
12
|
|
|
9
13
|
```ruby
|
|
10
14
|
# Rake tasks for Rails
|
|
11
15
|
gem "rateaux"
|
|
12
16
|
```
|
|
13
17
|
|
|
14
|
-
Then
|
|
18
|
+
Then call `bundle install`.
|
|
15
19
|
|
|
16
|
-
##
|
|
20
|
+
## Tasks
|
|
17
21
|
|
|
18
|
-
### Truncate
|
|
22
|
+
### DB Truncate
|
|
19
23
|
|
|
20
24
|
Delete all data from the current database.
|
|
21
25
|
|
|
@@ -23,20 +27,38 @@ Delete all data from the current database.
|
|
|
23
27
|
$ rake db:truncate
|
|
24
28
|
```
|
|
25
29
|
|
|
26
|
-
### Drop tables
|
|
30
|
+
### DB Drop tables
|
|
27
31
|
|
|
28
|
-
Delete all data and tables from the current database. This is similar to
|
|
32
|
+
Delete all data and tables from the current database. This is similar to
|
|
33
|
+
`db:drop` but it does not drop the database itself.
|
|
29
34
|
|
|
30
35
|
```sh
|
|
31
36
|
$ rake db:drop_tables
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
###
|
|
39
|
+
### DB Migrate Delete Orphaned
|
|
40
|
+
|
|
41
|
+
When your migration errors with "No migration with version number" you can call
|
|
42
|
+
this to delete all migrations that don’t have associated files anymore.
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
$ rake db:migrate:delete_orphaned
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### DB schema view
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
View the database structure.
|
|
37
51
|
|
|
38
52
|
```sh
|
|
39
|
-
$ rake
|
|
53
|
+
$ rake db:schema:view
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### I18n word count
|
|
57
|
+
|
|
58
|
+
Show the number of translated words in every available locale.
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
$ rake i18n:word_count
|
|
40
62
|
```
|
|
41
63
|
|
|
42
64
|
### Checkout
|
|
@@ -58,24 +80,55 @@ This will:
|
|
|
58
80
|
|
|
59
81
|
### Cache clear
|
|
60
82
|
|
|
61
|
-
Empty the cache store.
|
|
83
|
+
Empty the Rails cache store.
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
$ rake cache:clear
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Sidekiq flush
|
|
90
|
+
|
|
91
|
+
Empty Sidekiq’s queues.
|
|
62
92
|
|
|
63
93
|
```sh
|
|
64
|
-
$ rake
|
|
94
|
+
$ rake sidekiq:flush
|
|
65
95
|
```
|
|
66
96
|
|
|
67
97
|
### Assets Copy Non Digested
|
|
68
98
|
|
|
69
|
-
Copy assets files with a digest (for example `application-d45e…565.css`)
|
|
99
|
+
Copy assets files with a digest (for example `application-d45e…565.css`)
|
|
100
|
+
to their non-digested form (for example `application.css`).
|
|
70
101
|
|
|
71
102
|
```sh
|
|
72
103
|
$ rake assets:copy_non_digested
|
|
73
104
|
```
|
|
74
105
|
|
|
75
|
-
###
|
|
106
|
+
### Frozen string literal
|
|
76
107
|
|
|
77
|
-
|
|
108
|
+
Add the `# frozen_string_literal: true` header to all Ruby files in the project.
|
|
78
109
|
|
|
79
110
|
```sh
|
|
80
|
-
$ rake
|
|
111
|
+
$ rake add_frozen_string_literal_headers
|
|
81
112
|
```
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Release
|
|
116
|
+
|
|
117
|
+
To release a new version, update `CHANGELOG.md`, update the version in
|
|
118
|
+
`lib/rateaux/version.rb`.
|
|
119
|
+
|
|
120
|
+
Then:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
git add CHANGELOG.md lib/rateaux/version.rb
|
|
124
|
+
git commit -m v`ruby -r./lib/rateaux/version <<< 'puts Rateaux::VERSION'`
|
|
125
|
+
bin/rake release
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
The gem is available as open source under the terms of the [MIT License].
|
|
131
|
+
|
|
132
|
+
## The name
|
|
133
|
+
|
|
134
|
+
In French _rateaux_ means _rakes_.
|
data/Rakefile
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env rake
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Bundler
|
|
2
5
|
|
|
3
|
-
# bundler
|
|
4
6
|
begin
|
|
5
|
-
require
|
|
7
|
+
require "bundler/setup"
|
|
6
8
|
rescue LoadError
|
|
7
|
-
puts
|
|
9
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
Bundler::GemHelper.install_tasks
|
|
11
13
|
|
|
12
|
-
#
|
|
14
|
+
# RDoc
|
|
15
|
+
|
|
13
16
|
begin
|
|
14
|
-
require
|
|
17
|
+
require "rdoc/task"
|
|
15
18
|
rescue LoadError
|
|
16
|
-
require
|
|
17
|
-
require
|
|
19
|
+
require "rdoc/rdoc"
|
|
20
|
+
require "rake/rdoctask"
|
|
18
21
|
RDoc::Task = Rake::RDocTask
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
RDoc::Task.new(:rdoc) do |rdoc|
|
|
22
|
-
rdoc.rdoc_dir =
|
|
23
|
-
rdoc.title
|
|
24
|
-
rdoc.options <<
|
|
25
|
-
rdoc.rdoc_files.include(
|
|
26
|
-
rdoc.rdoc_files.include(
|
|
25
|
+
rdoc.rdoc_dir = "rdoc"
|
|
26
|
+
rdoc.title = "Rateaux"
|
|
27
|
+
rdoc.options << "--line-numbers"
|
|
28
|
+
rdoc.rdoc_files.include("README.rdoc")
|
|
29
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
|
27
30
|
end
|
|
28
31
|
|
|
29
|
-
#
|
|
30
|
-
|
|
32
|
+
# RSpec
|
|
33
|
+
|
|
34
|
+
require "rspec/core/rake_task"
|
|
31
35
|
RSpec::Core::RakeTask.new(:spec)
|
|
32
|
-
|
|
36
|
+
|
|
37
|
+
# RuboCop
|
|
38
|
+
|
|
39
|
+
require "rubocop/rake_task"
|
|
40
|
+
|
|
41
|
+
RuboCop::RakeTask.new
|
|
42
|
+
|
|
43
|
+
task default: %i[spec rubocop]
|
data/lib/rateaux/file_task.rb
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# File Task
|
|
4
|
-
#
|
|
5
|
-
# Adds a task and a file task. The file depends on the task that it creates.
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# For example:
|
|
9
|
-
#
|
|
10
|
-
# require "rateaux/file_task"
|
|
11
|
-
# include Rateaux::FileTask
|
|
12
|
-
#
|
|
13
|
-
# file_task "foo.txt", create: :environment do
|
|
14
|
-
# touch "foo.txt"
|
|
15
|
-
# end
|
|
16
|
-
#
|
|
17
|
-
# You can then:
|
|
18
|
-
#
|
|
19
|
-
# $ rake foo.txt # Will create the file only if it does not exist
|
|
20
|
-
# $ rake create # Will create the file all the time
|
|
21
|
-
#
|
|
22
|
-
# Your tasks can now depend on the file beeing present or create them :
|
|
23
|
-
#
|
|
24
|
-
# task send: "foo.txt"
|
|
25
|
-
#
|
|
26
|
-
# With file_task you don't have to add this block to the file task:
|
|
27
|
-
#
|
|
28
|
-
# file "foo.txt" do
|
|
29
|
-
# Rake::Task["create"]
|
|
30
|
-
# end
|
|
31
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
32
3
|
module Rateaux
|
|
4
|
+
# File Task
|
|
5
|
+
#
|
|
6
|
+
# Adds a task and a file task. The file depends on the task that it creates.
|
|
7
|
+
#
|
|
8
|
+
# For example:
|
|
9
|
+
#
|
|
10
|
+
# require "rateaux/file_task"
|
|
11
|
+
# include Rateaux::FileTask
|
|
12
|
+
#
|
|
13
|
+
# file_task "foo.txt", create: :environment do
|
|
14
|
+
# touch "foo.txt"
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
# You can then:
|
|
18
|
+
#
|
|
19
|
+
# $ rake foo.txt # Will create the file only if it does not exist
|
|
20
|
+
# $ rake create # Will create the file all the time
|
|
21
|
+
#
|
|
22
|
+
# Your tasks can now depend on the file beeing present or create them :
|
|
23
|
+
#
|
|
24
|
+
# task send: "foo.txt"
|
|
25
|
+
#
|
|
26
|
+
# With file_task you don't have to add this block to the file task:
|
|
27
|
+
#
|
|
28
|
+
# file "foo.txt" do
|
|
29
|
+
# Rake::Task["create"]
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
33
32
|
module FileTask
|
|
34
|
-
def file_task(path, definition)
|
|
35
|
-
t = task(definition)
|
|
36
|
-
yield
|
|
37
|
-
end
|
|
33
|
+
def file_task(path, definition, &)
|
|
34
|
+
t = task(definition, &)
|
|
38
35
|
|
|
39
36
|
file(path) do
|
|
40
37
|
Rake::Task[t.name].invoke
|
data/lib/rateaux/namespaced.rb
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# Namespaced
|
|
4
|
-
#
|
|
5
|
-
# Adds a namespace and a task with that namespace name.
|
|
6
|
-
#
|
|
7
|
-
# Choose the tasks you want to launch when using the namespace name
|
|
8
|
-
# by giving them as a second argument or by defning a "default" task.
|
|
9
|
-
#
|
|
10
|
-
# For example:
|
|
11
|
-
#
|
|
12
|
-
# require "rateaux/namespaced"
|
|
13
|
-
# include Rateaux::Namespaced
|
|
14
|
-
#
|
|
15
|
-
# desc "Export everything"
|
|
16
|
-
# namespaced :export do
|
|
17
|
-
# default: [:a, :b]
|
|
18
|
-
#
|
|
19
|
-
# …
|
|
20
|
-
# end
|
|
21
|
-
#
|
|
22
|
-
# Is the same as:
|
|
23
|
-
#
|
|
24
|
-
# require "rateaux/namespaced"
|
|
25
|
-
# include Rateaux::Namespaced
|
|
26
|
-
#
|
|
27
|
-
# desc "Export everything"
|
|
28
|
-
# namespaced :export, [:a, :b] do
|
|
29
|
-
# …
|
|
30
|
-
# end
|
|
31
|
-
#
|
|
32
|
-
# Both definitions add a task "export" that cals "export:a" and "export:b"
|
|
33
|
-
# without having to add:
|
|
34
|
-
#
|
|
35
|
-
# task export: ["export:a", "export:b"]
|
|
36
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
37
3
|
module Rateaux
|
|
4
|
+
# Adds a namespace and a task with that namespace name.
|
|
5
|
+
#
|
|
6
|
+
# Choose the tasks you want to launch when using the namespace name
|
|
7
|
+
# by giving them as a second argument or by defning a "default" task.
|
|
8
|
+
#
|
|
9
|
+
# For example:
|
|
10
|
+
#
|
|
11
|
+
# require "rateaux/namespaced"
|
|
12
|
+
# include Rateaux::Namespaced
|
|
13
|
+
#
|
|
14
|
+
# desc "Export everything"
|
|
15
|
+
# namespaced :export do
|
|
16
|
+
# task default: [:a, :b]
|
|
17
|
+
#
|
|
18
|
+
# ...
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# Is the same as:
|
|
22
|
+
#
|
|
23
|
+
# require "rateaux/namespaced"
|
|
24
|
+
# include Rateaux::Namespaced
|
|
25
|
+
#
|
|
26
|
+
# desc "Export everything"
|
|
27
|
+
# namespaced :export, [:a, :b] do
|
|
28
|
+
# ...
|
|
29
|
+
# end
|
|
30
|
+
#
|
|
31
|
+
# Both definitions add a task "export" that cals "export:a" and "export:b"
|
|
32
|
+
# without having to add:
|
|
33
|
+
#
|
|
34
|
+
# task export: ["export:a", "export:b"]
|
|
35
|
+
#
|
|
38
36
|
module Namespaced
|
|
39
|
-
def namespaced(name, defaults = :default)
|
|
37
|
+
def namespaced(name, defaults = :default, &)
|
|
40
38
|
case defaults
|
|
41
39
|
when Symbol, String
|
|
42
40
|
task name => "#{name}:#{defaults}"
|
|
@@ -46,9 +44,7 @@ module Rateaux
|
|
|
46
44
|
task name => defaults.to_a.map { |t| "#{name}:#{t}" }
|
|
47
45
|
end
|
|
48
46
|
|
|
49
|
-
namespace
|
|
50
|
-
yield
|
|
51
|
-
end
|
|
47
|
+
namespace(name, &)
|
|
52
48
|
end
|
|
53
49
|
end
|
|
54
50
|
end
|
data/lib/rateaux/version.rb
CHANGED
data/lib/rateaux.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Rateaux
|
|
4
|
+
# Tie to Rails
|
|
2
5
|
class Railtie < Rails::Railtie
|
|
3
6
|
rake_tasks do
|
|
4
|
-
Dir[File.join(File.dirname(__FILE__),
|
|
7
|
+
Dir[File.join(File.dirname(__FILE__), "tasks/*.rake")].each { |f| load f }
|
|
5
8
|
end
|
|
6
9
|
end
|
|
7
10
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Adds "frozen_string_literal: true" to the top of all Ruby files.
|
|
4
|
+
#
|
|
5
|
+
# $ rake add_frozen_string_literal_headers
|
|
6
|
+
|
|
7
|
+
desc "Adds the frozen_string_literal header to all Ruby files"
|
|
8
|
+
task add_frozen_string_literal_headers: :environment do
|
|
9
|
+
files = []
|
|
10
|
+
["*.rb", "*.rake"].each do |extension|
|
|
11
|
+
files.concat(Dir[File.join(Dir.getwd.split("\\"), "**", extension)])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
header = "# frozen_string_literal: true\n"
|
|
15
|
+
|
|
16
|
+
files.each do |file|
|
|
17
|
+
next if file.end_with?("db/schema.rb")
|
|
18
|
+
|
|
19
|
+
content = File.read(file)
|
|
20
|
+
next if content[0..header.length] == header
|
|
21
|
+
|
|
22
|
+
content = content.gsub(/^# (frozen_string_literal: true)\n/i, "")
|
|
23
|
+
content = "#{header}#{content}"
|
|
24
|
+
|
|
25
|
+
File.write(file, content)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# Empty Rails cache
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Empty Rails cache.
|
|
4
4
|
#
|
|
5
|
-
# $ rake
|
|
5
|
+
# $ rake cache:clear
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
namespace :cache do
|
|
8
|
+
desc "Empty Rails cache"
|
|
9
|
+
task clear: :environment do
|
|
10
|
+
Rails.cache.clear
|
|
11
|
+
end
|
|
10
12
|
end
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Copy all assets to their non-digested form.
|
|
4
4
|
#
|
|
5
5
|
# Via https://github.com/rails/sprockets-rails/issues/49#issuecomment-20535134
|
|
6
6
|
|
|
7
7
|
namespace :assets do
|
|
8
|
-
|
|
9
8
|
desc "Copy non digested assets"
|
|
10
9
|
task copy_non_digested: :environment do
|
|
11
|
-
assets = Dir.glob(File.join(Rails.root,
|
|
10
|
+
assets = Dir.glob(File.join(Rails.root, "public/assets/**/*"))
|
|
12
11
|
regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
|
|
13
12
|
assets.each do |file|
|
|
14
13
|
next if File.directory?(file) || file !~ regex
|
|
15
14
|
|
|
16
|
-
source = file.split(
|
|
17
|
-
source.push(source.pop.gsub(regex,
|
|
15
|
+
source = file.split("/")
|
|
16
|
+
source.push(source.pop.gsub(regex, "."))
|
|
18
17
|
|
|
19
18
|
non_digested = File.join(source)
|
|
20
19
|
FileUtils.cp(file, non_digested)
|
|
21
20
|
end
|
|
22
21
|
end
|
|
23
|
-
|
|
24
22
|
end
|
data/lib/tasks/rateaux_db.rake
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Truncate or delete all data from an SQL database.
|
|
4
4
|
#
|
|
5
5
|
# $ rake db:truncate
|
|
6
6
|
# $ rake db:drop_tables
|
|
7
7
|
|
|
8
|
-
require
|
|
8
|
+
require "database_cleaner"
|
|
9
9
|
|
|
10
10
|
namespace :db do
|
|
11
11
|
desc "Truncate all tables"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Delete orhphaned migrations.
|
|
4
|
+
#
|
|
5
|
+
# $ rake db:migrate:delete_orphaned
|
|
6
|
+
namespace :db do
|
|
7
|
+
namespace :migrate do
|
|
8
|
+
desc "Delete migrations that don’t have associated files anymore"
|
|
9
|
+
task delete_orphaned: :environment do
|
|
10
|
+
removed_file_versions =
|
|
11
|
+
ActiveRecord::Base
|
|
12
|
+
.connection_pool
|
|
13
|
+
.migration_context
|
|
14
|
+
.migrations_status
|
|
15
|
+
.filter_map { |_, version, name| version if name.include?("NO FILE") }
|
|
16
|
+
|
|
17
|
+
removed_file_versions.each do |version|
|
|
18
|
+
puts "Deleting orphaned version #{version}"
|
|
19
|
+
sql = "DELETE FROM schema_migrations WHERE version = '#{version}'"
|
|
20
|
+
ActiveRecord::Base.connection.execute(sql)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# View database schema.
|
|
4
4
|
#
|
|
5
5
|
# $ rake db:schema:view
|
|
6
|
-
require
|
|
6
|
+
require "terminal-table"
|
|
7
7
|
namespace :db do
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
namespace :schema do
|
|
9
|
+
desc "View database schema"
|
|
10
|
+
task view: :environment do
|
|
11
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
|
12
|
+
next if table == "schema_migrations"
|
|
13
|
+
|
|
14
|
+
rows = ActiveRecord::Base.connection.columns(table).map do |column|
|
|
15
|
+
[column.name, column.type]
|
|
16
|
+
end
|
|
17
|
+
table = Terminal::Table.new(
|
|
18
|
+
title: table,
|
|
19
|
+
headings: %w[Name Type],
|
|
20
|
+
rows: rows
|
|
21
|
+
)
|
|
22
|
+
puts table
|
|
23
|
+
end
|
|
21
24
|
end
|
|
25
|
+
end
|
|
22
26
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# Remove migrations then checkout a git branch
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Remove migrations then checkout a git branch.
|
|
4
4
|
#
|
|
5
5
|
# $ rake checkout new_branch_name
|
|
6
6
|
#
|
|
@@ -15,29 +15,31 @@
|
|
|
15
15
|
|
|
16
16
|
desc "Switch git branches and apply migrations"
|
|
17
17
|
task "checkout" do
|
|
18
|
-
|
|
19
18
|
# We can't checkout if we're dirty
|
|
20
19
|
unless `git diff --shortstat`.blank?
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
warn "error: Your local changes would be overwritten by checkout."
|
|
21
|
+
warn "Please, commit your changes or stash them before you can switch " \
|
|
22
|
+
"branches."
|
|
23
23
|
abort "Aborting"
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# Last argument trick
|
|
27
27
|
# Via http://itshouldbeuseful.wordpress.com/2011/11/07/passing-parameters-to-a-rake-task/
|
|
28
|
-
task ARGV.last do
|
|
28
|
+
task ARGV.last do
|
|
29
|
+
# DO nothing
|
|
30
|
+
end
|
|
29
31
|
branch_name = ARGV.last
|
|
30
32
|
|
|
31
33
|
# List migrations
|
|
32
34
|
changes = `git diff #{branch_name} --name-status`.lines
|
|
33
|
-
migrations = changes.map
|
|
34
|
-
match =
|
|
35
|
+
migrations = changes.map do |change|
|
|
36
|
+
match = %r{^A.*migrate/([0-9]+)}.match(change)
|
|
35
37
|
match ? match[1] : nil
|
|
36
|
-
|
|
38
|
+
end.compact
|
|
37
39
|
|
|
38
40
|
# Drop it like it's hot
|
|
39
41
|
migrations.sort.reverse.each do |migration|
|
|
40
|
-
# TODO we're already in rake, we should call these tasks directly
|
|
42
|
+
# TODO: we're already in rake, we should call these tasks directly
|
|
41
43
|
sh "bundle exec rake db:migrate:down VERSION=#{migration}"
|
|
42
44
|
end
|
|
43
45
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Show the number of translated words in every available locale.
|
|
4
|
+
#
|
|
5
|
+
# $ rake i18n:word_count
|
|
6
|
+
|
|
7
|
+
require "unicode/emoji"
|
|
8
|
+
|
|
9
|
+
class RateauxI18nWordCount
|
|
10
|
+
include ActionView::Helpers::SanitizeHelper
|
|
11
|
+
|
|
12
|
+
def words_for_locale(locale)
|
|
13
|
+
translations = I18n.t(".", locale: locale)
|
|
14
|
+
words = hash_string_values(translations).flat_map do |translation|
|
|
15
|
+
strip_tags(translation).split(/\s+/)
|
|
16
|
+
end
|
|
17
|
+
words.reject do |word|
|
|
18
|
+
word.blank? ||
|
|
19
|
+
word.size == 1 ||
|
|
20
|
+
word.start_with?("%") ||
|
|
21
|
+
word.match?(Unicode::Emoji::REGEX_VALID_INCLUDE_TEXT)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def hash_string_values(hash)
|
|
28
|
+
hash.inject([]) do |array, (_key, value)|
|
|
29
|
+
case value
|
|
30
|
+
when Hash then array + hash_string_values(value)
|
|
31
|
+
when String then array + [value]
|
|
32
|
+
else array
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
namespace :i18n do
|
|
39
|
+
desc "Show the number of translated words in every available locale"
|
|
40
|
+
task word_count: :environment do
|
|
41
|
+
counter = RateauxI18nWordCount.new
|
|
42
|
+
|
|
43
|
+
I18n.available_locales.each do |locale|
|
|
44
|
+
words = counter.words_for_locale(locale)
|
|
45
|
+
puts "#{locale}: #{words.count} (#{words.uniq.count} unique)"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
namespace :notes do
|
|
4
4
|
task :mine do
|
|
5
5
|
me = `whoami`.strip
|
|
6
|
-
p Rake::Task[
|
|
7
|
-
#Rake::Task[
|
|
8
|
-
Rake::Task[
|
|
6
|
+
p Rake::Task["notes:custom"].arg_names
|
|
7
|
+
# Rake::Task["notes:custom"].set_arg_names([:annotation])
|
|
8
|
+
Rake::Task["notes:custom"].invoke("TODO @#{me}")
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Empty all of Sidekiq's queues.
|
|
4
|
+
#
|
|
5
|
+
# $ rake sidekiq:flush
|
|
6
|
+
|
|
7
|
+
namespace :sidekiq do
|
|
8
|
+
desc "Empty Sidekiq queues"
|
|
9
|
+
task flush: :environment do
|
|
10
|
+
if Rails.env.production? && ENV["DISABLE_DATABASE_ENVIRONMENT_CHECK"] != "1"
|
|
11
|
+
raise "This task should not be run in production. Set " \
|
|
12
|
+
"DISABLE_DATABASE_ENVIRONMENT_CHECK=1 to override."
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Via https://stackoverflow.com/a/38672157/311657
|
|
16
|
+
require "sidekiq/api"
|
|
17
|
+
Sidekiq::RetrySet.new.clear
|
|
18
|
+
Sidekiq::ScheduledSet.new.clear
|
|
19
|
+
Sidekiq::DeadSet.new.clear
|
|
20
|
+
Sidekiq::Stats.new.reset
|
|
21
|
+
Sidekiq::Queue.all.map(&:clear)
|
|
22
|
+
end
|
|
23
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rateaux
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sunny Ripert
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-07-22 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: rails
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 3.2.20
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 3.2.20
|
|
27
12
|
- !ruby/object:Gem::Dependency
|
|
28
13
|
name: database_cleaner
|
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,41 +24,27 @@ dependencies:
|
|
|
39
24
|
- !ruby/object:Gem::Version
|
|
40
25
|
version: '0'
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
27
|
+
name: rails
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
44
29
|
requirements:
|
|
45
30
|
- - ">="
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
32
|
+
version: 3.2.20
|
|
48
33
|
type: :runtime
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
37
|
- - ">="
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: sqlite3
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
39
|
+
version: 3.2.20
|
|
69
40
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
41
|
+
name: terminal-table
|
|
71
42
|
requirement: !ruby/object:Gem::Requirement
|
|
72
43
|
requirements:
|
|
73
44
|
- - ">="
|
|
74
45
|
- !ruby/object:Gem::Version
|
|
75
46
|
version: '0'
|
|
76
|
-
type: :
|
|
47
|
+
type: :runtime
|
|
77
48
|
prerelease: false
|
|
78
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
50
|
requirements:
|
|
@@ -81,20 +52,20 @@ dependencies:
|
|
|
81
52
|
- !ruby/object:Gem::Version
|
|
82
53
|
version: '0'
|
|
83
54
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
55
|
+
name: unicode-emoji
|
|
85
56
|
requirement: !ruby/object:Gem::Requirement
|
|
86
57
|
requirements:
|
|
87
58
|
- - ">="
|
|
88
59
|
- !ruby/object:Gem::Version
|
|
89
60
|
version: '0'
|
|
90
|
-
type: :
|
|
61
|
+
type: :runtime
|
|
91
62
|
prerelease: false
|
|
92
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
64
|
requirements:
|
|
94
65
|
- - ">="
|
|
95
66
|
- !ruby/object:Gem::Version
|
|
96
67
|
version: '0'
|
|
97
|
-
description: A collection of
|
|
68
|
+
description: A collection of useful Rake tasks for Rails.
|
|
98
69
|
email:
|
|
99
70
|
- sunny@sunfox.org
|
|
100
71
|
executables: []
|
|
@@ -108,17 +79,20 @@ files:
|
|
|
108
79
|
- lib/rateaux/file_task.rb
|
|
109
80
|
- lib/rateaux/namespaced.rb
|
|
110
81
|
- lib/rateaux/version.rb
|
|
82
|
+
- lib/tasks/rateaux_add_frozen_string_literal_headers.rake
|
|
111
83
|
- lib/tasks/rateaux_cache_clear.rake
|
|
112
84
|
- lib/tasks/rateaux_copy_non_digested_assets.rake
|
|
113
85
|
- lib/tasks/rateaux_db.rake
|
|
86
|
+
- lib/tasks/rateaux_db_migrate.rake
|
|
114
87
|
- lib/tasks/rateaux_db_schema_view.rake
|
|
115
|
-
- lib/tasks/rateaux_encoding_headers.rake
|
|
116
88
|
- lib/tasks/rateaux_git_checkout.rake
|
|
89
|
+
- lib/tasks/rateaux_i18n_word_count.rake
|
|
117
90
|
- lib/tasks/rateaux_notes_mine.rake
|
|
91
|
+
- lib/tasks/rateaux_sidekiq_flush.rake
|
|
118
92
|
homepage: http://github.com/sunny/rateaux
|
|
119
93
|
licenses: []
|
|
120
|
-
metadata:
|
|
121
|
-
|
|
94
|
+
metadata:
|
|
95
|
+
rubygems_mfa_required: 'true'
|
|
122
96
|
rdoc_options: []
|
|
123
97
|
require_paths:
|
|
124
98
|
- lib
|
|
@@ -126,16 +100,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
126
100
|
requirements:
|
|
127
101
|
- - ">="
|
|
128
102
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: '
|
|
103
|
+
version: '3.2'
|
|
130
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
105
|
requirements:
|
|
132
106
|
- - ">="
|
|
133
107
|
- !ruby/object:Gem::Version
|
|
134
108
|
version: '0'
|
|
135
109
|
requirements: []
|
|
136
|
-
|
|
137
|
-
rubygems_version: 2.5.1
|
|
138
|
-
signing_key:
|
|
110
|
+
rubygems_version: 3.6.2
|
|
139
111
|
specification_version: 4
|
|
140
|
-
summary: A collection of
|
|
112
|
+
summary: A collection of useful Rake tasks for Rails.
|
|
141
113
|
test_files: []
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
#
|
|
3
|
-
# Add 'encoding: UTF-8' to all files
|
|
4
|
-
#
|
|
5
|
-
# $ rake encoding_headers
|
|
6
|
-
|
|
7
|
-
desc "Adds the missing utf-8 encoding header on all Ruby files"
|
|
8
|
-
task :encoding_headers => :environment do
|
|
9
|
-
files = []
|
|
10
|
-
["*.rb", "*.rake"].each do |extension|
|
|
11
|
-
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ])
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
encoding = "# encoding: UTF-8\n"
|
|
15
|
-
|
|
16
|
-
files.each do |file|
|
|
17
|
-
content = File.read(file)
|
|
18
|
-
next if content[0..encoding.length] == encoding
|
|
19
|
-
content = content.gsub(/^# (encoding: UTF-8|coding: UTF-8|-*- coding: UTF-8 -*-)\n/i, "")
|
|
20
|
-
new_file = File.open(file, "w")
|
|
21
|
-
new_file.write(encoding+content)
|
|
22
|
-
new_file.close
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|