diffend 0.2.18 → 0.2.19

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: a0a5718a6d7b90225e8a9d3dd8aff55c3bc8e84dced09b84f6a575a4decf002f
4
- data.tar.gz: '006843f27693e587008b3bf25676203050329460814e9f94ffd6f4af1cc4a8df'
3
+ metadata.gz: 0f18edf14b16e7f2ec3ce0c574ade976e78e3eac84f8395e45fc53595a8e3f91
4
+ data.tar.gz: 292e755dac0d191787b77fb8556b5e2f90f9e040ee9e28486de90601b2c2a67c
5
5
  SHA512:
6
- metadata.gz: 6040014adc4dac35c1f42fd663c5ad95a96a5b68e5b4591387c9be4d91840312ed1b8c4fe9fab17f6c410b225b11c31236f66bb131986c09d0f28538ac2e6ea7
7
- data.tar.gz: bf93737d117bc09a8fc9698b9b431459f6805dd4c4a35757d3a1c8e1a02c442cf53a2a782008349342a09faa6cf8659e7ceddcd128ba73c4c9665cfb41f13c42
6
+ metadata.gz: 73326da64425debc8c27ad1dd216df34313a45795a2c6f555d0e5df067dfc17977ae9ee6e8307ab1df33af58a87ca23511ed3920eaa9c0bcec566fef602c30c3
7
+ data.tar.gz: eabf666e6c1ef7a08afaadf519011edac2416f0a2fa13152a9112b898b94dde1f598f23866a9823220be308aa091d9dab6b6d03e95191f3d22ba43509d3933fa
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -3,6 +3,7 @@ name: ci
3
3
  jobs:
4
4
  specs:
5
5
  runs-on: ubuntu-latest
6
+
6
7
  strategy:
7
8
  fail-fast: false
8
9
  matrix:
@@ -11,8 +12,15 @@ jobs:
11
12
  include:
12
13
  - ruby: '2.7'
13
14
  coverage: 'true'
15
+
14
16
  steps:
15
17
  - uses: actions/checkout@v2
18
+ - uses: actions/cache@v2
19
+ with:
20
+ path: vendor/bundle
21
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
22
+ restore-keys: |
23
+ ${{ runner.os }}-gems-
16
24
  - name: Install package dependencies
17
25
  run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
18
26
  - name: Set up Ruby
@@ -22,10 +30,9 @@ jobs:
22
30
  - name: Install latest bundler
23
31
  run: |
24
32
  gem install bundler --no-document
25
- bundle config set without 'tools benchmarks docs'
26
33
  - name: Bundle install
27
34
  run: |
28
- bundle config set without development
35
+ bundle config path vendor/bundle
29
36
  bundle install --jobs 4 --retry 3
30
37
  - name: Run all tests
31
38
  env:
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased][master]
4
4
 
5
+ ## [0.2.19] (2020-08-18)
6
+
7
+ - better detection of gem sources ([#13](https://github.com/diffend-io/diffend-ruby/pull/13))
8
+
5
9
  ## [0.2.18] (2020-08-05)
6
10
 
7
11
  - use `Etc.getpwuid` instead of `Etc.getlogin` for fetching host user ([#11](https://github.com/diffend-io/diffend-ruby/pull/11))
@@ -18,6 +22,8 @@
18
22
 
19
23
  - initial release
20
24
 
21
- [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.17...HEAD
25
+ [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.19...HEAD
26
+ [0.2.19]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.18...v0.2.19
27
+ [0.2.18]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.17...v0.2.18
22
28
  [0.2.17]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.16...v0.2.17
23
29
  [0.2.16]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.15...v0.2.16
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diffend (0.2.18)
4
+ diffend (0.2.19)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
File without changes
@@ -22,7 +22,7 @@
22
22
  # Diffend main namespace
23
23
  module Diffend
24
24
  # Current plugin version
25
- VERSION = '0.2.18'
25
+ VERSION = '0.2.19'
26
26
  # Diffend homepage
27
27
  HOMEPAGE = 'https://diffend.io'
28
28
 
@@ -13,17 +13,22 @@ module Diffend
13
13
  Bundler::Source::Gemspec,
14
14
  Bundler::Source::Path
15
15
  ].freeze
16
- DEPENDENCIES = {
16
+ # List of dependency types
17
+ DEPENDENCIES_TYPES = {
17
18
  direct: 0,
18
- dep: 1
19
+ dependency: 1
19
20
  }.freeze
20
- SOURCES = {
21
+ # List of sources types
22
+ SOURCES_TYPES = {
21
23
  valid: 0,
22
24
  multiple_primary: 1
23
25
  }.freeze
24
- GEM_SOURCES = {
26
+ # List of gem sources types
27
+ GEM_SOURCES_TYPES = {
25
28
  local: 0,
26
- gemfile: 1
29
+ gemfile_source: 1,
30
+ gemfile_git: 2,
31
+ gemfile_path: 3
27
32
  }.freeze
28
33
 
29
34
  class << self
@@ -54,6 +59,9 @@ module Diffend
54
59
  @locked_specs = @definition.locked_gems ? @definition.locked_gems.specs : []
55
60
  end
56
61
 
62
+ # Build install specification
63
+ #
64
+ # @return [Hash]
57
65
  def build_install
58
66
  hash = build_main
59
67
 
@@ -75,7 +83,9 @@ module Diffend
75
83
  hash
76
84
  end
77
85
 
78
- # @param definition [Bundler::Definition] definition for your source
86
+ # Build update specification
87
+ #
88
+ # @return [Hash]
79
89
  def build_update
80
90
  hash = build_main
81
91
 
@@ -97,6 +107,9 @@ module Diffend
97
107
 
98
108
  private
99
109
 
110
+ # Build default specification
111
+ #
112
+ # @return [Hash]
100
113
  def build_main
101
114
  {
102
115
  'dependencies' => {},
@@ -106,6 +119,12 @@ module Diffend
106
119
  }
107
120
  end
108
121
 
122
+ # Build gem versions
123
+ #
124
+ # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
125
+ # @param locked_spec [Bundler::LazySpecification, Gem::Specification, NilClass]
126
+ #
127
+ # @return [Array<String>]
109
128
  def build_versions(spec, locked_spec = nil)
110
129
  locked_spec ? [locked_spec.version.to_s, spec.version.to_s] : [spec.version.to_s]
111
130
  end
@@ -115,45 +134,105 @@ module Diffend
115
134
  #
116
135
  # @return [Boolean] dependency type
117
136
  def build_dependency_type(name)
118
- @direct_dependencies.key?(name) ? DEPENDENCIES[:direct] : DEPENDENCIES[:dep]
137
+ if @direct_dependencies.key?(name)
138
+ DEPENDENCIES_TYPES[:direct]
139
+ else
140
+ DEPENDENCIES_TYPES[:dependency]
141
+ end
119
142
  end
120
143
 
144
+ # Build gem platform
145
+ #
146
+ # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
147
+ #
148
+ # @return [String]
121
149
  def build_spec_platform(spec)
122
150
  spec.platform || spec.send(:generic_local_platform)
123
151
  end
124
152
 
153
+ # Build gem source type
154
+ #
155
+ # @param source [Bundler::Source] gem source type
156
+ #
157
+ # @return [Integer] internal gem source type
158
+ def build_spec_gem_source_type(source)
159
+ case source
160
+ when Bundler::Source::Metadata
161
+ GEM_SOURCES_TYPES[:local]
162
+ when Bundler::Source::Rubygems
163
+ GEM_SOURCES_TYPES[:gemfile_source]
164
+ when Bundler::Source::Git
165
+ GEM_SOURCES_TYPES[:gemfile_git]
166
+ when Bundler::Source::Path
167
+ GEM_SOURCES_TYPES[:gemfile_path]
168
+ else
169
+ raise ArgumentError, "unknown source #{source.class}"
170
+ end
171
+ end
172
+
173
+ # Build gem source
174
+ #
175
+ # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
176
+ #
177
+ # @return [Hash]
125
178
  def build_spec_source(spec)
126
- if @direct_dependencies.key?(spec.name)
127
- dep_spec = @direct_dependencies[spec.name]
179
+ source = source_for_spec(spec)
128
180
 
129
- if dep_spec.source
130
- { 'type' => GEM_SOURCES[:gemfile], 'url' => source_name_from_source(dep_spec.source) }
131
- else
132
- { 'type' => GEM_SOURCES[:gemfile], 'url' => source_name_from_source(@main_source) }
133
- end
181
+ {
182
+ 'type' => build_spec_gem_source_type(source),
183
+ 'value' => source_name_from_source(source)
184
+ }
185
+ end
186
+
187
+ # Figure out source for gem
188
+ #
189
+ # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
190
+ #
191
+ # @return [Bundler::Source] gem source type
192
+ def source_for_spec(spec)
193
+ if @direct_dependencies.key?(spec.name)
194
+ @direct_dependencies[spec.name].source || @main_source
134
195
  else
135
- if spec.source.respond_to?(:remotes)
136
- { 'type' => GEM_SOURCES[:gemfile], 'url' => source_name_from_source(spec.source) }
137
- else
138
- { 'type' => GEM_SOURCES[:local], 'url' => '' }
139
- end
196
+ spec.source
140
197
  end
141
198
  end
142
199
 
200
+ # Build gem source name
201
+ #
202
+ # @param source [Bundler::Source] gem source type
203
+ #
204
+ # @return [String]
143
205
  def source_name_from_source(source)
144
- source_name(source.remotes.first)
206
+ case source
207
+ when Bundler::Source::Metadata
208
+ ''
209
+ when Bundler::Source::Rubygems
210
+ source_name(source.remotes.first)
211
+ when Bundler::Source::Git
212
+ source.uri
213
+ when Bundler::Source::Path
214
+ source.path
215
+ else
216
+ raise ArgumentError, "unknown source #{source.class}"
217
+ end
145
218
  end
146
219
 
220
+ # @param name [Bundler::URI]
221
+ #
222
+ # @return [String] cleaned source name
147
223
  def source_name(name)
148
224
  name.to_s[0...-1]
149
225
  end
150
226
 
227
+ # Build sources used in the Gemfile
228
+ #
229
+ # @return [Array<Hash>]
151
230
  def build_sources
152
231
  sources = @definition.send(:sources).rubygems_sources
153
232
  hash = []
154
233
 
155
234
  sources.each do |source|
156
- type = source.remotes.count > 1 ? SOURCES[:multiple_primary] : SOURCES[:valid]
235
+ type = build_source_type(source.remotes)
157
236
 
158
237
  source.remotes.each do |src|
159
238
  hash << { 'name' => source_name(src), 'type' => type }
@@ -163,30 +242,29 @@ module Diffend
163
242
  hash
164
243
  end
165
244
 
245
+ # Build gem source type
246
+ #
247
+ # @param remotes [Array<Bundler::URI>]
248
+ #
249
+ # @return [Integer] internal source type
250
+ def build_source_type(remotes)
251
+ remotes.count > 1 ? SOURCES_TYPES[:multiple_primary] : SOURCES_TYPES[:valid]
252
+ end
253
+
166
254
  # Checks if we should skip a source
167
255
  #
168
- # @param source [Bundler::Source::Git, Bundler::Source::Rubygems]
256
+ # @param source [Bundler::Source] gem source type
169
257
  #
170
258
  # @return [Boolean] true if we should skip this source, false otherwise
171
259
  def skip?(source)
172
- return true if git?(source)
173
260
  return true if me?(source)
174
261
 
175
262
  false
176
263
  end
177
264
 
178
- # Checks if it's a git source
179
- #
180
- # @param source [Bundler::Source::Git, Bundler::Source::Rubygems]
181
- #
182
- # @return [Boolean] true if it's a git source, false otherwise
183
- def git?(source)
184
- source.instance_of?(Bundler::Source::Git)
185
- end
186
-
187
265
  # Checks if it's a self source, this happens for repositories that are a gem
188
266
  #
189
- # @param source [Bundler::Source::Path,Bundler::Source::Git,Bundler::Source::Rubygems]
267
+ # @param source [Bundler::Source] gem source type
190
268
  #
191
269
  # @return [Boolean] true if it's a self source, false otherwise
192
270
  def me?(source)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Pajor
@@ -34,7 +34,7 @@ cert_chain:
34
34
  9MmF6uCQa1EjK2p8tYT0MnbHrFkoehxdX4VO9y99GAkhZyJNKPYPtyAUFV27sT2V
35
35
  LfCJRk4ifKIN/FUCwDSn8Cz0m6oH265q0p6wdzI6qrWOjP8tGOMBTA==
36
36
  -----END CERTIFICATE-----
37
- date: 2020-08-05 00:00:00.000000000 Z
37
+ date: 2020-08-18 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: bundler
@@ -80,7 +80,7 @@ files:
80
80
  - CHANGELOG.md
81
81
  - Gemfile
82
82
  - Gemfile.lock
83
- - LICENSE
83
+ - LICENSE.md
84
84
  - README.md
85
85
  - bin/bundle
86
86
  - bin/byebug
metadata.gz.sig CHANGED
Binary file