eskort 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7a22a56de33137d5967f74a0d9cda3f113a1b067
4
+ data.tar.gz: 31e6489c96d36b09c4a8a93a8e469de1f8af2f76
5
+ SHA512:
6
+ metadata.gz: fa8ae0fae56ac7615825e867229ec7568492a1fbdaca81d53594ff8cc854458c356de62b9c86ad2061750170fb7d23ddc789ac349556bf64c746b748a66bfe25
7
+ data.tar.gz: 3322340d25dfc9b07f0a7f5cae0e786dc89985a64bb52f553391bf61f115c404b482b06b8552d6fdab31b287ad026d81e0b87630e8bf2636471f3107d1589912
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ /vendor/bundle/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.7
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in eskort.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eskort (0.0.1)
5
+ octokit (~> 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.6.0)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ coderay (1.1.2)
13
+ diff-lcs (1.3)
14
+ faraday (0.15.4)
15
+ multipart-post (>= 1.2, < 3)
16
+ method_source (0.9.2)
17
+ multipart-post (2.0.0)
18
+ octokit (4.14.0)
19
+ sawyer (~> 0.8.0, >= 0.5.3)
20
+ pry (0.12.2)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.9.0)
23
+ public_suffix (3.0.3)
24
+ rake (10.5.0)
25
+ rspec (3.8.0)
26
+ rspec-core (~> 3.8.0)
27
+ rspec-expectations (~> 3.8.0)
28
+ rspec-mocks (~> 3.8.0)
29
+ rspec-core (3.8.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-expectations (3.8.3)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-mocks (3.8.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-support (3.8.0)
38
+ sawyer (0.8.2)
39
+ addressable (>= 2.3.5)
40
+ faraday (> 0.8, < 2.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 2.0)
47
+ eskort!
48
+ pry
49
+ rake (~> 10.0)
50
+ rspec (~> 3.0)
51
+
52
+ BUNDLED WITH
53
+ 2.0.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 SAKAI, Atsushi
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Eskort
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/eskort`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'eskort'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install eskort
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/eskort.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eskort"
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/eskort ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "eskort"
4
+ require "octokit"
5
+ require 'pry'
6
+
7
+ # TODO:
8
+ # should move to cli options
9
+ UPDATE_GEMS_COUNT = 1
10
+ DEFAULT_LABELS = []
11
+ REPOSITORY_NAME = 'radioboo/eskort'
12
+ BASE_BRANCH = 'master'
13
+ GIT_USER_EMAIL = 'sakai.atsushi@gmail.com'
14
+ GIT_USER_NAME = 'radioboo'
15
+
16
+ def checkout_and_update_gem(branch_name, active_spec)
17
+ command = Eskort::Bundler::Command.new
18
+ command.git_config_global(email: GIT_USER_EMAIL, name: GIT_USER_NAME)
19
+ command.git_checkout(branch_name)
20
+ command.bundle_update(active_spec.name)
21
+ command.git_commit(active_spec.name, active_spec.version.to_s)
22
+ command.git_push(branch_name)
23
+ end
24
+
25
+ def branch_name(active_spec)
26
+ "#{active_spec.name}-#{Time.now.to_i}#{Time.now.usec}"
27
+ end
28
+
29
+ def create_pull_request(branch_name, current_spec, active_spec)
30
+ client = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
31
+ client.create_pull_request(
32
+ REPOSITORY_NAME,
33
+ BASE_BRANCH,
34
+ branch_name,
35
+ title(active_spec.name, current_spec.version.to_s, active_spec.version.to_s),
36
+ body(active_spec.name, current_spec.version.to_s, active_spec.version.to_s),
37
+ { labels: DEFAULT_LABELS },
38
+ )
39
+ end
40
+
41
+ def title(spec_name, from_version, to_version)
42
+ "Auto Update: #{spec_name} #{from_version} -> #{to_version}"
43
+ end
44
+
45
+ def body(spec_name, from_version, to_version)
46
+ "Auto Update: #{spec_name} #{from_version} -> #{to_version}"
47
+ end
48
+
49
+ outdated_gems = Eskort::Bundler::Outdated.new.list
50
+ outdated_gems.sample(UPDATE_GEMS_COUNT).each do |og|
51
+ branch_name = branch_name(og.active_spec)
52
+ checkout_and_update_gem(branch_name, og.active_spec)
53
+ create_pull_request(branch_name, og.current_spec, og.active_spec)
54
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/eskort.gemspec ADDED
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "eskort/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eskort"
8
+ spec.version = Eskort::VERSION
9
+ spec.authors = ["Atsushi Sakai"]
10
+ spec.email = ["sakai.atsushi@gmail.com"]
11
+
12
+ spec.summary = %q{Escort your bundlr environment to the latest version.}
13
+ spec.description = %q{Escort your bundlr environment to the latest version.}
14
+ spec.homepage = "https://github.com/radioboo."
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
23
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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_dependency "octokit", "~> 4.0"
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ end
@@ -0,0 +1,26 @@
1
+ module Eskort
2
+ module Bundler
3
+ class Command
4
+ def bundle_update(gem_name)
5
+ Kernel.system("bundle update #{gem_name}")
6
+ end
7
+
8
+ def git_config_global(email:, name:)
9
+ Kernel.system("git config --global user.email #{email}")
10
+ Kernel.system("git config --global user.name #{name}")
11
+ end
12
+
13
+ def git_checkout(branch_name)
14
+ Kernel.system("git checkout -b #{branch_name} origin/master")
15
+ end
16
+
17
+ def git_commit(gem_name, gem_version)
18
+ Kernel.system("git commit Gemfile.lock -m \'Auto update #{gem_name} to version #{gem_version}\'")
19
+ end
20
+
21
+ def git_push(branch_name)
22
+ Kernel.system("git push origin #{branch_name}")
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,68 @@
1
+ module Eskort
2
+ module Bundler
3
+
4
+ class Outdated
5
+
6
+ def list # rubocop:disable Metrics/AbcSize
7
+ outdated_gems_list = []
8
+
9
+ current_specs = ::Bundler.ui.silence { ::Bundler.definition.resolve }
10
+
11
+ current_dependencies = {}
12
+ ::Bundler.ui.silence do
13
+ ::Bundler.load.dependencies.each do |dep|
14
+ current_dependencies[dep.name] = dep
15
+ end
16
+ end
17
+
18
+ gemfile_specs, dependency_specs = current_specs.partition do |spec|
19
+ current_dependencies.key?(spec.name)
20
+ end
21
+
22
+ definition = ::Bundler::Definition.build('Gemfile', 'Gemfile.lock', true).tap(&:resolve_remotely!)
23
+
24
+ target_specs = gemfile_specs + dependency_specs
25
+ target_specs.sort_by(&:name).each do |current_spec|
26
+ dependency = current_dependencies[current_spec.name]
27
+
28
+ # trueで実行するとGemfileで許可されているUpdate可能なものだけをリストする
29
+ active_spec = retrieve_active_spec(false, definition, current_spec)
30
+
31
+ next if active_spec.nil?
32
+ next if !outdated?(active_spec, current_spec) && (current_spec.git_version == active_spec.git_version)
33
+
34
+ outdated_gems_list << Gem.new(active_spec, current_spec, dependency)
35
+ end
36
+ outdated_gems_list
37
+ end
38
+
39
+ private
40
+
41
+ def outdated?(active_spec, current_spec)
42
+ ::Gem::Version.new(active_spec.version) > ::Gem::Version.new(current_spec.version)
43
+ end
44
+
45
+ def retrieve_active_spec(strict, definition, current_spec)
46
+ if strict
47
+ active_spec = definition.find_resolved_spec(current_spec)
48
+ else
49
+ active_specs = definition.find_indexed_specs(current_spec)
50
+ active_specs.delete_if { |b| b.respond_to?(:version) && b.version.prerelease? } if !current_spec.version.prerelease? && active_specs.size > 1
51
+ active_spec = active_specs.last
52
+ end
53
+ active_spec
54
+ end
55
+
56
+ class Gem
57
+
58
+ attr_reader :active_spec, :current_spec, :dependency
59
+
60
+ def initialize(active_spec, current_spec, dependency)
61
+ @active_spec = active_spec
62
+ @current_spec = current_spec
63
+ @dependency = dependency
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ module Eskort
2
+ module Bundler
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Eskort
2
+ VERSION = "0.0.1"
3
+ end
data/lib/eskort.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "eskort/version"
2
+ require "eskort/bundler/outdated"
3
+ require "eskort/bundler/command"
4
+
5
+ module Eskort
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eskort
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Atsushi Sakai
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.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: Escort your bundlr environment to the latest version.
70
+ email:
71
+ - sakai.atsushi@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/eskort
86
+ - bin/setup
87
+ - eskort.gemspec
88
+ - lib/eskort.rb
89
+ - lib/eskort/bundler.rb
90
+ - lib/eskort/bundler/command.rb
91
+ - lib/eskort/bundler/outdated.rb
92
+ - lib/eskort/version.rb
93
+ homepage: https://github.com/radioboo.
94
+ licenses: []
95
+ metadata:
96
+ homepage_uri: https://github.com/radioboo.
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.6.14.1
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Escort your bundlr environment to the latest version.
117
+ test_files: []