avm-eac_ruby_base1 0.5.0 → 0.6.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: de35d5fa535fdc0c796068eba1e0bdafd96ea2424b05cc1136b9280fdbcf9ab4
4
- data.tar.gz: b634b46d9b404a31b5706c6e465c73247d7cf6bec81d8dfd9beccf461813316f
3
+ metadata.gz: ae50465c6257b0c96caed1eeadc4d7879294952f52a3e8b4fc0cbfb3dbc9408b
4
+ data.tar.gz: 1d76ec909ab0216c8f5759eae08d3ea4e1ea49fe6cd708bb5796fd0b97768179
5
5
  SHA512:
6
- metadata.gz: a3def674b0a551e351553972503cc401b21b81c08cacb8b9fb5dd8de35cd1029d5668346e1ec589bf54adc8579c46af8db630a75f8a0d441c8519693ca2d40cf
7
- data.tar.gz: 206b8b7f43ea1150a2a52a4e4789cd64e89306241961ed5ab3610ffaf4034f60f97acee70c5318f49b75076f9fc82022510c3028166bfe2b741abf52d8c24284
6
+ metadata.gz: 81dba51b5ab1af1c389933de54316315c7af93a2b473a977a9f9f2b1c9522aeb6cbbf7ad6214b3873e0137c5534f0760e20a23d3a854abd19a376e332ab1805d
7
+ data.tar.gz: 0d3fea5b073cf33e07c76427d76112754832bd3c89cb1328e71bb8f09502cbdcffbf40f313fe5dadd13fd24a60c0f32bfe2897e52d6c016a302d927ed0ff2c8b
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ class Gemfile
9
+ class AddOrReplaceGemLine
10
+ enable_method_class
11
+ common_constructor :sender, :gem_name, :gem_specs
12
+ delegate :lines, to: :sender
13
+
14
+ def existing_gem_line_index
15
+ lines.index { |line| line.start_with?(gem_line_prefix) }
16
+ end
17
+
18
+ def result
19
+ if existing_gem_line_index.present?
20
+ replace_line
21
+ else
22
+ add_line
23
+ end
24
+ end
25
+
26
+ def add_line
27
+ lines.insert(add_line_index, new_gem_line)
28
+ end
29
+
30
+ def add_line_index
31
+ (gems_lines_start_index..(lines.count - 1)).each do |e|
32
+ return e if new_gem_line < lines[e]
33
+ end
34
+ lines.count
35
+ end
36
+
37
+ def gems_lines_start_index
38
+ lines.index { |line| line.start_with?('gem ') } || lines.count
39
+ end
40
+
41
+ def new_gem_line
42
+ ([gem_line_prefix] + gem_specs).join(', ')
43
+ end
44
+
45
+ def gem_line_prefix
46
+ "gem '#{gem_name}'"
47
+ end
48
+
49
+ def replace_line
50
+ lines[existing_gem_line_index] = new_gem_line
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ class Gemfile
9
+ class Dependency
10
+ common_constructor :gemfile, :gem_name
11
+
12
+ def version_specs=(version_specs)
13
+ gemfile.add_or_replace_gem_line(gem_name, version_specs)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ class Gemfile
9
+ require_sub __FILE__, require_dependency: true
10
+
11
+ class << self
12
+ def from_file(path)
13
+ new(path.read.each_line.map(&:rstrip))
14
+ end
15
+ end
16
+
17
+ common_constructor :lines
18
+
19
+ # @return [Avm::EacRubyBase1::Bundler::Gemfile::Dependency]
20
+ def dependency(gem_name)
21
+ ::Avm::EacRubyBase1::Bundler::Gemfile::Dependency.new(self, gem_name)
22
+ end
23
+
24
+ def write(path)
25
+ path.to_pathname.write(to_text)
26
+ end
27
+
28
+ def to_text
29
+ lines.map { |line| "#{line}\n" }.join
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-eac_ruby_base1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-14 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -93,6 +93,10 @@ extensions: []
93
93
  extra_rdoc_files: []
94
94
  files:
95
95
  - lib/avm/eac_ruby_base1.rb
96
+ - lib/avm/eac_ruby_base1/bundler.rb
97
+ - lib/avm/eac_ruby_base1/bundler/gemfile.rb
98
+ - lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb
99
+ - lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb
96
100
  - lib/avm/eac_ruby_base1/rubocop.rb
97
101
  - lib/avm/eac_ruby_base1/rubocop/configured.rb
98
102
  - lib/avm/eac_ruby_base1/rubocop/envvar.rb