rexer 0.9.1 → 0.11.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: 1db7d4adf66ad78aae372f512810ade8001893feadc4233da362ad2bffaa5f58
4
- data.tar.gz: a5b03b4d24061a734c2525b1b6251c8e905c4055b7ab7c7fc42a8c6edb5ad13c
3
+ metadata.gz: 86612492af231c5ed6d00b8fe44c305a62013b2aeb3571bbb70c4d53e8ed6b30
4
+ data.tar.gz: 1cf5c21eb32b9a30829c1dcc9b823902dd9a560190a44ae9976288f4c340e5f3
5
5
  SHA512:
6
- metadata.gz: cb41f315f2e2881f08a6e8831df01809ac9a36b10734289201d430bdf9bba91d13fe02fc64e7c730e4a268442cadfbe5bba1e1057f0f0967f41e250fb3e5b9d7
7
- data.tar.gz: 806b8384297143c5d1e27b44a2a79106203b87133c41233e85c05510da0e590b9bd81b9cd96b6199bab09c2f4a45d1aa28e1174b4894146b7fcbf87afbe3098d
6
+ metadata.gz: da47f60be431db339d94dbaa944b4732495cc2f29088413826a3828c03c6e140fa438c967f38ed68881058f89d2caff0c3751adf569c9110579e508c29016135
7
+ data.tar.gz: 4c48a3ebffb2341d93adde02983cb9019587e00f0be83060f57237967c07fa955a94e2ba34a129392d33be3bc862b557586b931dc02ad4e74135556f17dc239c
data/README.md CHANGED
@@ -80,13 +80,13 @@ This command uninstalls the extensions and deletes the `.extensions.lock`.
80
80
  ```
81
81
  $ rex
82
82
  Commands:
83
- rex envs # Show the list of defined environments in .extensions.rb
83
+ rex envs # Show the list of environments and their extensions defined in .extensions.rb
84
84
  rex help [COMMAND] # Describe available commands or one specific command
85
85
  rex init # Create a new .extensions.rb file
86
86
  rex install [ENV] # Install the definitions in .extensions.rb for the specified environment
87
87
  rex state # Show the current state of the installed extensions
88
- rex switch [ENV] # Uninstall extensions for the currently installed environment and install ext...
89
- rex uninstall # Uninstall extensions for the currently installed environment based on the st...
88
+ rex switch [ENV] # Uninstall extensions for the currently installed environment and install extensions for the specified environment
89
+ rex uninstall # Uninstall extensions for the currently installed environment based on the state in .extensions.lock and remove the lock file
90
90
  rex update # Update extensions for the currently installed environment to the latest version
91
91
  rex version # Show Rexer version
92
92
 
@@ -166,7 +166,12 @@ In addition, you can define as many environments as you like, and list the defin
166
166
  ```
167
167
  $ rex envs
168
168
  default
169
+ bleuclair (support-propshaft)
170
+ redmine_issues_panel (master)
171
+
169
172
  stable
