rexer 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61d1b3b0172a3db2da03ac1f428f447a5296df8430fabaf21f4ce1cb1f96ce41
4
- data.tar.gz: 8dc2852d1ef7f6052d2c8d09cba035276fd7b039bc109be732d0599142a27059
3
+ metadata.gz: 0aa31136277eb6010005efd6b949d33791f40c43cf2c10e4c59aaa63f7635874
4
+ data.tar.gz: 7782364e1ae8e1c068d89c416feb8f058f39babfa9a4bf949c238cf828f51975
5
5
  SHA512:
6
- metadata.gz: 72c9335b6be10bb6a7220d3b632ce2d0c20719165b5e93d17244e5f8c4412ea8fad0b36e805ae1cba51ef652d77afce8dd98676bfe1dcfb0b14e24249cf4fa8d
7
- data.tar.gz: b708a563d706ba42aad33a1daa40a5d7a7c4365c481be516d423a2a05176f8b4c0f6ef68afae27ca571ba55a99f03b3dbf51e10de497f91f672f781ff87a762a
6
+ metadata.gz: a657e3d3ace4b1134d455b05fc9dabc1905e96fb88870b41d0b771c4bd7e7803949b333a422a724a8d15937613cba04a692105a51c7332ba74f35dc996010459
7
+ data.tar.gz: ec8fed06a4d98da769d42c99266caa91f6250f738e71ca39536f66f0ed1a570594b8b3f5c96166ee4563137a9e7c6a008842582138af70412e96e6438a9ffcf2
data/README.md CHANGED
@@ -79,6 +79,7 @@ This command uninstalls the extensions and deletes the `.extensions.lock`.
79
79
  ```
80
80
  $ rex
81
81
  Commands:
82
+ rex edit # Edit .extensions.rb
82
83
  rex envs # Show the list of environments and their extensions defined in .extensions.rb
83
84
  rex help [COMMAND] # Describe available commands or one specific command
84
85
  rex init # Create a new .extensions.rb file
data/lib/rexer/cli.rb CHANGED
@@ -50,6 +50,11 @@ module Rexer
50
50
  Commands::Envs.new.call
51
51
  end
52
52
 
53
+ desc "edit", "Edit .extensions.rb"
54
+ def edit
55
+ Commands::Edit.new.call
56
+ end
57
+
53
58
  desc "version", "Show Rexer version"
54
59
  def version
55
60
  puts Rexer::VERSION
@@ -0,0 +1,28 @@
1
+ require "shellwords"
2
+
3
+ module Rexer
4
+ module Commands
5
+ class Edit
6
+ def call
7
+ definition_file = Definition.file
8
+
9
+ if editor.to_s.empty?
10
+ puts Paint["Please set your $VISUAL or $EDITOR environment variable.", :red]
11
+ exit 1
12
+ end
13
+
14
+ edit_system_editor(definition_file.to_s)
15
+ end
16
+
17
+ private
18
+
19
+ def editor
20
+ ENV["VISUAL"].to_s.empty? ? ENV["EDITOR"] : ENV["VISUAL"]
21
+ end
22
+
23
+ def edit_system_editor(file_path)
24
+ system(*Shellwords.split(editor), file_path)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,7 +2,12 @@ module Rexer
2
2
  module Commands
3
3
  class Init
4
4
  def call
5
- definition_file = Definition.file
5
+ unless redmine_root_dir?
6
+ puts Paint["Please run in the Redmine root directory.", :red]
7
+ exit 1
8
+ end
9
+
10
+ definition_file = Pathname.new(Rexer.definition_file)
6
11
 
7
12
  if definition_file.exist?
8
13
  puts Paint["#{definition_file.basename} already exists", :red]
@@ -34,6 +39,10 @@ module Rexer
34
39
 
35
40
  TEMPLATE
36
41
  end
42
+
43
+ def redmine_root_dir?
44
+ Pathname.new("README.rdoc").then { _1.exist? && _1.read.include?("Redmine") }
45
+ end
37
46
  end
38
47
  end
39
48
  end
@@ -2,7 +2,7 @@ module Rexer
2
2
  module Definition
3
3
  module Lock
4
4
  def self.file
5
- @file ||= Pathname.new(Rexer.definition_lock_file)
5
+ @file ||= Definition.dir.join(Rexer.definition_lock_file)
6
6
  end
7
7
 
8
8
  def self.load_data
@@ -10,6 +10,8 @@ module Rexer
10
10
 
11
11
  dsl = Dsl.new.tap { _1.instance_eval(file.read) }
12
12
  dsl.to_data
13
+ rescue DefinitionFileNotFound
14
+ nil
13
15
  end
14
16
 
15
17
  def self.create_file(env)
@@ -10,6 +10,12 @@ module Rexer
10
10
  end
11
11
  end
12
12
 
13
+ class DefinitionFileNotFound < StandardError
14
+ def initialize
15
+ super("No definition file (#{Rexer.definition_file}) found")
16
+ end
17
+ end
18
+
13
19
  Source = ::Data.define(:type, :options)
14
20
 
15
21
  Plugin = ::Data.define(:name, :source, :hooks, :env) do
@@ -20,13 +26,32 @@ module Rexer
20
26
  include ExtensionComparable
21
27
  end
22
28
 
29
+ def self.dir
30
+ @dir ||= find_difinition_dir
31
+ end
32
+
23
33
  def self.file
24
- @file ||= Pathname.new(Rexer.definition_file)
34
+ @file ||= dir.join(Rexer.definition_file)
25
35
  end
26
36
 
27
37
  def self.load_data
28
38
  dsl = Dsl.new.tap { _1.instance_eval(file.read) }
29
39
  dsl.to_data
40
+ rescue DefinitionFileNotFound
41
+ nil
42
+ end
43
+
44
+ def self.find_difinition_dir
45
+ definition_file = Rexer.definition_file
46
+ dir = Pathname.pwd
47
+
48
+ until dir.join(definition_file).exist?
49
+ raise DefinitionFileNotFound if dir.root?
50
+ dir = dir.parent
51
+ end
52
+
53
+ dir
30
54
  end
55
+ private_class_method :find_difinition_dir
31
56
  end
32
57
  end
@@ -1,11 +1,7 @@
1
- require "active_support/core_ext/class/attribute"
2
-
3
1
  module Rexer
4
2
  module Extension
5
3
  module Entity
6
4
  class Base
7
- class_attribute :root_dir
8
-
9
5
  def initialize(definition)
10
6
  @definition = definition
11
7
  @hooks = definition.hooks || {}
@@ -14,6 +10,8 @@ module Rexer
14
10
 
15
11
  attr_reader :hooks, :name
16
12
 
13
+ def root_dir = raise "Not implemented"
14
+
17
15
  def exist?
18
16
  path.exist? && !path.empty?
19
17
  end
@@ -36,7 +34,9 @@ module Rexer
36
34
  end
37
35
 
38
36
  class Plugin < Base
39
- self.root_dir = Pathname.new("plugins")
37
+ def root_dir
38
+ @root_dir ||= Rexer.redmine_root_dir.join("plugins")
39
+ end
40
40
 
41
41
  def contains_db_migrations?
42
42
  path.join("db", "migrate").then { _1.exist? && !_1.empty? }
@@ -48,7 +48,9 @@ module Rexer
48
48
  end
49
49
 
50
50
  class Theme < Base
51
- self.root_dir = Pathname.new("themes")
51
+ def root_dir
52
+ @root_dir ||= Rexer.redmine_root_dir.join("themes")
53
+ end
52
54
  end
53
55
  end
54
56
  end
@@ -16,12 +16,8 @@ module Rexer
16
16
 
17
17
  attr_reader :plugin
18
18
 
19
- def needs_db_migration?
20
- plugin.contains_db_migrations?
21
- end
22
-
23
19
  def run_db_migrate(extra_envs = {})
24
- return unless needs_db_migration?
20
+ return unless plugin.contains_db_migrations?
25
21
 
26
22
  envs = {"NAME" => plugin.name.to_s}.merge(extra_envs)
27
23
  cmds = build_cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate", envs:)
@@ -35,7 +35,7 @@ module Rexer
35
35
  end
36
36
 
37
37
  def call_installed_hook
38
- plugin.hooks[:installed]&.call
38
+ Rexer.redmine_root_dir { plugin.hooks[:installed]&.call }
39
39
  end
40
40
  end
41
41
  end
@@ -28,7 +28,7 @@ module Rexer
28
28
  end
29
29
 
30
30
  def call_uninstalled_hook
31
- plugin.hooks[:uninstalled]&.call
31
+ Rexer.redmine_root_dir { plugin.hooks[:uninstalled]&.call }
32
32
  end
33
33
  end
34
34
  end
@@ -23,7 +23,7 @@ module Rexer
23
23
  end
24
24
 
25
25
  def call_installed_hook
26
- theme.hooks[:installed]&.call
26
+ Rexer.redmine_root_dir { theme.hooks[:installed]&.call }
27
27
  end
28
28
  end
29
29
  end
@@ -23,7 +23,7 @@ module Rexer
23
23
  end
24
24
 
25
25
  def call_uninstalled_hook
26
- theme.hooks[:uninstalled]&.call
26
+ Rexer.redmine_root_dir { theme.hooks[:uninstalled]&.call }
27
27
  end
28
28
  end
29
29
  end
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.16.0"
2
+ VERSION = "0.17.0"
3
3
  end
data/lib/rexer.rb CHANGED
@@ -21,6 +21,14 @@ module Rexer
21
21
  ".extensions.lock"
22
22
  end
23
23
 
24
+ def redmine_root_dir
25
+ if block_given?
26
+ Dir.chdir(Definition.dir) { yield }
27
+ else
28
+ Definition.dir
29
+ end
30
+ end
31
+
24
32
  def config
25
33
  @config ||= Config.new(command_prefix: ENV["REXER_COMMAND_PREFIX"])
26
34
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuya Hidaka
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-01-01 00:00:00.000000000 Z
10
+ date: 2025-02-16 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: thor
@@ -126,6 +125,7 @@ files:
126
125
  - lib/rexer.rb
127
126
  - lib/rexer/cli.rb
128
127
  - lib/rexer/commands.rb
128
+ - lib/rexer/commands/edit.rb
129
129
  - lib/rexer/commands/envs.rb
130
130
  - lib/rexer/commands/init.rb
131
131
  - lib/rexer/commands/install.rb
@@ -160,7 +160,6 @@ licenses:
160
160
  - MIT
161
161
  metadata:
162
162
  source_code_uri: https://github.com/hidakatsuya/rexer
163
- post_install_message:
164
163
  rdoc_options: []
165
164
  require_paths:
166
165
  - lib
@@ -175,8 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
174
  - !ruby/object:Gem::Version
176
175
  version: '0'
177
176
  requirements: []
178
- rubygems_version: 3.5.11
179
- signing_key:
177
+ rubygems_version: 3.6.2
180
178
  specification_version: 4
181
179
  summary: A command-line tool for managing Redmine Plugins and Themes
182
180
  test_files: []