worker_plugins 0.0.10 → 0.0.12
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 +4 -4
- data/README.md +18 -0
- data/Rakefile +1 -0
- data/app/services/worker_plugins/application_service.rb +6 -0
- data/app/services/worker_plugins/select_column_with_type_cast.rb +15 -3
- data/db/migrate/20260325100902_add_session_id_to_worker_plugins_workplaces.rb +6 -0
- data/lib/tasks/release.rake +171 -0
- data/lib/worker_plugins/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1204dc5970fc5918fc39aa22e76fcf3fbfae7a040912eda7151ab59e85be415
|
|
4
|
+
data.tar.gz: 9e7a9916256ff3fa6775dcddbdde2c1ba1fa9f95b08edc5786d487809b17ef2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77b9f5d7e32386bdafa68225bb952c97d8c03c40b1d8c338940f56c3c8dc654b27747629e9018a40f2749a56d06752a7ee84e3bbf27f64c53d27fcf263c09135
|
|
7
|
+
data.tar.gz: 45c97e82cee0dda1f2d24279b77165843852d0f9d9a8f8c8fb41592cfeaf4c789b07481495abcc34ba8a8c1c1d697deeff26d70a6b0ad457f3b2677689e42193
|
data/README.md
CHANGED
|
@@ -27,6 +27,24 @@ Optimally loop over resources on a workspace:
|
|
|
27
27
|
workspace.each_resource(types: ['User']) do |user|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Release
|
|
31
|
+
|
|
32
|
+
Run the release task from a clean worktree:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bundle exec rake release:patch
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The task checks out `master`, fetches and fast-forwards from `origin/master`, bumps `lib/worker_plugins/version.rb`, commits and pushes the release commit, runs `npm login` if `npm whoami` shows no active session, then builds and pushes the gem to RubyGems and removes the generated `.gem` file afterward.
|
|
39
|
+
|
|
40
|
+
Use `BUMP=minor`, `BUMP=major`, or `VERSION=x.y.z` to control the version bump:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bundle exec rake release:minor
|
|
44
|
+
bundle exec rake release:major
|
|
45
|
+
bundle exec rake release:rubygems VERSION=0.1.0
|
|
46
|
+
```
|
|
47
|
+
|
|
30
48
|
## License
|
|
31
49
|
|
|
32
50
|
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
CHANGED
|
@@ -30,4 +30,10 @@ class WorkerPlugins::ApplicationService < ServicePattern::Service
|
|
|
30
30
|
def sqlite?
|
|
31
31
|
ActiveRecord::Base.connection.instance_values["config"][:adapter].downcase.include?("sqlite")
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
def mysql?
|
|
35
|
+
adapter_name = ActiveRecord::Base.connection.instance_values["config"][:adapter].downcase
|
|
36
|
+
|
|
37
|
+
adapter_name.include?("mysql") || adapter_name.include?("trilogy")
|
|
38
|
+
end
|
|
33
39
|
end
|
|
@@ -22,15 +22,27 @@ class WorkerPlugins::SelectColumnWithTypeCast < WorkerPlugins::ApplicationServic
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def query_with_integer
|
|
25
|
-
|
|
25
|
+
if mysql?
|
|
26
|
+
query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS SIGNED)")
|
|
27
|
+
else
|
|
28
|
+
query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS BIGINT)")
|
|
29
|
+
end
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
def query_with_varchar
|
|
29
|
-
|
|
33
|
+
if mysql?
|
|
34
|
+
query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS CHAR)")
|
|
35
|
+
else
|
|
36
|
+
query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS VARCHAR)")
|
|
37
|
+
end
|
|
30
38
|
end
|
|
31
39
|
|
|
32
40
|
def query_with_uuid
|
|
33
|
-
|
|
41
|
+
if postgres?
|
|
42
|
+
query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS UUID)")
|
|
43
|
+
else
|
|
44
|
+
query_with_varchar
|
|
45
|
+
end
|
|
34
46
|
end
|
|
35
47
|
|
|
36
48
|
def same_type?
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
require "English"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
require "pathname"
|
|
4
|
+
require "rubygems/version"
|
|
5
|
+
require "shellwords"
|
|
6
|
+
|
|
7
|
+
class WorkerPluginsRubygemsRelease # rubocop:disable Lint/ConstantDefinitionInBlock
|
|
8
|
+
VERSION_FILE = Pathname.new(File.expand_path("../worker_plugins/version.rb", __dir__)) unless const_defined?(:VERSION_FILE)
|
|
9
|
+
|
|
10
|
+
def call
|
|
11
|
+
ensure_clean_worktree!
|
|
12
|
+
checkout_master!
|
|
13
|
+
fetch!
|
|
14
|
+
merge!
|
|
15
|
+
|
|
16
|
+
next_version = determine_next_version
|
|
17
|
+
|
|
18
|
+
bump_version!(next_version)
|
|
19
|
+
commit!(next_version)
|
|
20
|
+
push!
|
|
21
|
+
gem_file = build_gem!(next_version)
|
|
22
|
+
push_gem!(gem_file)
|
|
23
|
+
delete_gem_file!(gem_file)
|
|
24
|
+
rescue StandardError
|
|
25
|
+
warn "Release failed."
|
|
26
|
+
raise
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def ensure_clean_worktree!
|
|
32
|
+
dirty_entries = git_status_lines.grep_v(%r{\A\?\? worker_plugins-[^/]+\.gem\z})
|
|
33
|
+
return if dirty_entries.empty?
|
|
34
|
+
|
|
35
|
+
raise "Working tree must be clean before releasing:\n#{dirty_entries.join("\n")}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def checkout_master!
|
|
39
|
+
run!("git", "checkout", "master")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def fetch!
|
|
43
|
+
run!("git", "fetch", remote_name)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def merge!
|
|
47
|
+
run!("git", "merge", "--ff-only", "#{remote_name}/master")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def determine_next_version
|
|
51
|
+
requested_version || bumped_version
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def requested_version
|
|
55
|
+
version = ENV["VERSION"]&.strip
|
|
56
|
+
return if version.to_s.empty?
|
|
57
|
+
|
|
58
|
+
Gem::Version.new(version)
|
|
59
|
+
version
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def bumped_version
|
|
63
|
+
case bump_type
|
|
64
|
+
when "major"
|
|
65
|
+
[version_segments[0] + 1, 0, 0].join(".")
|
|
66
|
+
when "minor"
|
|
67
|
+
[version_segments[0], version_segments[1] + 1, 0].join(".")
|
|
68
|
+
when "patch"
|
|
69
|
+
[version_segments[0], version_segments[1], version_segments[2] + 1].join(".")
|
|
70
|
+
else
|
|
71
|
+
raise "Unsupported BUMP=#{bump_type.inspect}. Use patch, minor, major, or VERSION=x.y.z."
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def version_segments
|
|
76
|
+
@version_segments ||= begin
|
|
77
|
+
segments = Gem::Version.new(current_version).segments
|
|
78
|
+
segments << 0 while segments.length < 3
|
|
79
|
+
segments
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def current_version
|
|
84
|
+
@current_version ||= VERSION_FILE.read[/VERSION = "([^"]+)"/, 1] || raise("Could not find current version")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def bump_version!(next_version)
|
|
88
|
+
raise "Next version must differ from current version" if next_version == current_version
|
|
89
|
+
|
|
90
|
+
VERSION_FILE.write(
|
|
91
|
+
VERSION_FILE.read.sub(
|
|
92
|
+
/VERSION = "[^"]+"/,
|
|
93
|
+
%(VERSION = "#{next_version}")
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
run!("git", "add", VERSION_FILE.to_s)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def commit!(next_version)
|
|
101
|
+
run!("git", "commit", "-m", "Release #{next_version}")
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def push!
|
|
105
|
+
run!("git", "push", remote_name, "master")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def build_gem!(next_version)
|
|
109
|
+
gem_file = "worker_plugins-#{next_version}.gem"
|
|
110
|
+
run!("gem", "build", "worker_plugins.gemspec")
|
|
111
|
+
gem_file
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def push_gem!(gem_file)
|
|
115
|
+
run!("gem", "push", gem_file)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def delete_gem_file!(gem_file)
|
|
119
|
+
FileUtils.rm_f(gem_file)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def git_status_lines
|
|
123
|
+
capture!("git", "status", "--porcelain").split("\n").reject(&:empty?)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def bump_type
|
|
127
|
+
ENV.fetch("BUMP", "patch")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def remote_name
|
|
131
|
+
ENV.fetch("REMOTE", "origin")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def capture!(*command)
|
|
135
|
+
output = `#{command.map { |part| Shellwords.escape(part) }.join(" ")}`
|
|
136
|
+
raise "Command failed: #{command.join(' ')}" unless $CHILD_STATUS&.success?
|
|
137
|
+
|
|
138
|
+
output
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def run!(*command)
|
|
142
|
+
return if system(*command)
|
|
143
|
+
|
|
144
|
+
raise "Command failed: #{command.join(' ')}"
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
namespace :release do
|
|
149
|
+
desc "Release a patch version from master by fetching, fast-forward merging, bumping version, pushing, and publishing"
|
|
150
|
+
task :patch do
|
|
151
|
+
ENV["BUMP"] = "patch"
|
|
152
|
+
WorkerPluginsRubygemsRelease.new.call
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
desc "Release a minor version from master by fetching, fast-forward merging, bumping version, pushing, and publishing"
|
|
156
|
+
task :minor do
|
|
157
|
+
ENV["BUMP"] = "minor"
|
|
158
|
+
WorkerPluginsRubygemsRelease.new.call
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
desc "Release a major version from master by fetching, fast-forward merging, bumping version, pushing, and publishing"
|
|
162
|
+
task :major do
|
|
163
|
+
ENV["BUMP"] = "major"
|
|
164
|
+
WorkerPluginsRubygemsRelease.new.call
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
desc "Release the gem from master by fetching, fast-forward merging, bumping version, pushing, and publishing"
|
|
168
|
+
task :rubygems do
|
|
169
|
+
WorkerPluginsRubygemsRelease.new.call
|
|
170
|
+
end
|
|
171
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: worker_plugins
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kasper Stöckel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Rails framework for easily choosing and creating lists of objects and
|
|
14
14
|
execute plugins against them.
|
|
@@ -41,6 +41,8 @@ files:
|
|
|
41
41
|
- db/migrate/20200702072306_change_workplace_links_resource_id_to_string_to_support_uuids.rb
|
|
42
42
|
- db/migrate/20210106190349_change_resource_id_to_string_to_support_uuid.rb
|
|
43
43
|
- db/migrate/20260322194625_add_session_id_to_worker_plugins_workplaces.rb
|
|
44
|
+
- db/migrate/20260325100902_add_session_id_to_worker_plugins_workplaces.rb
|
|
45
|
+
- lib/tasks/release.rake
|
|
44
46
|
- lib/tasks/worker_plugins_tasks.rake
|
|
45
47
|
- lib/worker_plugins.rb
|
|
46
48
|
- lib/worker_plugins/engine.rb
|