eac_launcher 0.3.2 → 0.4.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
- SHA1:
3
- metadata.gz: cbf92881899793eadfed0da3d1f071b4c4e3ab2e
4
- data.tar.gz: 2b6b80b197ac17d6f8fe0dd10dddce9c06b15769
2
+ SHA256:
3
+ metadata.gz: 290a1a038cf1980ae1a6d85a3428f79f50acf5b86ce12bae24913be01c88636f
4
+ data.tar.gz: 03e46414c9e8e234f6165ae76d67880caf0e71ae4ffdb2256fd4d276f8f185f8
5
5
  SHA512:
6
- metadata.gz: 5d248573f77e07ffc6603bd99688cd9918c4700e04799ae81b97670440efe1152965a9b924d960f67369ca6792848d9b117f21f7c5d969f2f9a8f6049eb21aae
7
- data.tar.gz: c930ed45b92017191a9ec5fa96a93d1430742e69c77f06c948a0b162984ce8aba496068012848cdb4ab214cbb0574916f74af77de730a3443de8b0fbae277da8
6
+ metadata.gz: e6cd81ae0be28005ca445b19b5a5ea4daed91774975ac4c426ac468cafdbe8fc43171c7f20b956e85c9ff556753ef1e922dcdde79469ca446585d57fd1b129de
7
+ data.tar.gz: f7fab0d8008fb44cc760a6fc53090f65df1f235464126aad656834e88c9d00d315d5d57d4cbe0845e14caeade73e2813b647a2825552bf80d82160bd27442479
@@ -16,12 +16,14 @@ Usage:
16
16
  Options:
17
17
  -h --help Show this screen.
18
18
  --all Get all instances.
19
+ --recache Rewrite instances cache.
19
20
 
20
21
  DOCOPT
21
22
 
22
23
  private
23
24
 
24
25
  def run
26
+ ::EacLauncher::Context.current.recache = options['--recache']
25
27
  instances.each { |i| show_instance(i) }
26
28
  end
27
29
 
@@ -16,12 +16,14 @@ Usage:
16
16
  Options:
17
17
  -h --help Show this screen.
18
18
  -i --instances Show instances.
19
+ --recache Rewrite instances cache.
19
20
 
20
21
  DOCOPT
21
22
 
22
23
  private
23
24
 
24
25
  def run
26
+ ::EacLauncher::Context.current.recache = options['--recache']
25
27
  ::EacLauncher::Context.current.projects.each do |p|
26
28
  show_project(p)
27
29
  end
@@ -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
+ --recache Rewrite instances cache.
20
21
 
21
22
  DOCOPT
22
23
 
@@ -27,6 +28,7 @@ DOCOPT
27
28
  private
28
29
 
29
30
  def run
31
+ ::EacLauncher::Context.current.recache = options['--recache']
30
32
  build_publish_options
31
33
  instances.each do |i|
32
34
  next unless i.options.publishable?
data/lib/eac_launcher.rb CHANGED
@@ -8,6 +8,7 @@ require('eac/simple_cache')
8
8
  require('eac_ruby_utils')
9
9
  require('git')
10
10
  require('json')
11
+ require('ruby-progressbar')
11
12
  require('rubygems')
12
13
  require('shellwords')
13
14
  require('yaml')
@@ -21,6 +22,8 @@ module EacLauncher
21
22
  require 'eac_launcher/paths/real'
22
23
  require 'eac_launcher/project'
23
24
  require 'eac_launcher/stereotype'
25
+ require 'eac_launcher/context/instance_discovery'
26
+ require 'eac_launcher/context/instance_manager'
24
27
  require 'eac_launcher/context/settings'
25
28
  require 'eac_launcher/git/base'
26
29
  require 'eac_launcher/git/error'
@@ -20,20 +20,26 @@ module EacLauncher
20
20
  end
21
21
 
22
22
  attr_reader :root, :settings, :cache_root
23
- attr_accessor :publish_options
23
+ attr_accessor :publish_options, :recache
24
24
 
25
25
  def initialize(options = {})
26
26
  @options = options.with_indifferent_access
27
- @root = ::EacLauncher::Paths::Logical.new(nil, build_option(:projects_root), '/')
27
+ @root = ::EacLauncher::Paths::Logical.new(self, nil, build_option(:projects_root), '/')
28
28
  @settings = ::EacLauncher::Context::Settings.new(build_option(:settings_file))
29
29
  @cache_root = build_option(:cache_root)
30
30
  @publish_options = { new: false, confirm: false, stereotype: nil }
31
+ @instance_manager = ::EacLauncher::Context::InstanceManager.new(self)
32
+ @recache = false
31
33
  end
32
34
 
33
35
  def instance(name)