173
+ bleuclair (support-propshaft)
174
+ redmine_issues_panel (v1.0.2)
170
175
  ```
171
176
 
172
177
  ### Defining hooks
data/lib/rexer/cli.rb CHANGED
@@ -39,7 +39,7 @@ module Rexer
39
39
  Commands::State.new.call
40
40
  end
41
41
 
42
- desc "envs", "Show the list of defined environments in .extensions.rb"
42
+ desc "envs", "Show the list of environments and their extensions defined in .extensions.rb"
43
43
  def envs
44
44
  Commands::Envs.new.call
45
45
  end
@@ -6,16 +6,27 @@ module Rexer
6
6
  end
7
7
 
8
8
  def call
9
- puts(*defined_envs)
9
+ defined_envs = definition.envs
10
+ defined_envs.each.with_index do |env, i|
11
+ puts env
12
+
13
+ definition_with(env).then { _1.themes + _1.plugins }.each do
14
+ puts " #{_1.name} (#{Source.from_definition(_1.source).info})"
15
+ end
16
+
17
+ puts if i < defined_envs.size - 1
18
+ end
10
19
  end
11
20
 
12
21
  private
13
22
 
14
23
  attr_reader :definition
15
24
 
16
- def defined_envs
17
- all_envs = definition.plugins.map(&:env) + definition.themes.map(&:env)
18
- all_envs.uniq.sort
25
+ def definition_with(env)
26
+ definition.with(
27
+ plugins: definition.plugins.select { _1.env == env },
28
+ themes: definition.themes.select { _1.env == env }
29
+ )
19
30
  end
20
31
  end
21
32
  end
@@ -1,3 +1,5 @@
1
+ require "paint"
2
+
1
3
  module Rexer
2
4
  module Commands
3
5
  class Init
@@ -37,9 +37,12 @@ module Rexer
37
37
  end
38
38
 
39
39
  def load_definition(env)
40
- Definition.load_data.tap { |data|
41
- data.env = env
42
- }
40
+ data = Definition.load_data
41
+ data.with(
42
+ plugins: data.plugins.select { _1.env == env },
43
+ themes: data.themes.select { _1.env == env },
44
+ env:
45
+ )
43
46
  end
44
47
 
45
48
  def load_lock_definition
@@ -1,22 +1,12 @@
1
1
  module Rexer
2
2
  module Definition
3
- class Data
4
- attr_accessor :env
5
- attr_reader :version
6
-
7
- def initialize(plugins, themes, env: nil, version: nil)
8
- @plugins = plugins
9
- @themes = themes
10
- @env = env
11
- @version = version
12
- end
13
-
14
- def plugins
15
- env ? @plugins.select { _1.env == env } : @plugins
3
+ Data = ::Data.define(:plugins, :themes, :env, :version) do
4
+ def initialize(plugins:, themes:, env: nil, version: nil)
5
+ super
16
6
  end
17
7
 
18
- def themes
19
- env ? @themes.select { _1.env == env } : @themes
8
+ def envs
9
+ (plugins.map(&:env) + themes.map(&:env)).uniq.sort
20
10
  end
21
11
 
22
12
  def diff(other)
@@ -1,10 +1,17 @@
1
1
  module Rexer
2
2
  module Definition
3
3
  class Dsl
4
- def initialize(env = :default)
4
+ def initialize
5
5
  @plugins = []
6
6
  @themes = []
7
- @env = env
7
+ @env = :default
8
+ end
9
+
10
+ class EnvDsl < self
11
+ def initialize(env)
12
+ super()
13
+ @env = env
14
+ end
8
15
  end
9
16
 
10
17
  def plugin(name, **opts, &hooks)
@@ -27,7 +34,7 @@ module Rexer
27
34
 
28
35
  def env(*env_names, &dsl)
29
36
  env_names.each do |env_name|
30
- data = self.class.new(env_name).tap { _1.instance_eval(&dsl) }.to_data
37
+ data = EnvDsl.new(env_name).tap { _1.instance_eval(&dsl) }.to_data
31
38
 
32
39
  @plugins += data.plugins
33
40
  @themes += data.themes
@@ -56,7 +63,7 @@ module Rexer
56
63
  end
57
64
 
58
65
  def build_source(opts)
59
- type = opts.keys.find { Rexer::Source.names.include?(_1) }
66
+ type = opts.keys.find { Rexer::Source.const_defined?(_1.capitalize) }
60
67
  Source.new(type, opts[type]) if type
61
68
  end
62
69
  end
@@ -23,17 +23,20 @@ module Rexer
23
23
 
24
24
  class Dsl < Definition::Dsl
25
25
  def lock(env:, version:)
26
- lock_state.update(env:, version:)
26
+ @lock_env = env
27
+ @lock_version = version
27
28
  end
28
29
 
29
30
  def to_data
30
- Definition::Data.new(@plugins, @themes, **lock_state)
31
+ plugins = lock_by_env(@plugins)
32
+ themes = lock_by_env(@themes)
33
+ Definition::Data.new(plugins, themes, @lock_env, @lock_version)
31
34
  end
32
35
 
33
36
  private
34
37
 
35
- def lock_state
36
- @lock_state ||= {}
38
+ def lock_by_env(plugins_or_themes)
39
+ plugins_or_themes.select { _1.env == @lock_env }
37
40
  end
38
41
  end
39
42
  end
@@ -1,10 +1,6 @@
1
1
  module Rexer
2
2
  module Source
3
3
  class Base
4
- def self.inherited(subclass)
5
- Source.names << subclass.name.split("::").last.downcase.to_sym
6
- end
7
-
8
4
  # Load the source to the given path.
9
5
  def load(_path)
10
6
  raise "Not implemented"
data/lib/rexer/source.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  module Rexer
2
2
  module Source
3
- def self.names = @names ||= []
4
-
5
3
  def self.from_definition(source)
6
4
  const_get(source.type.capitalize).new(**source.options)
7
5
  end
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.9.1"
2
+ VERSION = "0.11.0"
3
3
  end
data/lib/rexer.rb CHANGED
@@ -32,4 +32,3 @@ require "zeitwerk"
32
32
 
33
33
  loader = Zeitwerk::Loader.for_gem
34
34
  loader.setup
35
- loader.eager_load
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.9.1
4
+ version: 0.11.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-09-03 00:00:00.000000000 Z
11
+ date: 2024-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor