rexer 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd717744bdbbcbb0470f21f2cf7c8345b4852901a7cd86088751ca971d07b5cf
4
- data.tar.gz: ec7eac6cb58e0eed5ad5ad58de7479fc6223521497deb49728fb62a6fc2616dd
3
+ metadata.gz: 2b58d350ffc9bafc33b202240ed26a3ecf6228a29677ba2cca1938c81bd32576
4
+ data.tar.gz: 68d15da77b4838c6bbd97e35bd2b301c2cdf0d738176cc24fe62a07c1e486013
5
5
  SHA512:
6
- metadata.gz: f9db79d00f966ffa25c12cc5978103169e796f621e7e5e7dc842225067dbce3dcded6453cd61caa15e13434725bfc74da416b9c196a287279627359de3db5e2d
7
- data.tar.gz: 1d02b36a1baf9a5350d6729dd565f0cad4327a99c07ed28694d89f34253f2fcc8c08dd7bb68e978a4ace19c9ff3985d45a1041595c9c05dc8e40226484da5f84
6
+ metadata.gz: 3ef4db2f19d7fc91b28d265b8afe6a51080553ec4d2bd8f9a02824c05ed166593a1fbe44ed7e28a3a2ec3eb40d98a255963eb953b4e900340902ec4499a619cd
7
+ data.tar.gz: 330a05a5692158e30db7a3a4f55d2b830b18265dfb1fb277e5b73f27af113002014234431a8abe2f8a2932c2ca16f65b3c76121e483f9add212bcd0e45e74de4
data/README.md CHANGED
@@ -117,10 +117,6 @@ plugin :redmica_s3, github: { repo: "redmica/redmica_s3" } do
117
117
  uninstalled do
118
118
  Pathname.new("config", "s3.yml").delete
119
119
  end
120
-
121
- updated do
122
- puts "updated"
123
- end
124
120
  end
