eac_launcher 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: e37ffc318f78eed70edcee0ed1ebca08bd89b2bd
4
- data.tar.gz: 5d74edb3dcaa1aea513d07dc4e2e2fa31c32ec76
3
+ metadata.gz: 380d1f61d80e539cc654af9001183f3de43c5456
4
+ data.tar.gz: 12c85fabb456c5aeb4544a374cefbc469dc6c916
5
5
  SHA512:
6
- metadata.gz: 6b315365e92517c172dcd3072f26253908ae2b9103963e7d74caf1be4e3ee37ac62953c3c1ee79a9bf0c29626fef233cd784a760e96ceca1d317489ca276b13f
7
- data.tar.gz: b5c31a49522e094d1c23ba613e4eb10d840b30a8e02815413bb565b1542af95ea9743ee43f724ba4919a1838704622123b40f42bb0e7bfcbbcf17ba5957ee226
6
+ metadata.gz: 4949dcf967347ccb56f4f50f3185bf35911bbe70c96592134d9894bffac708ea53454e6a416ac6387e1afd07b34b27e58f8a4519508a3f84362e63c59cc2949a
7
+ data.tar.gz: 3742a103c667b7fb5cc7e38047420eacf91261decb58ca798a03a9dde37a64d5ab1e948281c198d030a4e82ae239af2adc438fc0fdc07c200fab2c08723f40cd
@@ -23,10 +23,13 @@ module EacLauncher
23
23
  require 'eac_launcher/git/publish_base'
24
24
  require 'eac_launcher/git/warp_base'
25
25
  require 'eac_launcher/instances/base'
26
+ require 'eac_launcher/instances/error'
26
27
  require 'eac_launcher/instances/runner_helper'
27
28
  require 'eac_launcher/instances/settings'
28
29
  require 'eac_launcher/publish/base'
29
30
  require 'eac_launcher/publish/check_result'
31
+ require 'eac_launcher/ruby/gem/build'
32
+ require 'eac_launcher/ruby/gem/specification'
30
33
  require 'eac_launcher/stereotypes/git'
31
34
  require 'eac_launcher/stereotypes/git_subrepo'
32
35
  require 'eac_launcher/stereotypes/git_subtree'
@@ -10,7 +10,9 @@ module EacLauncher
10
10
  @instance = instance
11
11
  end
12
12
 
13
- def check
13
+ protected
14
+
15
+ def internal_check
14
16
  if publish_remote_no_exist?
15
17
  ::EacLauncher::Publish::CheckResult.blocked('Remote does not exist')
16
18
  elsif remote_equal_or_following?
@@ -63,8 +63,8 @@ module EacLauncher
63
63
  stereotypes.each do |s|
64
64
  return s.warp_class.new(self) if s.warp_class
65
65
  end
66
- raise "None stereotype of \"#{to_root_path}\" has subclass \"CurrentCache\" " \
67
- "(#{stereotypes.join(', ')})"
66
+ raise ::EacLauncher::Instances::Error, "None stereotype of \"#{to_root_path}\" has " \
67
+ "subclass \"CurrentCache\" (#{stereotypes.join(', ')})"
68
68
  end
69
69
 
70
70
  private
@@ -0,0 +1,6 @@
1
+ module EacLauncher
2
+ module Instances
3
+ class Error < StandardError
4
+ end
5
+ end
6
+ end
@@ -11,7 +11,7 @@ module EacLauncher
11
11
  def find_file_with_extension(extension)
12
12
  r = find_files_with_extension(extension)
13
13
  return r.first if r.any?
14
- raise "Extension \"#{extension}\" not found in directory \"#{directory}\""
14
+ raise "Extension \"#{extension}\" not found in directory \"#{self}\""
15
15
  end
16
16
 
17
17
  def find_files_with_extension(extension)
@@ -7,6 +7,12 @@ module EacLauncher
7
7
  return unless s.status == ::EacLauncher::Publish::CheckResult::STATUS_PENDING
8
8
  publish
9
9
  end
