eac_launcher 0.4.0 → 0.5.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: 290a1a038cf1980ae1a6d85a3428f79f50acf5b86ce12bae24913be01c88636f
4
- data.tar.gz: 03e46414c9e8e234f6165ae76d67880caf0e71ae4ffdb2256fd4d276f8f185f8
3
+ metadata.gz: c324b8f85e2f9e0c1bf361975a6819b452da017ea28d0f0f6a404d4a1317cb18
4
+ data.tar.gz: dba44e7346080c992d0685cb8f6f2073d5001c8b55977dc03d31ddf4c2c0eeca
5
5
  SHA512:
6
- metadata.gz: e6cd81ae0be28005ca445b19b5a5ea4daed91774975ac4c426ac468cafdbe8fc43171c7f20b956e85c9ff556753ef1e922dcdde79469ca446585d57fd1b129de
7
- data.tar.gz: f7fab0d8008fb44cc760a6fc53090f65df1f235464126aad656834e88c9d00d315d5d57d4cbe0845e14caeade73e2813b647a2825552bf80d82160bd27442479
6
+ metadata.gz: c583eaa14ecbf7bf75bbe5620281e9d7055b9a8b070f7a5692c9a45b528c0229f4b72c3244588e9677bc50b22887d0a6911377618f882ce159b91269a59769e3
7
+ data.tar.gz: a15a502859f808a545c4036e891929d3c92170b23769a48f336aea75250ee6c2453178472cc1e395d351226a911f3518273846858f4c4a6073dcdd6d039d5d91
@@ -17,6 +17,7 @@ Options:
17
17
  --new Publish projects not published before.
18
18
  -s --stereotype=<st> Publish only for stereotype <stereotype>.
19
19
  --all Publish all instances.
20
+ --pending Publish only pending.
20
21
  --recache Rewrite instances cache.
21
22
 
22
23
  DOCOPT
@@ -20,7 +20,7 @@ module EacLauncher
20
20
  end
21
21
 
22
22
  attr_reader :root, :settings, :cache_root
23
- attr_accessor :publish_options, :recache
23
+ attr_accessor :publish_options, :recache, :instance_manager
24
24
 
25
25
  def initialize(options = {})
26
26
  @options = options.with_indifferent_access
@@ -40,6 +40,10 @@ module EacLauncher
40
40
  @instance_manager.instances
41
41
  end
42
42
 
43
+ def pending_instances
44
+ @instance_manager.pending_instances
45
+ end
46
+
43
47
  private
44
48
 
45
49
  def build_option(key)
@@ -7,6 +7,18 @@ module EacLauncher
7
7
  @context = context
8
8
  end
9
9
 
10
+ def publish_state_set(instance, stereotype_name, check_status)
11
+ data = cached_instances_file_content_uncached
12
+ data[instance.logical] ||= {}
13
+ data[instance.logical][:publish_state] ||= {}
14
+ data[instance.logical][:publish_state][stereotype_name] = check_status
15
+ write_cache_file(data)
16
+ end
17
+
18
+ def pending_instances
19
+ instances.select { |instance| pending_instance?(instance) }
20
+ end
21
+
10
22
  private
11
23
 
12
24
  def instances_uncached
@@ -31,15 +43,27 @@ module EacLauncher
31
43
  end
32
44
 
33
45
  def cache_instances(instances)
34
- r = Hash[instances.map { |i| [i.logical, i.to_h] }]
35
- ::File.write(cache_file_path, r.to_yaml)
46
+ write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
36
47
  instances
37
48
  end
38
49
 
50
+ def write_cache_file(data)
51
+ ::File.write(cache_file_path, data.to_yaml)
52
+ end
53
+
39
54
  def cache_file_path
40
55
  ::File.join(@context.cache_root, 'instances.yml')
41
56
  end
42
57
 
58
+ def pending_instance?(instance)
59
+ data = cached_instances_file_content
60
+ return false unless data[instance.logical]
61
+ return false unless data[instance.logical][:publish_state].is_a?(Hash)
62
+ data[instance.logical][:publish_state].any? do |_k, v|
63
+ ::EacLauncher::Publish::CheckResult.pending_status?(v)
64
+ end
65
+ end
66
+
43
67
  class CachedInstances
44
68
  def initialize(content)
45
69
  @content = content
@@ -8,10 +8,6 @@ module EacLauncher
8
8
 
9
9
  CHECKERS = %w[publish_remote_no_exist remote_equal remote_following local_following].freeze
10
10
 
11
- def initialize(instance)
12
- @instance = instance
13
- end
14
-
15
11
  protected
16
12
 
17
13
  def internal_check
@@ -61,7 +57,7 @@ module EacLauncher
61
57
  end
62
58
 
63
59
  def sgit_uncached
64
- ::EacLauncher::Git::Base.new(@instance.warped)
60
+ ::EacLauncher::Git::Base.new(instance.warped)
65
61
  end
66
62
 
67
63
  def publish
@@ -20,6 +20,8 @@ module EacLauncher
20
20
  def instances
21
21
  if options['--all']
22
22
  context.instances
23
+ elsif options['--pending']
24
+ context.pending_instances
23
25
  else
24
26
  options['<instance_path>'].map { |p| find_instance!(p) }
25
27
  end
@@ -1,6 +1,12 @@
1
1
  module EacLauncher
2
2
  module Publish
3
3
  class Base
4
+ attr_reader :instance
5
+
6
+ def initialize(instance)
7
+ @instance = instance
8
+ end
9
+
4
10
  def run
5
11
  s = check
6
12
  info("Check: #{s}")
@@ -9,6 +15,20 @@ module EacLauncher
9
15
  end
10
16
 
11
17
  def check
18
+ s = check_with_rescue
19
+ ::EacLauncher::Context.current.instance_manager.publish_state_set(
20
+ instance, stereotype.stereotype_name, s.status
21
+ )
22
+ s
23
+ end
24
+
25
+ private
26
+
27
+ def stereotype
28
+ self.class.name.deconstantize.constantize
29
+ end
30
+
31
+ def check_with_rescue
12
32
  internal_check
13
33
  rescue ::EacLauncher::Instances::Error => ex
14
34
  ::EacLauncher::Publish::CheckResult.blocked("Error: #{ex}")
@@ -16,6 +16,10 @@ module EacLauncher
16
16
  end
17
17
 
18
18
  class << self
19
+ def pending_status?(status)
20
+ [STATUS_PENDING, STATUS_BLOCKED].include?(status)
21
+ end
22
+
19
23
  def updated_color
20
24
  'green'
21
25
  end
@@ -5,10 +5,6 @@ module EacLauncher
5
5
  include ::Eac::SimpleCache
6
6
  include ::EacRubyUtils::Console::Speaker
7
7
 
8
- def initialize(instance)
9
- @instance = instance
10
- end
11
-
12
8
  protected
13
9
 
14
10
  def internal_check
@@ -55,7 +51,7 @@ module EacLauncher
55
51
  end
56
52
 
57
53
  def source_uncached
58
- @instance.warped
54
+ instance.warped
59
55
  end
60
56
 
61
57
  def gem_spec_uncached
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacLauncher
4
- VERSION = '0.4.0'.freeze
4
+ VERSION = '0.5.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-14 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport