restore_bundled_with 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +15 -0
- data/CHANGELOG.md +16 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +189 -0
- data/RELEASE.md +14 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/conventional-changelog.js +19 -0
- data/bin/run-rubocop.sh +42 -0
- data/bin/setup +7 -0
- data/exe/restore-bundled-with +5 -0
- data/lib/restore_bundled_with.rb +28 -0
- data/lib/restore_bundled_with/cli.rb +134 -0
- data/lib/restore_bundled_with/delete.rb +13 -0
- data/lib/restore_bundled_with/error.rb +3 -0
- data/lib/restore_bundled_with/fetch.rb +38 -0
- data/lib/restore_bundled_with/insert.rb +18 -0
- data/lib/restore_bundled_with/restore.rb +39 -0
- data/lib/restore_bundled_with/version.rb +3 -0
- data/restore_bundled_with.gemspec +45 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 41b5d988c8c3575b8d890a093cc059a67269585f
|
4
|
+
data.tar.gz: a88e716c17b3d8c30af065d95b399428b91dfbe7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ff8e3a8bae902347bfb3fd6456e56adfdf353b7a1de245a5c027891a6518605baba8e932952fac67c028f0413b6a9dec6c1c59cb3cd84eadbd24fa38c09f61a
|
7
|
+
data.tar.gz: 516c46004b15d944d2590d7f70b2117e5062d850371390f9deada594d2e39facafa19f4a7b5d60ae53619a822deb1058b43033596d7087576c3466af4be769a8
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-06-20 02:51:10 +0900 using RuboCop version 0.32.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
Metrics/AbcSize:
|
9
|
+
Exclude:
|
10
|
+
- lib/restore_bundled_with/cli.rb
|
11
|
+
|
12
|
+
# Configuration parameters: CountComments.
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Exclude:
|
15
|
+
- lib/restore_bundled_with/cli.rb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<a name"0.1.0"></a>
|
2
|
+
## 0.1.0 (2015-06-20)
|
3
|
+
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* **restore:** unfrozen option ([3c316318](https://github.com/packsaddle/ruby-restore_bundled_with/commit/3c316318))
|
8
|
+
|
9
|
+
|
10
|
+
#### Features
|
11
|
+
|
12
|
+
* **fetch:** fetch git stored BUNDLED WITH ([eee0d0c1](https://github.com/packsaddle/ruby-restore_bundled_with/commit/eee0d0c1))
|
13
|
+
* **insert:** body plus section ([3dac3291](https://github.com/packsaddle/ruby-restore_bundled_with/commit/3dac3291))
|
14
|
+
* **restore:** add restore ([c21108fc](https://github.com/packsaddle/ruby-restore_bundled_with/commit/c21108fc))
|
15
|
+
* **trim:** trim bundled_with ([c4b19a48](https://github.com/packsaddle/ruby-restore_bundled_with/commit/c4b19a48))
|
16
|
+
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 sanemat
|
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,189 @@
|
|
1
|
+
# RestoreBundledWith
|
2
|
+
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/restore_bundled_with.svg?style=flat)](http://badge.fury.io/rb/restore_bundled_with)
|
4
|
+
[![Build Status](http://img.shields.io/travis/packsaddle/ruby-restore_bundled_with/master.svg?style=flat)](https://travis-ci.org/packsaddle/ruby-restore_bundled_with)
|
5
|
+
|
6
|
+
Restore `BUNDLED WITH` section in `Gemfile.lock` from git repository.
|
7
|
+
|
8
|
+
```text
|
9
|
+
# Gemfile.lock
|
10
|
+
PATH
|
11
|
+
remote: .
|
12
|
+
specs:
|
13
|
+
(snip)
|
14
|
+
|
15
|
+
BUNDLED WITH
|
16
|
+
1.10.4
|
17
|
+
```
|
18
|
+
|
19
|
+
## Description
|
20
|
+
|
21
|
+
Bundler `v1.10.0 or higher` tracks Bundler version in lockfile.
|
22
|
+
We should use latest Bundler, but sometimes we are afraid we have to use older Bundler.
|
23
|
+
We use Different version of Bundler between a project and a local machine.
|
24
|
+
In addition, Bundler `v1.9.x` removes `BUNDLED WITH` section.
|
25
|
+
*RestoreBundledWith* solves these conflicts.
|
26
|
+
*RestoreBundledWith* restores `BUNDLED WITH` section from git repository.
|
27
|
+
|
28
|
+
* [Track Bundler version in lockfile by smlance #3485 bundler/bundler](https://github.com/bundler/bundler/pull/3485)
|
29
|
+
* [Do not update BUNDLED WITH if no other changes to the lock happened #3697 bundler/bundler](https://github.com/bundler/bundler/issues/3697)
|
30
|
+
|
31
|
+
## Example
|
32
|
+
|
33
|
+
### Newer Bundler Case
|
34
|
+
|
35
|
+
```text
|
36
|
+
$ cat Gemfile.lock
|
37
|
+
(snip)
|
38
|
+
unicorn-worker-killer
|
39
|
+
webmock
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
1.10.2
|
43
|
+
```
|
44
|
+
|
45
|
+
Execute `bundle update` by Bundler v1.10.3.
|
46
|
+
|
47
|
+
```
|
48
|
+
$ git diff
|
49
|
+
(snip)
|
50
|
+
@@ -291,4 +296,4 @@ DEPENDENCIES
|
51
|
+
webmock
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
- 1.10.2
|
55
|
+
+ 1.10.3
|
56
|
+
```
|
57
|
+
|
58
|
+
Then, execute `restore-bundled-with`.
|
59
|
+
|
60
|
+
```
|
61
|
+
$ git diff
|
62
|
+
```
|
63
|
+
|
64
|
+
There is no diff, because this restores `BUNDLED WITH` from git repository.
|
65
|
+
|
66
|
+
### Old Bundler (v1.9) Case
|
67
|
+
|
68
|
+
```text
|
69
|
+
$ cat Gemfile.lock
|
70
|
+
(snip)
|
71
|
+
unicorn-worker-killer
|
72
|
+
webmock
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
1.10.2
|
76
|
+
```
|
77
|
+
|
78
|
+
Execute `bundle update` by Bundler v1.9.9.
|
79
|
+
|
80
|
+
```
|
81
|
+
$ git diff
|
82
|
+
(snip)
|
83
|
+
@@ -289,6 +299,3 @@ DEPENDENCIES
|
84
|
+
unicorn
|
85
|
+
unicorn-worker-killer
|
86
|
+
webmock
|
87
|
+
-
|
88
|
+
-BUNDLED WITH
|
89
|
+
- 1.10.2
|
90
|
+
```
|
91
|
+
|
92
|
+
Then, execute `restore-bundled-with`.
|
93
|
+
|
94
|
+
```
|
95
|
+
$ git diff
|
96
|
+
```
|
97
|
+
|
98
|
+
There is no diff, because this restores `BUNDLED WITH` from git repository.
|
99
|
+
|
100
|
+
|
101
|
+
## Usage
|
102
|
+
|
103
|
+
```text
|
104
|
+
Commands:
|
105
|
+
restore-bundled-with delete # Delete BUNDLED WITH
|
106
|
+
restore-bundled-with fetch # Fetch BUNDLED WITH section
|
107
|
+
restore-bundled-with help [COMMAND] # Describe available commands or one specific command
|
108
|
+
restore-bundled-with restore # Restore BUNDLED WITH on Gemfile.lock
|
109
|
+
restore-bundled-with version # Show the RestoreBundledWith version
|
110
|
+
|
111
|
+
Usage:
|
112
|
+
restore-bundled-with restore
|
113
|
+
|
114
|
+
Options:
|
115
|
+
[--data=DATA]
|
116
|
+
[--file=FILE]
|
117
|
+
[--lockfile=LOCKFILE]
|
118
|
+
# Default: Gemfile.lock
|
119
|
+
[--ref=REF]
|
120
|
+
# Default: HEAD
|
121
|
+
[--git-path=GIT_PATH]
|
122
|
+
# Default: .
|
123
|
+
[--git-options=key:value]
|
124
|
+
[--new-line=NEW_LINE]
|
125
|
+
# Default:
|
126
|
+
[--debug], [--no-debug]
|
127
|
+
[--verbose], [--no-verbose]
|
128
|
+
|
129
|
+
Restore BUNDLED WITH on Gemfile.lock
|
130
|
+
|
131
|
+
Usage:
|
132
|
+
restore-bundled-with delete
|
133
|
+
|
134
|
+
Options:
|
135
|
+
[--data=DATA]
|
136
|
+
[--file=FILE]
|
137
|
+
[--debug], [--no-debug]
|
138
|
+
[--verbose], [--no-verbose]
|
139
|
+
|
140
|
+
Delete BUNDLED WITH
|
141
|
+
|
142
|
+
Usage:
|
143
|
+
restore-bundled-with fetch
|
144
|
+
|
145
|
+
Options:
|
146
|
+
[--lockfile=LOCKFILE]
|
147
|
+
# Default: Gemfile.lock
|
148
|
+
[--ref=REF]
|
149
|
+
# Default: HEAD
|
150
|
+
[--git-path=GIT_PATH]
|
151
|
+
# Default: .
|
152
|
+
[--git-options=key:value]
|
153
|
+
[--debug], [--no-debug]
|
154
|
+
[--verbose], [--no-verbose]
|
155
|
+
|
156
|
+
Fetch BUNDLED WITH section
|
157
|
+
```
|
158
|
+
|
159
|
+
## Installation
|
160
|
+
|
161
|
+
Add this line to your application's Gemfile:
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
gem 'restore_bundled_with'
|
165
|
+
```
|
166
|
+
|
167
|
+
And then execute:
|
168
|
+
|
169
|
+
$ bundle
|
170
|
+
|
171
|
+
Or install it yourself as:
|
172
|
+
|
173
|
+
$ gem install restore_bundled_with
|
174
|
+
|
175
|
+
## Development
|
176
|
+
|
177
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
178
|
+
|
179
|
+
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).
|
180
|
+
|
181
|
+
## Contributing
|
182
|
+
|
183
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/packsaddle/ruby-restore_bundled_with. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
184
|
+
|
185
|
+
|
186
|
+
## License
|
187
|
+
|
188
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
189
|
+
|
data/RELEASE.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'restore_bundled_with'
|
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
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
var fs = require('fs');
|
4
|
+
var execSync = require('child_process').execSync;
|
5
|
+
var conventionalChangelog = require('conventional-changelog');
|
6
|
+
|
7
|
+
var repo = 'https://github.com/packsaddle/ruby-restore_bundled_with'
|
8
|
+
var version = "" + execSync('bundle exec exe/restore-bundled-with version --digit');
|
9
|
+
|
10
|
+
conventionalChangelog({
|
11
|
+
repository: repo,
|
12
|
+
version: version,
|
13
|
+
file: 'CHANGELOG.md'
|
14
|
+
}, function(err, log) {
|
15
|
+
fs.writeFile('CHANGELOG.md', log, function(err){
|
16
|
+
console.log(err);
|
17
|
+
});
|
18
|
+
console.log('Here is your changelog!', log);
|
19
|
+
});
|
data/bin/run-rubocop.sh
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -v
|
3
|
+
if [ -n "${TRAVIS_PULL_REQUEST}" ] && [ "${TRAVIS_PULL_REQUEST}" != "false" ] && [ "${TRAVIS_JOB_NUMBER: -1}" == "1" ]; then
|
4
|
+
# Travis-CI
|
5
|
+
#
|
6
|
+
# git clone --depth=50 \
|
7
|
+
# git://github.com/packsaddle/example-ruby-travis-ci.git \
|
8
|
+
# packsaddle/example-ruby-travis-ci
|
9
|
+
# cd packsaddle/example-ruby-travis-ci
|
10
|
+
# git fetch origin +refs/pull/1/merge:
|
11
|
+
# git checkout -qf FETCH_HEAD
|
12
|
+
|
13
|
+
echo gem install
|
14
|
+
gem install --no-document rubocop-select rubocop rubocop-checkstyle_formatter \
|
15
|
+
checkstyle_filter-git saddler saddler-reporter-github \
|
16
|
+
github_status_notifier
|
17
|
+
|
18
|
+
github-status-notifier notify --state pending --context saddler/rubocop
|
19
|
+
|
20
|
+
TARGET_FILES=$(git diff -z --name-only origin/master \
|
21
|
+
| xargs -0 rubocop-select)
|
22
|
+
|
23
|
+
if [ "${TARGET_FILES}" == "" ]; then
|
24
|
+
echo "no rubocop target found"
|
25
|
+
github-status-notifier notify --state success --context saddler/rubocop
|
26
|
+
exit 0
|
27
|
+
fi
|
28
|
+
|
29
|
+
git diff -z --name-only origin/master \
|
30
|
+
| xargs -0 rubocop-select \
|
31
|
+
| xargs rubocop \
|
32
|
+
--require rubocop/formatter/checkstyle_formatter \
|
33
|
+
--format RuboCop::Formatter::CheckstyleFormatter \
|
34
|
+
| checkstyle_filter-git diff origin/master \
|
35
|
+
| saddler report \
|
36
|
+
--require saddler/reporter/github \
|
37
|
+
--reporter Saddler::Reporter::Github::PullRequestReviewComment
|
38
|
+
|
39
|
+
github-status-notifier notify --exit-status $? --context saddler/rubocop
|
40
|
+
fi
|
41
|
+
|
42
|
+
exit 0
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
require 'restore_bundled_with/error'
|
5
|
+
require 'restore_bundled_with/fetch'
|
6
|
+
require 'restore_bundled_with/delete'
|
7
|
+
require 'restore_bundled_with/insert'
|
8
|
+
require 'restore_bundled_with/restore'
|
9
|
+
require 'restore_bundled_with/version'
|
10
|
+
|
11
|
+
module RestoreBundledWith
|
12
|
+
ISSUE_URL = 'https://github.com/packsaddle/ruby-restore_bundled_with/issues/new'
|
13
|
+
def self.default_logger
|
14
|
+
logger = Logger.new(STDERR)
|
15
|
+
logger.progname = "RestoreBundledWith #{VERSION}"
|
16
|
+
logger.level = Logger::WARN
|
17
|
+
logger
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.logger
|
21
|
+
return @logger if @logger
|
22
|
+
@logger = default_logger
|
23
|
+
end
|
24
|
+
|
25
|
+
class << self
|
26
|
+
attr_writer :logger
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module RestoreBundledWith
|
4
|
+
class CLI < Thor
|
5
|
+
def self.exit_on_failure?
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'version', 'Show the RestoreBundledWith version'
|
10
|
+
map %w(-v --version) => :version
|
11
|
+
option :digit, type: :boolean, default: false
|
12
|
+
def version
|
13
|
+
if options[:digit]
|
14
|
+
print ::RestoreBundledWith::VERSION
|
15
|
+
else
|
16
|
+
puts "RestoreBundledWith version #{::RestoreBundledWith::VERSION}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'restore', 'Restore BUNDLED WITH on Gemfile.lock'
|
21
|
+
option :data
|
22
|
+
option :file
|
23
|
+
option :lockfile, type: :string, default: Fetch::LOCK_FILE
|
24
|
+
option :ref, type: :string, default: Fetch::REF
|
25
|
+
option :git_path, type: :string, default: Fetch::GIT_PATH
|
26
|
+
option :git_options, type: :hash, default: Fetch::GIT_OPTIONS
|
27
|
+
option :new_line, type: :string, default: Insert::NEW_LINE
|
28
|
+
option :debug, type: :boolean, default: false
|
29
|
+
option :verbose, type: :boolean, default: false
|
30
|
+
def restore
|
31
|
+
setup_logger(options)
|
32
|
+
|
33
|
+
params = options.dup
|
34
|
+
params[:file] = options[:lockfile] if !options[:data] && !options[:file]
|
35
|
+
data = read_data(params)
|
36
|
+
lockfile = Restore.new(
|
37
|
+
data,
|
38
|
+
options[:lockfile],
|
39
|
+
options[:ref],
|
40
|
+
options[:git_path],
|
41
|
+
options[:git_options],
|
42
|
+
options[:new_line]
|
43
|
+
)
|
44
|
+
lockfile.restore
|
45
|
+
lockfile.write
|
46
|
+
rescue StandardError => e
|
47
|
+
suggest_messages(options)
|
48
|
+
raise e
|
49
|
+
end
|
50
|
+
default_command :restore
|
51
|
+
|
52
|
+
desc 'delete', 'Delete BUNDLED WITH'
|
53
|
+
option :data
|
54
|
+
option :file
|
55
|
+
option :debug, type: :boolean, default: false
|
56
|
+
option :verbose, type: :boolean, default: false
|
57
|
+
def delete
|
58
|
+
setup_logger(options)
|
59
|
+
|
60
|
+
data = read_data(options)
|
61
|
+
puts Delete.new(data).delete
|
62
|
+
rescue StandardError => e
|
63
|
+
suggest_messages(options)
|
64
|
+
raise e
|
65
|
+
end
|
66
|
+
|
67
|
+
desc 'fetch', 'Fetch BUNDLED WITH section'
|
68
|
+
option :lockfile, type: :string, default: Fetch::LOCK_FILE
|
69
|
+
option :ref, type: :string, default: Fetch::REF
|
70
|
+
option :git_path, type: :string, default: Fetch::GIT_PATH
|
71
|
+
option :git_options, type: :hash, default: Fetch::GIT_OPTIONS
|
72
|
+
option :debug, type: :boolean, default: false
|
73
|
+
option :verbose, type: :boolean, default: false
|
74
|
+
def fetch
|
75
|
+
setup_logger(options)
|
76
|
+
|
77
|
+
puts Fetch
|
78
|
+
.new(
|
79
|
+
options[:lockfile],
|
80
|
+
options[:ref],
|
81
|
+
options[:git_path],
|
82
|
+
options[:git_options])
|
83
|
+
.pick
|
84
|
+
rescue StandardError => e
|
85
|
+
suggest_messages(options)
|
86
|
+
raise e
|
87
|
+
end
|
88
|
+
|
89
|
+
no_commands do
|
90
|
+
def read_data(options)
|
91
|
+
data = \
|
92
|
+
if options[:data]
|
93
|
+
options[:data]
|
94
|
+
elsif options[:file]
|
95
|
+
File.read(options[:file])
|
96
|
+
elsif !$stdin.tty?
|
97
|
+
ARGV.clear
|
98
|
+
ARGF.read
|
99
|
+
end
|
100
|
+
|
101
|
+
logger.info('input data')
|
102
|
+
logger.info(data)
|
103
|
+
fail NoInputError if !data || data.empty?
|
104
|
+
|
105
|
+
data
|
106
|
+
end
|
107
|
+
|
108
|
+
def logger
|
109
|
+
::RestoreBundledWith.logger
|
110
|
+
end
|
111
|
+
|
112
|
+
def setup_logger(options)
|
113
|
+
if options[:debug]
|
114
|
+
logger.level = Logger::DEBUG
|
115
|
+
elsif options[:verbose]
|
116
|
+
logger.level = Logger::INFO
|
117
|
+
end
|
118
|
+
logger.debug(options)
|
119
|
+
end
|
120
|
+
|
121
|
+
def suggest_messages(options)
|
122
|
+
logger.error 'Please report from here:'
|
123
|
+
logger.error ISSUE_URL
|
124
|
+
logger.error 'options:'
|
125
|
+
logger.error options
|
126
|
+
end
|
127
|
+
|
128
|
+
# http://stackoverflow.com/a/23955971/104080
|
129
|
+
def method_missing(method, *args)
|
130
|
+
self.class.start([self.class.default_command, method.to_s] + args)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RestoreBundledWith
|
2
|
+
class Fetch
|
3
|
+
LOCK_FILE = 'Gemfile.lock'
|
4
|
+
REF = 'HEAD'
|
5
|
+
GIT_PATH = '.'
|
6
|
+
GIT_OPTIONS = {}
|
7
|
+
# REGEX_PICK = /^(?<pick>\n^BUNDLED WITH.*\n.+\n)/
|
8
|
+
# git.cat_file trims last \n?
|
9
|
+
REGEX_PICK = /^(?<pick>\n^BUNDLED WITH.*\n.+)/
|
10
|
+
def initialize(
|
11
|
+
file = LOCK_FILE,
|
12
|
+
ref = REF,
|
13
|
+
git_path = GIT_PATH,
|
14
|
+
git_options = GIT_OPTIONS)
|
15
|
+
@file = file
|
16
|
+
@ref = ref
|
17
|
+
@git_path = git_path
|
18
|
+
@git_options = git_options
|
19
|
+
end
|
20
|
+
|
21
|
+
def pick
|
22
|
+
match = REGEX_PICK.match(target_file_contents)
|
23
|
+
if match
|
24
|
+
match[:pick]
|
25
|
+
else
|
26
|
+
''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def target_file_contents
|
31
|
+
git.cat_file("#{@ref}:#{@file}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def git
|
35
|
+
@git ||= ::Git.open(@git_path, @git_options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RestoreBundledWith
|
2
|
+
class Insert
|
3
|
+
NEW_LINE = "\n"
|
4
|
+
def initialize(body, section, new_line = NEW_LINE)
|
5
|
+
@body = body
|
6
|
+
@section = section
|
7
|
+
@new_line = new_line
|
8
|
+
end
|
9
|
+
|
10
|
+
def insert
|
11
|
+
if @section && !@section.empty?
|
12
|
+
@body + @section + @new_line
|
13
|
+
else
|
14
|
+
@body
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module RestoreBundledWith
|
2
|
+
class Restore
|
3
|
+
def initialize(
|
4
|
+
data,
|
5
|
+
lockfile = Fetch::LOCK_FILE,
|
6
|
+
ref = Fetch::REF,
|
7
|
+
git_path = Fetch::GIT_PATH,
|
8
|
+
git_options = Fetch::GIT_OPTIONS,
|
9
|
+
new_line = Insert::NEW_LINE
|
10
|
+
)
|
11
|
+
@data = data
|
12
|
+
@lockfile = lockfile
|
13
|
+
@ref = ref
|
14
|
+
@git_path = git_path
|
15
|
+
@git_options = git_options
|
16
|
+
@new_line = new_line
|
17
|
+
end
|
18
|
+
|
19
|
+
def restore
|
20
|
+
data = Delete.new(@data).delete
|
21
|
+
section = Fetch
|
22
|
+
.new(
|
23
|
+
@lockfile,
|
24
|
+
@ref,
|
25
|
+
@git_path,
|
26
|
+
@git_options)
|
27
|
+
.pick
|
28
|
+
@data = Insert.new(data, section, @new_line).insert
|
29
|
+
end
|
30
|
+
|
31
|
+
def write
|
32
|
+
File.write(@lockfile, @data)
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
@data
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'restore_bundled_with/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'restore_bundled_with'
|
8
|
+
spec.version = RestoreBundledWith::VERSION
|
9
|
+
spec.authors = ['sanemat']
|
10
|
+
spec.email = ['o.gata.ken@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = \
|
13
|
+
'Restore BUNDLED WITH section in Gemfile.lock from git repository.'
|
14
|
+
spec.description = <<-'EOS'.gsub("\n") { ' ' }
|
15
|
+
We should use latest Bundler,
|
16
|
+
but sometimes we are afraid we have to use older Bundler.
|
17
|
+
RestoreBundledWith solves these conflicts.
|
18
|
+
EOS
|
19
|
+
spec.homepage = 'https://github.com/packsaddle/ruby-restore_bundled_with'
|
20
|
+
spec.license = 'MIT'
|
21
|
+
|
22
|
+
spec.files = \
|
23
|
+
`git ls-files -z`
|
24
|
+
.split("\x0")
|
25
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
.reject do |f|
|
27
|
+
[
|
28
|
+
'.travis.yml',
|
29
|
+
'circle.yml',
|
30
|
+
'.tachikoma.yml',
|
31
|
+
'package.json'
|
32
|
+
].include?(f)
|
33
|
+
end
|
34
|
+
spec.bindir = 'exe'
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ['lib']
|
37
|
+
|
38
|
+
spec.add_runtime_dependency 'thor', '>= 0'
|
39
|
+
spec.add_runtime_dependency 'git', '>= 0'
|
40
|
+
|
41
|
+
spec.add_development_dependency 'bundler', '>= 0'
|
42
|
+
spec.add_development_dependency 'rake', '>= 0'
|
43
|
+
spec.add_development_dependency 'test-unit', '>= 0'
|
44
|
+
spec.add_development_dependency 'test-unit-rr', '>= 0'
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: restore_bundled_with
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sanemat
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: git
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-unit-rr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: 'We should use latest Bundler, but sometimes we are afraid we have to
|
98
|
+
use older Bundler. RestoreBundledWith solves these conflicts. '
|
99
|
+
email:
|
100
|
+
- o.gata.ken@gmail.com
|
101
|
+
executables:
|
102
|
+
- restore-bundled-with
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".rubocop_todo.yml"
|
109
|
+
- CHANGELOG.md
|
110
|
+
- CODE_OF_CONDUCT.md
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- RELEASE.md
|
115
|
+
- Rakefile
|
116
|
+
- bin/console
|
117
|
+
- bin/conventional-changelog.js
|
118
|
+
- bin/run-rubocop.sh
|
119
|
+
- bin/setup
|
120
|
+
- exe/restore-bundled-with
|
121
|
+
- lib/restore_bundled_with.rb
|
122
|
+
- lib/restore_bundled_with/cli.rb
|
123
|
+
- lib/restore_bundled_with/delete.rb
|
124
|
+
- lib/restore_bundled_with/error.rb
|
125
|
+
- lib/restore_bundled_with/fetch.rb
|
126
|
+
- lib/restore_bundled_with/insert.rb
|
127
|
+
- lib/restore_bundled_with/restore.rb
|
128
|
+
- lib/restore_bundled_with/version.rb
|
129
|
+
- restore_bundled_with.gemspec
|
130
|
+
homepage: https://github.com/packsaddle/ruby-restore_bundled_with
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.4.5
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Restore BUNDLED WITH section in Gemfile.lock from git repository.
|
154
|
+
test_files: []
|