10
+
11
+ def check
12
+ internal_check
13
+ rescue ::EacLauncher::Instances::Error => ex
14
+ ::EacLauncher::Publish::CheckResult.blocked("Error: #{ex}")
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -0,0 +1,75 @@
1
+ module EacLauncher
2
+ module Ruby
3
+ module Gem
4
+ class Build
5
+ include ::EacRubyUtils::Console::Speaker
6
+
7
+ def initialize(original_gem_root)
8
+ @original_gem_root = original_gem_root
9
+ end
10
+
11
+ def output_file
12
+ return nil unless @gem_root
13
+ @gem_root.find_files_with_extension('.gem').first
14
+ end
15
+
16
+ def builded?
17
+ output_file.present? && ::File.exist?(output_file)
18
+ end
19
+
20
+ def build
21
+ return if builded?
22
+ copy_gem_files
23
+ build_gem
24
+ check_gem
25
+ end
26
+
27
+ def close
28
+ ::FileUtils.remove_entry(@gem_root) if ::File.directory?(@gem_root)
29
+ @gem_root = nil
30
+ end
31
+
32
+ private
33
+
34
+ def copy_gem_files
35
+ @gem_root = ::EacLauncher::Path.new(::Dir.mktmpdir)
36
+ FileUtils.cp_r "#{@original_gem_root}/.", @gem_root
37
+ end
38
+
39
+ def build_gem
40
+ info("Building gemspec #{gemspec_file}...")
41
+ clear_gems
42
+ Dir.chdir @gem_root do
43
+ EacRubyUtils::Envs.local.command('gem', 'build', gemspec_file).execute!
44
+ end
45
+ end
46
+
47
+ def check_gem
48
+ Dir.mktmpdir do |dir|
49
+ Dir.chdir dir do
50
+ EacRubyUtils::Envs.local.command('gem', 'unpack', gem).system
51
+ gs = File.join(dir, File.basename(gem, '.gem'))
52
+ if (Dir.entries(gs) - %w[. ..]).empty?
53
+ raise "\"#{dir}\" (Unpacked from #{gem}) has no source code"
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ def clear_gems
60
+ @gem_root.find_files_with_extension('.gem').each do |f|
61
+ FileUtils.rm_rf(f)
62
+ end
63
+ end
64
+
65
+ def gemspec_file
66
+ @gem_root.find_file_with_extension('.gemspec')
67
+ end
68
+
69
+ def gem
70
+ @gem_root.find_file_with_extension('.gem')
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,47 @@
1
+ module EacLauncher
2
+ module Ruby
3
+ module Gem
4
+ class Specification
5
+ class << self
6
+ def parse_version_file(file)
7
+ s = ::File.read(file)
8
+ m = /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.match(s)
9
+ m ? m[1] : nil
10
+ end
11
+ end
12
+
13
+ attr_reader :gemspec_file
14
+
15
+ def initialize(gemspec_file)
16
+ @gemspec_file = gemspec_file
17
+ end
18
+
19
+ def version
20
+ v = self.class.parse_version_file(version_file)
21
+ return v if v.present?
22
+ raise "Version not found on file \"#{version_file}\""
23
+ end
24
+
25
+ def name
26
+ ::File.basename(gemspec_file).gsub(/\.gemspec\z/, '')
27
+ end
28
+
29
+ def full_name
30
+ "#{name}-#{version}"
31
+ end
32
+
33
+ private
34
+
35
+ def gem_root
36
+ ::File.dirname(gemspec_file)
37
+ end
38
+
39
+ def version_file
40
+ f = ::File.join(gem_root, 'lib', name, 'version.rb')
41
+ return f if ::File.exist?(f)
42
+ raise "Version file \"#{f}\" does not exist"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -20,9 +20,10 @@ module EacLauncher
20
20
  private
21
21
 
22
22
  def check_parent
23
- return if parent_cache_git.descendant?('HEAD', subrepo_parent_hash)
24
- raise "Subrepo parent hash \"#{subrepo_parent_hash}\" not found in " \
25
- "\"#{parent_cache_git}\""
23
+ return if parent_cache_git.rev_parse(subrepo_parent_hash) &&
24
+ parent_cache_git.descendant?('HEAD', subrepo_parent_hash)
25
+ raise EacLauncher::Instances::Error, "Subrepo parent hash \"#{subrepo_parent_hash}\""\
26
+ " not found in \"#{parent_cache_git}\""
26
27
  end
27
28
 
28
29
  def subrepo_parent_hash
@@ -12,8 +12,8 @@ module EacLauncher
12
12
  :red
13
13
  end
14
14
 
15
- def load_gemspec(file)
16
- ::Gem::Specification.load(file)
15
+ def load_gemspec(gemspec_file)
16
+ ::EacLauncher::Ruby::Gem::Specification.new(gemspec_file)
17
17
  end
18
18
  end
19
19
  end
@@ -6,10 +6,12 @@ module EacLauncher
6
6
  include ::EacRubyUtils::Console::Speaker
7
7
 
8
8
  def initialize(instance)
9
- @source = instance.current_cache
9
+ @instance = instance
10
10
  end
11
11
 
12
- def check
12
+ protected
13
+
14
+ def internal_check
13
15
  if new_and_unpublishing_new?
14
16
  ::EacLauncher::Publish::CheckResult.blocked(
15
17
  "#{gem_spec.full_name} does not exist in RubyGems"
@@ -24,17 +26,23 @@ module EacLauncher
24
26
 
25
27
  private
26
28
 
29
+ def source_uncached
30
+ @instance.current_cache
31
+ end
32
+
27
33
  def gem_spec_uncached
28
34
  ::EacLauncher::Stereotypes::RubyGem.load_gemspec(gemspec)
29
35
  end
30
36
 
37
+ def gem_build_uncached
38
+ ::EacLauncher::Ruby::Gem::Build.new(source)
39
+ end
40
+
31
41
  def publish
32
- Dir.mktmpdir do |dir|
33
- @tempdir = ::EacLauncher::Path.new(dir)
34
- build_gem
35
- check_gem
36
- push_gem
37
- end
42
+ gem_build.open
43
+ push_gem
44
+ ensure
45
+ gem_build.close
38
46
  end
39
47
 
40
48
  def new_and_unpublishing_new?
@@ -46,7 +54,7 @@ module EacLauncher
46
54
  end
47
55
 
48
56
  def version_already_pushed?
49
- gem_versions.any? { |v| v['number'] == gem_spec.version.version }
57
+ gem_versions.any? { |v| v['number'] == gem_spec.version }
50
58
  end
51
59
 
52
60
  def gem_versions_uncached
@@ -56,36 +64,6 @@ module EacLauncher
56
64
  raise "#{http} code error: #{http.status}"
57
65
  end
58
66
 
59
- def build_gem
60
- info("Building gem #{gem_spec}...")
61
- clear_gems
62
- Dir.chdir @source do
63
- EacRubyUtils::Envs.local.command('gem', 'build', gemspec).system
64
- end
65
- source = @source.find_file_with_extension('.gem')
66
- FileUtils.mv(source, File.join(@tempdir, File.basename(source)))
67
- ensure
68
- clear_gems
69
- end
70
-
71
- def clear_gems
72
- @source.find_files_with_extension('.gem').each do |f|
73
- FileUtils.rm_rf(f)
74
- end
75
- end
76
-
77
- def check_gem
78
- Dir.mktmpdir do |dir|
79
- Dir.chdir dir do
80
- EacRubyUtils::Envs.local.command('gem', 'unpack', gem).system
81
- gs = File.join(dir, File.basename(gem, '.gem'))
82
- if (Dir.entries(gs) - %w[. ..]).empty?
83
- raise "\"#{dir}\" (Unpacked from #{gem}) has no source code"
84
- end
85
- end
86
- end
87
- end
88
-
89
67
  def push_gem
90
68
  info("Pushing gem #{gem_spec}...")
91
69
  if ::EacLauncher::Context.current.publish_options[:confirm]
@@ -97,11 +75,7 @@ module EacLauncher
97
75
  end
98
76
 
99
77
  def gemspec_uncached
100
- @source.find_file_with_extension('.gemspec')
101
- end
102
-
103
- def gem
104
- @tempdir.find_file_with_extension('.gem')
78
+ source.find_file_with_extension('.gemspec')
105
79
  end
106
80
  end
107
81
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacLauncher
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.3'.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.1.2
4
+ version: 0.1.3
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-04-06 00:00:00.000000000 Z
11
+ date: 2018-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: 1.3.0
109
+ - !ruby/object:Gem::Dependency
110
+ name: rspec
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '3.7'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '3.7'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: rubocop
111
125
  requirement: !ruby/object:Gem::Requirement
@@ -145,12 +159,15 @@ files:
145
159
  - lib/eac_launcher/git/warp_base.rb
146
160
  - lib/eac_launcher/instances/base.rb
147
161
  - lib/eac_launcher/instances/base/cache.rb
162
+ - lib/eac_launcher/instances/error.rb
148
163
  - lib/eac_launcher/instances/runner_helper.rb
149
164
  - lib/eac_launcher/instances/settings.rb
150
165
  - lib/eac_launcher/path.rb
151
166
  - lib/eac_launcher/project.rb
152
167
  - lib/eac_launcher/publish/base.rb
153
168
  - lib/eac_launcher/publish/check_result.rb
169
+ - lib/eac_launcher/ruby/gem/build.rb
170
+ - lib/eac_launcher/ruby/gem/specification.rb
154
171
  - lib/eac_launcher/stereotype.rb
155
172
  - lib/eac_launcher/stereotypes/git.rb
156
173
  - lib/eac_launcher/stereotypes/git/publish.rb