34
36
  instances.find { |i| i.name == name }
35
37
  end
36
38
 
39
+ def instances
40
+ @instance_manager.instances
41
+ end
42
+
37
43
  private
38
44
 
39
45
  def build_option(key)
@@ -56,29 +62,5 @@ module EacLauncher
56
62
  end
57
63
  r.map { |name, instances| ::EacLauncher::Project.new(name, instances) }
58
64
  end
59
-
60
- def instances_uncached
61
- path_instances(root, nil)
62
- end
63
-
64
- def path_instances(path, parent_instance)
65
- on_rescued_path_instances(path) do |r|
66
- if path.project?
67
- parent_instance = ::EacLauncher::Instances::Base.instanciate(path, self, parent_instance)
68
- r << path if path.included?
69
- end
70
- r.concat(path.children.flat_map { |c| path_instances(c, parent_instance) })
71
- end
72
- end
73
-
74
- def on_rescued_path_instances(path)
75
- r = []
76
- begin
77
- yield(r)
78
- rescue StandardError => ex
79
- warn("#{path}: #{ex}")
80
- end
81
- r
82
- end
83
65
  end
84
66
  end
@@ -0,0 +1,49 @@
1
+ module EacLauncher
2
+ class Context
3
+ class InstanceDiscovery
4
+ attr_reader :instances
5
+
6
+ def initialize(context)
7
+ @context = context
8
+ @progress = ::ProgressBar.create(title: 'Instance discovery', total: 1)
9
+ @instances = path_instances(@context.root, nil)
10
+ ensure
11
+ @progress.finish if @progress
12
+ end
13
+
14
+ private
15
+
16
+ def path_instances(path, parent_instance)
17
+ update_progress_format(path)
18
+ on_rescued_path_instances(path) do |r|
19
+ if path.project?
20
+ parent_instance = ::EacLauncher::Instances::Base.instanciate(path, parent_instance)
21
+ r << path
22
+ end
23
+ children = path.children
24
+ update_progress_count(children)
25
+ r.concat(children.flat_map { |c| path_instances(c, parent_instance) })
26
+ end
27
+ end
28
+
29
+ def on_rescued_path_instances(path)
30
+ r = []
31
+ begin
32
+ yield(r) if path.included?
33
+ rescue StandardError => ex
34
+ warn("#{path}: #{ex}")
35
+ end
36
+ r
37
+ end
38
+
39
+ def update_progress_format(path)
40
+ @progress.format = "%t (Paths: %c/%C, Current: #{path.logical}) |%B| %a"
41
+ end
42
+
43
+ def update_progress_count(children)
44
+ @progress.total += children.count
45
+ @progress.increment
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,63 @@
1
+ module EacLauncher
2
+ class Context
3
+ class InstanceManager
4
+ include ::Eac::SimpleCache
5
+
6
+ def initialize(context)
7
+ @context = context
8
+ end
9
+
10
+ private
11
+
12
+ def instances_uncached
13
+ (cached_instances ? cached_instances : search_instances).select(&:included?)
14
+ end
15
+
16
+ def search_instances
17
+ cache_instances(::EacLauncher::Context::InstanceDiscovery.new(@context).instances)
18
+ end
19
+
20
+ def cached_instances
21
+ return nil if @context.recache
22
+ return nil unless cached_instances_file_content
23
+ CachedInstances.new(cached_instances_file_content).instances
24
+ end
25
+
26
+ def cached_instances_file_content_uncached
27
+ r = YAML.load_file(cache_file_path)
28
+ r.is_a?(::Hash) ? r : nil
29
+ rescue Errno::ENOENT
30
+ nil
31
+ end
32
+
33
+ def cache_instances(instances)
34
+ r = Hash[instances.map { |i| [i.logical, i.to_h] }]
35
+ ::File.write(cache_file_path, r.to_yaml)
36
+ instances
37
+ end
38
+
39
+ def cache_file_path
40
+ ::File.join(@context.cache_root, 'instances.yml')
41
+ end
42
+
43
+ class CachedInstances
44
+ def initialize(content)
45
+ @content = content
46
+ @instances = {}
47
+ end
48
+
49
+ def instances
50
+ @content.keys.map { |k| by_logical_path(k) }
51
+ end
52
+
53
+ def by_logical_path(k)
54
+ return @instances[k] if @instances.key?(k)
55
+ h = @content[k]
56
+ parent_instance = h[:parent] ? by_logical_path(h[:parent]) : nil
57
+ path = ::EacLauncher::Paths::Logical.from_h(@context, h)
58
+ @instances[k] = ::EacLauncher::Instances::Base.instanciate(path, parent_instance)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -17,6 +17,10 @@ module EacLauncher
17
17
  enum_value(%w[Projects Exclude])
