virtual_gem 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +117 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/virtual_gem.rb +120 -0
- data/lib/virtual_gem/bundler/lock_file_parser.rb +12 -0
- data/lib/virtual_gem/gem/specification.rb +26 -0
- data/lib/virtual_gem/version.rb +3 -0
- data/lib/virtual_gem/virtual_gem_info.rb +11 -0
- data/virtual_gem.gemspec +28 -0
- metadata +118 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 449164632a423d0f6a5e1c1a7a7613508dd8a6fe6edbc22d46587eada1d44757
|
|
4
|
+
data.tar.gz: e17416dadc02ea2338c51d4fb1d31ad9c05a0906328ebd0ea71e1f250ee4d8ea
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f747a6908cebc74636739666cb29491365061360666e1b741b7330eb782f441cccacd34d4db174a2f89e10d5c78ae488e14fdb020a57398f35626b7cefe7bd48
|
|
7
|
+
data.tar.gz: 9a8ce076ed944e1584cccde6ec611e7752988cb809650b8c51b2841ffb18e4bac06b2a5bb9d1168dac11014a4cf067059efce63a4db88b05611c31fbb909d4cf
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at ota42y@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
virtual_gem (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.0)
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
fincop (0.53.0.1)
|
|
12
|
+
rubocop (>= 0.53.0)
|
|
13
|
+
rubocop-rspec (>= 1.22.0)
|
|
14
|
+
parallel (1.12.1)
|
|
15
|
+
parser (2.5.0.5)
|
|
16
|
+
ast (~> 2.4.0)
|
|
17
|
+
powerpack (0.1.1)
|
|
18
|
+
rainbow (3.0.0)
|
|
19
|
+
rake (10.4.2)
|
|
20
|
+
rspec (3.7.0)
|
|
21
|
+
rspec-core (~> 3.7.0)
|
|
22
|
+
rspec-expectations (~> 3.7.0)
|
|
23
|
+
rspec-mocks (~> 3.7.0)
|
|
24
|
+
rspec-core (3.7.1)
|
|
25
|
+
rspec-support (~> 3.7.0)
|
|
26
|
+
rspec-expectations (3.7.0)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.7.0)
|
|
29
|
+
rspec-mocks (3.7.0)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.7.0)
|
|
32
|
+
rspec-support (3.7.1)
|
|
33
|
+
rubocop (0.54.0)
|
|
34
|
+
parallel (~> 1.10)
|
|
35
|
+
parser (>= 2.5)
|
|
36
|
+
powerpack (~> 0.1)
|
|
37
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
38
|
+
ruby-progressbar (~> 1.7)
|
|
39
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
40
|
+
rubocop-rspec (1.24.0)
|
|
41
|
+
rubocop (>= 0.53.0)
|
|
42
|
+
ruby-progressbar (1.9.0)
|
|
43
|
+
unicode-display_width (1.3.0)
|
|
44
|
+
|
|
45
|
+
PLATFORMS
|
|
46
|
+
ruby
|
|
47
|
+
|
|
48
|
+
DEPENDENCIES
|
|
49
|
+
bundler (~> 1.16)
|
|
50
|
+
fincop
|
|
51
|
+
rake (~> 10.0)
|
|
52
|
+
rspec (~> 3.0)
|
|
53
|
+
virtual_gem!
|
|
54
|
+
|
|
55
|
+
BUNDLED WITH
|
|
56
|
+
1.16.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 ota42y
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# VirtualGem
|
|
2
|
+
|
|
3
|
+
Create virtual gem version for checking dependency.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# The purpose
|
|
7
|
+
|
|
8
|
+
This dependency setting include alpha and beta version.
|
|
9
|
+
So this setting include "0.1.0", "0.2.1", "0.3.0.rc1"
|
|
10
|
+
```
|
|
11
|
+
spec.add_dependency "ota42y_test_gem", "< 0.3"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And when "0.3.0" released, we can't install it because "< 0.3" does't include "0.3.0".
|
|
15
|
+
|
|
16
|
+
We already test release candidate version so "0.3.0" will work well.
|
|
17
|
+
But we can't check until "0.3.0" released.
|
|
18
|
+
|
|
19
|
+
For example, when `ota42y_dependent_test_gem` depends `ota42y_test_gem` '< 0.3', this setting well success.
|
|
20
|
+
```ruby
|
|
21
|
+
gem 'ota42y_dependent_test_gem', '0.2.0'
|
|
22
|
+
gem 'ota42y_test_gem', '0.2.0'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
And this setting will fail because we can't resolve dependency.
|
|
26
|
+
```ruby
|
|
27
|
+
gem 'ota42y_dependent_test_gem', '0.2.0' # require 'ota42y_test_gem', '< 0.3'
|
|
28
|
+
gem 'ota42y_test_gem', '0.3.0'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
But 'ota42y_test_gem' version '0.3.0' isn't released!
|
|
32
|
+
So rubygems exit on finding gem process and we can't check dependency.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
$ bundle update ota42y_test_gem
|
|
36
|
+
Fetching gem metadata from https://rubygems.org/.........
|
|
37
|
+
Could not find gem 'ota42y_test_gem (= 0.3.0)' in any of the gem sources listed in your Gemfile.
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`virtual_gem` create new version gem from old version.
|
|
41
|
+
When use `virtual_gem`, we can pass finding process and check dependency.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
$ bundle update ota42y_test_gem
|
|
45
|
+
Fetching gem metadata from https://rubygems.org/.........
|
|
46
|
+
Resolving dependencies...
|
|
47
|
+
Bundler could not find compatible versions for gem "ota42y_test_gem":
|
|
48
|
+
In Gemfile:
|
|
49
|
+
ota42y_test_gem (= 0.3.0)
|
|
50
|
+
|
|
51
|
+
ota42y_dependent_test_gem (= 0.2.0) was resolved to 0.2.0, which depends on
|
|
52
|
+
ota42y_test_gem (< 0.3)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Even if we create virtual_gem, bundle will fail by dependencies error.
|
|
56
|
+
So this gem provide overwrite gem dependencies
|
|
57
|
+
We can change `ota42y_dependent_test_gem` depends `ota42y_test_gem` '< 0.3' to '<= 0.3', so we can pass and check next dependencies.
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
$ gem install virtual_gem
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
Please write this line to your Gemfile
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
::VirtualGem.register_virtual_gem(name: 'ota42y_test_gem',new_version: '0.3.0', original_version: '0.2.0')
|
|
68
|
+
|
|
69
|
+
source "https://rubygems.org"
|
|
70
|
+
|
|
71
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
72
|
+
|
|
73
|
+
require 'bundler'
|
|
74
|
+
|
|
75
|
+
gem 'ota42y_test_gem', '0.3.0'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This code create 'ota42y_test_gem' version 0.3.0 using 0.2.0 gem.
|
|
79
|
+
We don't release '0.3.0' yet but bundle install will success.
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
% bundle install
|
|
83
|
+
Using bundler 1.16.1
|
|
84
|
+
Using ota42y_test_gem 0.3.0
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If you want to override gem requirement, use register_requirements_changes.
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
::VirtualGem.register_requirements_changes(name: 'ota42y_dependent_test_gem', version: '0.2.0', new_requirements: { 'ota42y_test_gem': ['<= 0.3'] })
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
'ota42y_dependent_test_gem' version '0.2.0' depends on 'ota42y_test_gem' version '< 0.3' but this method change depends on '<=0.3'.
|
|
94
|
+
|
|
95
|
+
## Important notice
|
|
96
|
+
We check `bundle install` process only.
|
|
97
|
+
So don't use `virtual_gem` for execute ruby script.
|
|
98
|
+
(We don't change ::GEM_NAME::VERSION so many gem will doesn't work well.)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
104
|
+
|
|
105
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
106
|
+
|
|
107
|
+
## Contributing
|
|
108
|
+
|
|
109
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/virtual_gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
114
|
+
|
|
115
|
+
## Code of Conduct
|
|
116
|
+
|
|
117
|
+
Everyone interacting in the VirtualGem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/virtual_gem/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'virtual_gem'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require 'irb'
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/virtual_gem.rb
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require_relative 'virtual_gem/version'
|
|
2
|
+
require_relative 'virtual_gem/virtual_gem_info'
|
|
3
|
+
require_relative 'virtual_gem/gem/specification'
|
|
4
|
+
require_relative 'virtual_gem/bundler/lock_file_parser'
|
|
5
|
+
|
|
6
|
+
module VirtualGem
|
|
7
|
+
class << self
|
|
8
|
+
def register_virtual_gem(name:, new_version:, original_version:)
|
|
9
|
+
info = ::VirtualGem::VirtualGemInfo.new(name: name, new_version: new_version, original_version: original_version)
|
|
10
|
+
|
|
11
|
+
@virtual_gem_dict ||= Hash.new { |h, k| h[k] = {} }
|
|
12
|
+
@virtual_gem_dict[name][new_version] = info
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# changes = [ { gem_name: ['=< 0.3'] } ]
|
|
16
|
+
def register_requirements_changes(name:, version:, new_requirements:)
|
|
17
|
+
@requirements_changes ||= Hash.new { |h, k| h[k] = {} }
|
|
18
|
+
@requirements_changes[name][version] = new_requirements
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def update_virtual_gems(stubs, stubs_by_name)
|
|
22
|
+
create_virtual_gems(stubs, stubs_by_name)
|
|
23
|
+
update_new_requirements(stubs_by_name)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def replace_new_requirements(specs)
|
|
27
|
+
return unless @requirements_changes
|
|
28
|
+
|
|
29
|
+
dict = specs.group_by(&:name)
|
|
30
|
+
@requirements_changes.each do |name, change_settings|
|
|
31
|
+
gems = dict[name]
|
|
32
|
+
next unless gems
|
|
33
|
+
|
|
34
|
+
versions = gems.map { |g| [g.version.to_s, g] }.to_h
|
|
35
|
+
next if versions.empty?
|
|
36
|
+
|
|
37
|
+
replace_requirements(versions, change_settings)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def update_new_requirements(stubs_by_name)
|
|
44
|
+
return unless @requirements_changes
|
|
45
|
+
|
|
46
|
+
@requirements_changes.each do |name, change_settings|
|
|
47
|
+
gems = stubs_by_name[name]
|
|
48
|
+
next unless gems
|
|
49
|
+
|
|
50
|
+
versions = gems.map { |g| [g.version.to_s, g] }.to_h
|
|
51
|
+
next if versions.empty?
|
|
52
|
+
|
|
53
|
+
update_requirements(versions, change_settings)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def create_virtual_gems(stubs, stubs_by_name)
|
|
58
|
+
return unless @virtual_gem_dict
|
|
59
|
+
|
|
60
|
+
@virtual_gem_dict.each do |name, info_list|
|
|
61
|
+
gems = stubs_by_name[name]
|
|
62
|
+
versions = build_gem_version_dict(gems)
|
|
63
|
+
next unless versions
|
|
64
|
+
|
|
65
|
+
new_gems = info_list.map { |_, info| create_from_info(versions, info) }.compact
|
|
66
|
+
|
|
67
|
+
stubs.concat new_gems
|
|
68
|
+
gems.concat new_gems
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def build_gem_version_dict(gems)
|
|
73
|
+
return nil unless gems
|
|
74
|
+
return nil if gems.empty?
|
|
75
|
+
|
|
76
|
+
gems.map { |g| [g.version.to_s, g] }.to_h
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def update_requirements(versions, settings)
|
|
80
|
+
settings.each do |version, new_requirements|
|
|
81
|
+
gem = versions[version]
|
|
82
|
+
next unless gem # not found replaced gem
|
|
83
|
+
dependencies_map = gem.to_spec.dependencies.map { |d| [d.name, d] }.to_h
|
|
84
|
+
|
|
85
|
+
new_requirements.each do |name, requirements|
|
|
86
|
+
dependency = dependencies_map[name.to_s]
|
|
87
|
+
dependency.instance_variable_set(:@requirement, ::Gem::Requirement.new(requirements)) if dependency
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def replace_requirements(versions, settings)
|
|
93
|
+
settings.each do |version, new_requirements|
|
|
94
|
+
gem = versions[version]
|
|
95
|
+
next unless gem # not found replaced gem
|
|
96
|
+
|
|
97
|
+
dependencies_map = gem.dependencies.map { |d| [d.name, d] }.to_h
|
|
98
|
+
|
|
99
|
+
new_requirements.each do |name, requirements|
|
|
100
|
+
dependency = dependencies_map[name.to_s]
|
|
101
|
+
dependency.instance_variable_set(:@requirement, ::Gem::Requirement.new(requirements)) if dependency
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def create_from_info(versions, info)
|
|
107
|
+
version = info.original_version
|
|
108
|
+
original_gem = versions[version]
|
|
109
|
+
return nil unless original_gem
|
|
110
|
+
|
|
111
|
+
virtual_gem = Gem::StubSpecification.gemspec_stub(original_gem.loaded_from, original_gem.base_dir, original_gem.gems_dir)
|
|
112
|
+
raise 'virtual gem error' unless virtual_gem.valid? # failed..bug?
|
|
113
|
+
|
|
114
|
+
data = virtual_gem.instance_variable_get(:@data)
|
|
115
|
+
data.instance_variable_set(:@version, ::Gem::Version.new(info.new_version))
|
|
116
|
+
|
|
117
|
+
virtual_gem
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module VirtualGem
|
|
2
|
+
module VirtualGemStubs
|
|
3
|
+
module ClassMethods
|
|
4
|
+
def stubs
|
|
5
|
+
return super if class_variable_get(:@@stubs)
|
|
6
|
+
|
|
7
|
+
# add virtual gem
|
|
8
|
+
stubs = super
|
|
9
|
+
stubs_by_name = class_variable_get(:@@stubs_by_name)
|
|
10
|
+
::VirtualGem.update_virtual_gems(stubs, stubs_by_name)
|
|
11
|
+
|
|
12
|
+
stubs
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.prepended(base)
|
|
17
|
+
class << base
|
|
18
|
+
prepend ClassMethods
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Gem::Specification
|
|
25
|
+
prepend ::VirtualGem::VirtualGemStubs
|
|
26
|
+
end
|
data/virtual_gem.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'virtual_gem/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'virtual_gem'
|
|
8
|
+
spec.version = VirtualGem::VERSION
|
|
9
|
+
spec.authors = ['ota42y']
|
|
10
|
+
spec.email = ['ota42y@gmail.com']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'create virtual gem and for checking dependency'
|
|
13
|
+
spec.description = 'create virtual gem and for checking dependency'
|
|
14
|
+
spec.homepage = 'https://github.com/ota42y/virtual_gem'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = 'exe'
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ['lib']
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
|
25
|
+
spec.add_development_dependency 'fincop'
|
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: virtual_gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ota42y
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: fincop
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
description: create virtual gem and for checking dependency
|
|
70
|
+
email:
|
|
71
|
+
- ota42y@gmail.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- ".rubocop.yml"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- CODE_OF_CONDUCT.md
|
|
81
|
+
- Gemfile
|
|
82
|
+
- Gemfile.lock
|
|
83
|
+
- LICENSE.txt
|
|
84
|
+
- README.md
|
|
85
|
+
- Rakefile
|
|
86
|
+
- bin/console
|
|
87
|
+
- bin/setup
|
|
88
|
+
- lib/virtual_gem.rb
|
|
89
|
+
- lib/virtual_gem/bundler/lock_file_parser.rb
|
|
90
|
+
- lib/virtual_gem/gem/specification.rb
|
|
91
|
+
- lib/virtual_gem/version.rb
|
|
92
|
+
- lib/virtual_gem/virtual_gem_info.rb
|
|
93
|
+
- virtual_gem.gemspec
|
|
94
|
+
homepage: https://github.com/ota42y/virtual_gem
|
|
95
|
+
licenses:
|
|
96
|
+
- MIT
|
|
97
|
+
metadata: {}
|
|
98
|
+
post_install_message:
|
|
99
|
+
rdoc_options: []
|
|
100
|
+
require_paths:
|
|
101
|
+
- lib
|
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
112
|
+
requirements: []
|
|
113
|
+
rubyforge_project:
|
|
114
|
+
rubygems_version: 2.7.3
|
|
115
|
+
signing_key:
|
|
116
|
+
specification_version: 4
|
|
117
|
+
summary: create virtual gem and for checking dependency
|
|
118
|
+
test_files: []
|