125
121
  ```
126
122
 
@@ -28,7 +28,7 @@ module Rexer
28
28
 
29
29
  install(diff.added_themes, diff.added_plugins)
30
30
  uninstall(diff.deleted_themes, diff.deleted_plugins)
31
- update(diff.changed_themes, diff.changed_plugins)
31
+ reload_source(diff.source_changed_themes, diff.source_changed_plugins)
32
32
 
33
33
  create_lock_file(definition.env)
34
34
  print_state
@@ -64,13 +64,13 @@ module Rexer
64
64
  end
65
65
  end
66
66
 
67
- def update(themes, plugins)
67
+ def reload_source(themes, plugins)
68
68
  themes.each do
69
- Extension::Theme::Updater.new(_1).update
69
+ Extension::Theme::SourceReloader.new(_1).reload
70
70
  end
71
71
 
72
72
  plugins.each do
73
- Extension::Plugin::Updater.new(_1).update
73
+ Extension::Plugin::SourceReloader.new(_1).reload
74
74
  end
75
75
  end
76
76
 
@@ -39,10 +39,8 @@ module Rexer
39
39
  end
40
40
  end
41
41
 
42
- def source_info(source_def)
43
- source_def.then {
44
- Source.const_get(_1.type.capitalize).new(**_1.options).info
45
- }
42
+ def source_info(definition_source)
43
+ Source.from_definition(definition_source).info
46
44
  end
47
45
 
48
46
  def no_lock_file_found
@@ -22,21 +22,21 @@ module Rexer
22
22
  old_data.themes - new_data.themes
23
23
  end
24
24
 
25
- def changed_plugins
25
+ def source_changed_plugins
26
26
  old_plugins = old_data.plugins
27
27
 
28
28
  (new_data.plugins & old_plugins).select do |new_plugin|
29
29
  old_plugin = old_plugins.find { _1.name == new_plugin.name }
30
- plugin_changed?(old_plugin, new_plugin)
30
+ plugin_source_changed?(old_plugin, new_plugin)
31
31
  end
32
32
  end
33
33
 
34
- def changed_themes
34
+ def source_changed_themes
35
35
  old_themes = old_data.themes
36
36
 
37
37
  (new_data.themes & old_themes).select do |new_theme|
38
38
  old_theme = old_themes.find { _1.name == new_theme.name }
39
- theme_changed?(old_theme, new_theme)
39
+ theme_source_changed?(old_theme, new_theme)
40
40
  end
41
41
  end
42
42
 
@@ -44,11 +44,11 @@ module Rexer
44
44
 
45
45
  attr_reader :old_data, :new_data
46
46
 
47
- def plugin_changed?(old_plugin, new_plugin)
47
+ def plugin_source_changed?(old_plugin, new_plugin)
48
48
  old_plugin.source != new_plugin.source
49
49
  end
50
50
 
51
- def theme_changed?(old_theme, new_theme)
51
+ def theme_source_changed?(old_theme, new_theme)
52
52
  old_theme.source != new_theme.source
53
53
  end
54
54
  end
@@ -11,7 +11,7 @@ module Rexer
11
11
  @plugins << Definition::Plugin.new(
12
12
  name: name,
13
13
  source: build_source(opts),
14
- hooks: build_hooks(hooks, %i[installed uninstalled updated]),
14
+ hooks: build_hooks(hooks, %i[installed uninstalled]),
15
15
  env: @env
16
16
  )
17
17
  end
@@ -20,7 +20,7 @@ module Rexer
20
20
  @themes << Definition::Theme.new(
21
21
  name: name,
22
22
  source: build_source(opts),
23
- hooks: build_hooks(hooks, %i[installed uninstalled updated]),
23
+ hooks: build_hooks(hooks, %i[installed uninstalled]),
24
24
  env: @env
25
25
  )
26
26
  end
@@ -54,7 +54,7 @@ module Rexer
54
54
  end
55
55
 
56
56
  def build_source(opts)
57
- type = opts.keys.find { Rexer::Source::Base.source_names.include?(_1) }
57
+ type = opts.keys.find { Rexer::Source.names.include?(_1) }
58
58
  Source.new(type, opts[type]) if type
59
59
  end
60
60
  end
@@ -42,9 +42,7 @@ module Rexer
42
42
  end
43
43
 
44
44
  def source
45
- @source ||= definition.source.then do |src|
46
- Source.const_get(src.type.capitalize).new(**src.options)
47
- end
45
+ @source ||= Source.from_definition(definition.source)
48
46
  end
49
47
  end
50
48
 
@@ -90,7 +88,6 @@ module Rexer
90
88
 
91
89
  update_source
92
90
  run_db_migrate
93
- hooks[:updated]&.call
94
91
  end
95
92
 
96
93
  private
@@ -99,6 +96,24 @@ module Rexer
99
96
  source.update(plugin_dir.to_s)
100
97
  end
101
98
  end
99
+
100
+ class SourceReloader < Base
101
+ def reload
102
+ return unless plugin_exists?
103
+
104
+ reload_source
105
+ run_db_migrate
106
+ end
107
+
108
+ private
109
+
110
+ def reload_source
111
+ plugin_dir.to_s.then { |dir|
112
+ FileUtils.rm_rf(dir)
113
+ source.load(dir)
114
+ }
115
+ end
116
+ end
102
117
  end
103
118
  end
104
119
  end
@@ -32,9 +32,7 @@ module Rexer
32
32
  end
33
33
 
34
34
  def source
35
- @source ||= definition.source.then do |src|
36
- Source.const_get(src.type.capitalize).new(**src.options)
37
- end
35
+ @source ||= Source.from_definition(definition.source)
38
36
  end
39
37
  end
40
38
 
@@ -73,7 +71,6 @@ module Rexer
73
71
  return unless theme_exists?
74
72
 
75
73
  update_source
76
- hooks[:updated]&.call
77
74
  end
78
75
 
79
76
  private
@@ -82,6 +79,23 @@ module Rexer
82
79
  source.update(theme_dir.to_s)
83
80
  end
84
81
  end
82
+
83
+ class SourceReloader < Base
84
+ def reload
85
+ return unless theme_exists?
86
+
87
+ reload_source
88
+ end
89
+
90
+ private
91
+
92
+ def reload_source
93
+ theme_dir.to_s.then { |dir|
94
+ FileUtils.rm_rf(dir)
95
+ source.load(dir)
96
+ }
97
+ end
98
+ end
85
99
  end
86
100
  end
87
101
  end
@@ -1,16 +1,16 @@
1
1
  module Rexer
2
2
  module Source
3
3
  class Base
4
- def self.source_names = @source_names ||= []
5
-
6
4
  def self.inherited(subclass)
7
- source_names << subclass.name.split("::").last.downcase.to_sym
5
+ Source.names << subclass.name.split("::").last.downcase.to_sym
8
6
  end
9
7
 
8
+ # Load the source to the given path.
10
9
  def load(_path)
11
10
  raise "Not implemented"
12
11
  end
13
12
 
13
+ # Update to the latest version of the source.
14
14
  def update(_path)
15
15
  raise "Not implemented"
16
16
  end
@@ -0,0 +1,9 @@
1
+ module Rexer
2
+ module Source
3
+ def self.names = @names ||= []
4
+
5
+ def self.from_definition(source)
6
+ const_get(source.type.capitalize).new(**source.options)
7
+ end
8
+ end
9
+ end
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuya Hidaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -82,6 +82,7 @@ files:
82
82
  - lib/rexer/definition/lock.rb
83
83
  - lib/rexer/extension/plugin.rb
84
84
  - lib/rexer/extension/theme.rb
85
+ - lib/rexer/source.rb
85
86
  - lib/rexer/source/base.rb
86
87
  - lib/rexer/source/git.rb
87
88
  - lib/rexer/source/github.rb