18
18
  end
19
19
 
20
+ def excluded_paths_uncached
21
+ enum_value(%w[Paths Exclude])
22
+ end
23
+
20
24
  def enum_value(path)
21
25
  r = value(path)
22
26
  r.is_a?(Enumerable) ? r : []
@@ -11,18 +11,17 @@ module EacLauncher
11
11
  super
12
12
  end
13
13
 
14
- def instanciate(path, context, parent)
14
+ def instanciate(path, parent)
15
15
  unless path.is_a?(::EacLauncher::Instances::Base)
16
16
  raise "#{path} is not a project" unless path.project?
17
17
  path.extend(::EacLauncher::Instances::Base)
18
- path.context = context
19
18
  path.parent = parent
20
19
  end
21
20
  path
22
21
  end
23
22
  end
24
23
 
25
- attr_accessor :context, :parent
24
+ attr_accessor :parent
26
25
 
27
26
  def name
28
27
  logical
@@ -65,6 +64,10 @@ module EacLauncher
65
64
  !::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
66
65
  end
67
66
 
67
+ def to_h
68
+ super.to_h.merge(parent: parent ? parent.logical : nil)
69
+ end
70
+
68
71
  private
69
72
 
70
73
  def publish?(stereotype)
@@ -5,9 +5,17 @@ module EacLauncher
5
5
  class Logical
6
6
  include ::Eac::SimpleCache
7
7
 
8
- attr_reader :real, :logical, :parent_path
8
+ class << self
9
+ def from_h(context, h)
10
+ parent_path = h[:parent_path] ? from_h(context, h[:parent_path]) : nil
11
+ new(context, parent_path, h[:real], h[:logical])
12
+ end
13
+ end
9
14
 
10
- def initialize(parent_path, real, logical)
15
+ attr_reader :context, :real, :logical, :parent_path
16
+
17
+ def initialize(context, parent_path, real, logical)
18
+ @context = context
11
19
  @parent_path = parent_path
12
20
  @real = ::EacLauncher::Paths::Real.new(real)
13
21
  @logical = logical
@@ -17,6 +25,10 @@ module EacLauncher
17
25
  logical
18
26
  end
19
27
 
28
+ def to_h
29
+ { logical: logical, real: real.to_s, parent_path: parent_path ? parent_path.to_h : nil }
30
+ end
31
+
20
32
  def project?
21
33
  stereotypes.any?
22
34
  end
@@ -32,6 +44,10 @@ module EacLauncher
32
44
  r
33
45
  end
34
46
 
47
+ def included?
48
+ !context.settings.excluded_paths.include?(logical)
49
+ end
50
+
35
51
  private
36
52
 
37
53
  def stereotypes_uncached
@@ -40,6 +56,7 @@ module EacLauncher
40
56
 
41
57
  def build_child(name)
42
58
  ::EacLauncher::Paths::Logical.new(
59
+ context,
43
60
  self,
44
61
  ::File.join(warped, name),
45
62
  ::File.join(logical, name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacLauncher
4
- VERSION = '0.3.2'.freeze
4
+ VERSION = '0.4.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.3.2
4
+ version: 0.4.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: 2018-05-27 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -85,6 +85,9 @@ dependencies:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0.1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.1.2
88
91
  type: :runtime
89
92
  prerelease: false
90
93
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,6 +95,9 @@ dependencies:
92
95
  - - "~>"
93
96
  - !ruby/object:Gem::Version
94
97
  version: '0.1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 0.1.2
95
101
  - !ruby/object:Gem::Dependency
96
102
  name: git
97
103
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +112,20 @@ dependencies:
106
112
  - - "~>"
107
113
  - !ruby/object:Gem::Version
108
114
  version: 1.3.0
115
+ - !ruby/object:Gem::Dependency
116
+ name: ruby-progressbar
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
109
129
  - !ruby/object:Gem::Dependency
110
130
  name: rspec
111
131
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +170,8 @@ files:
150
170
  - exe/eac_launcher_publish
151
171
  - lib/eac_launcher.rb
152
172
  - lib/eac_launcher/context.rb
173
+ - lib/eac_launcher/context/instance_discovery.rb
174
+ - lib/eac_launcher/context/instance_manager.rb
153
175
  - lib/eac_launcher/context/settings.rb
154
176
  - lib/eac_launcher/git/base.rb
155
177
  - lib/eac_launcher/git/base/subrepo.rb
@@ -391,7 +413,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
413
  version: '0'
392
414
  requirements: []
393
415
  rubyforge_project:
394
- rubygems_version: 2.6.14
416
+ rubygems_version: 2.7.7
395
417
  signing_key:
396
418
  specification_version: 4
397
419
  summary: Utilities to deploy applications and libraries.