bundler-commentate 0.2.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: afb8cac7f4d14ddeda89be75adb7d228e5e1400db60644e58e6c71937091dd7d
4
+ data.tar.gz: 001b470ab78ef5a32c1a1adafd43c365b29ce40c88a7c83716ce0d38f448b89e
5
+ SHA512:
6
+ metadata.gz: 3bc6b5613e3cdb26dc10de28d0e9f01f312ac4cd11cf2036d143e35fc2f60bebeac7639c3bb16d04aa46ff866502c025c285b671de05a996b6e20b45a36528e1
7
+ data.tar.gz: c48de3e57869376d1a5324abd28c83c428bcda7d9dd3934bf5d0269ddb1bdc49491ac6d2eab7bad38e20a0d1d37e62bfe4af4812861c299ab587f74316af9e58
data/.rubocop.yml ADDED
@@ -0,0 +1,60 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.7
4
+
5
+ Layout/EmptyLineBetweenDefs:
6
+ Enabled: false
7
+
8
+ Layout/LineLength:
9
+ Enabled: false
10
+
11
+ Layout/SpaceAroundEqualsInParameterDefault:
12
+ Enabled: false
13
+
14
+ Layout/SpaceAroundMethodCallOperator:
15
+ Enabled: false
16
+
17
+ Layout/SpaceAroundOperators:
18
+ Enabled: false
19
+
20
+ Layout/SpaceBeforeComma:
21
+ Enabled: false
22
+
23
+ Layout/SpaceInsideParens:
24
+ Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Enabled: false
28
+
29
+ Metrics/MethodLength:
30
+ Enabled: false
31
+
32
+ Style/AndOr:
33
+ Enabled: false
34
+
35
+ Style/BlockDelimiters:
36
+ Enabled: false
37
+
38
+ Style/ClassAndModuleChildren:
39
+ Enabled: false
40
+
41
+ Style/NestedTernaryOperator:
42
+ Enabled: false
43
+
44
+ Style/RaiseArgs:
45
+ Enabled: false
46
+
47
+ Style/RescueStandardError:
48
+ Enabled: false
49
+
50
+ Style/SingleLineMethods:
51
+ Enabled: false
52
+
53
+ Style/SpecialGlobalVars:
54
+ Enabled: false
55
+
56
+ Style/StringLiterals:
57
+ Enabled: false
58
+
59
+ Style/StringLiteralsInInterpolation:
60
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-11-04
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in bundler-commentate.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0" # "Rake is a Make-like program implemented in Ruby"
9
+
10
+ gem "minitest", "~> 5.0" # "minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking"
11
+
12
+ gem "rubocop", "~> 1.7" # "Automatic Ruby code style checking tool."
13
+ gem "rubocop-minitest" # "Automatic Minitest code style checking tool."
14
+ gem "rubocop-rake" # "A RuboCop plugin for Rake"
15
+
16
+ plugin 'bundler-commentate', path: '.'
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bundler-commentate (0.2.0)
5
+ parser (~> 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ coderay (1.1.3)
12
+ method_source (1.0.0)
13
+ minitest (5.14.4)
14
+ parallel (1.21.0)
15
+ parser (3.0.2.0)
16
+ ast (~> 2.4.1)
17
+ pry (0.14.1)
18
+ coderay (~> 1.1)
19
+ method_source (~> 1.0)
20
+ rainbow (3.0.0)
21
+ rake (13.0.6)
22
+ regexp_parser (2.1.1)
23
+ rexml (3.2.5)
24
+ rubocop (1.22.3)
25
+ parallel (~> 1.10)
26
+ parser (>= 3.0.0.0)
27
+ rainbow (>= 2.2.2, < 4.0)
28
+ regexp_parser (>= 1.8, < 3.0)
29
+ rexml
30
+ rubocop-ast (>= 1.12.0, < 2.0)
31
+ ruby-progressbar (~> 1.7)
32
+ unicode-display_width (>= 1.4.0, < 3.0)
33
+ rubocop-ast (1.12.0)
34
+ parser (>= 3.0.1.1)
35
+ rubocop-minitest (0.15.2)
36
+ rubocop (>= 0.90, < 2.0)
37
+ rubocop-rake (0.6.0)
38
+ rubocop (~> 1.0)
39
+ ruby-progressbar (1.11.0)
40
+ unicode-display_width (2.1.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler-commentate!
47
+ minitest (~> 5.0)
48
+ pry (~> 0.14.1)
49
+ rake (~> 13.0)
50
+ rubocop (~> 1.7)
51
+ rubocop-minitest
52
+ rubocop-rake
53
+
54
+ BUNDLED WITH
55
+ 2.2.27
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Frank J. Cameron
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,82 @@
1
+ # Bundler::Commentate
2
+
3
+ Append gem summaries to a Gemfile.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ plugin 'bundler-commentate'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install bundler-commentate
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ $ bundle commentate -h
25
+ commentate [OPTIONS]
26
+ -i, --in-place Overwrite Gemfile
27
+ -g, --gemfile GEMFILE Gemfile input, "-" for STDIN; default is "Gemfile"
28
+ -o, --outfile GEMFILE Gemfile output, "-" for STDOUT; default is STDOUT
29
+ -v, --[no-]verbose Run verbosely
30
+ ```
31
+
32
+ ### Example
33
+
34
+ Read './Gemfile' and print annotated version to STDOUT: `bundle commentate`
35
+
36
+ ```
37
+ $ cat Gemfile
38
+ # frozen_string_literal: true
39
+ source 'https://rubygems.org'
40
+ # Specify your gem's dependencies in bundler-commentate.gemspec
41
+ gemspec
42
+ gem 'rake', '~> 13.0'
43
+ gem 'minitest', '~> 5.0'
44
+ gem 'rubocop', '~> 1.7'
45
+ gem 'rubocop-minitest'
46
+ gem 'rubocop-rake'
47
+ plugin 'bundler-commentate', path: '.'
48
+
49
+ $ bundle commentate
50
+ # frozen_string_literal: true
51
+ source 'https://rubygems.org'
52
+ # Specify your gem's dependencies in bundler-commentate.gemspec
53
+ gemspec
54
+ gem "rake", "~> 13.0" # "Rake is a Make-like program implemented in Ruby"
55
+ gem "minitest", "~> 5.0" # "minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking"
56
+ gem "rubocop", "~> 1.7" # "Automatic Ruby code style checking tool."
57
+ gem "rubocop-minitest" # "Automatic Minitest code style checking tool."
58
+ gem "rubocop-rake" # "A RuboCop plugin for Rake"
59
+ plugin 'bundler-commentate', path: '.'
60
+ ```
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install
65
+ dependencies. Then, run `rake test` to run the tests. You can also run
66
+ `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake
69
+ install`. To release a new version, update the version number in
70
+ `version.rb`, and then run `bundle exec rake release`, which will create
71
+ a git tag for the version, push git commits and the created tag, and
72
+ push the `.gem` file to [rubygems.org](https://rubygems.org).
73
+
74
+ ## Contributing
75
+
76
+ Bug reports and pull requests are welcome on GitHub at
77
+ https://gitlab.com/fjc/bundler-commentate.
78
+
79
+ ## License
80
+
81
+ The gem is available as open source under the terms of the [MIT
82
+ License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ require 'rubocop/rake_task'
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'bundler/commentate'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require 'pry'
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
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
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/bundler/commentate/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'bundler-commentate'
7
+ spec.version = Bundler::Commentate::VERSION
8
+ spec.authors = ['Frank J. Cameron']
9
+ spec.email = ['fjc@fastmail.net']
10
+
11
+ spec.summary = 'Bundler plugin to add gem summaries to a Gemfile'
12
+ spec.homepage = 'https://gitlab.com/fjc/bundler-commentate'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.7.0'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = spec.homepage
18
+ spec.metadata['changelog_uri'] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_dependency 'parser', '~> 3.0'
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Commentate < Bundler::Plugin::API
5
+ VERSION = '0.2.0'
6
+ end
7
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'commentate/version'
4
+
5
+ require 'optparse'
6
+ require 'parser/current'
7
+
8
+ module Bundler
9
+ # Add gem summaries to a Gemfile.
10
+ class Commentate < Bundler::Plugin::API
11
+ command 'commentate'
12
+
13
+ def exec(command, args)
14
+ send command, args
15
+ end
16
+
17
+ private
18
+
19
+ def commentate(args)
20
+ OptionParser.new { |opts|
21
+ opts.banner = 'commentate [OPTIONS] [GEM, GEM, ...]'
22
+
23
+ opts.on('-i' , '--in-place' , 'Overwrite Gemfile' )
24
+ opts.on('-g GEMFILE' , '--gemfile' , 'Gemfile input, "-" for STDIN; default is "Gemfile"')
25
+ opts.on('-o GEMFILE' , '--outfile' , 'Gemfile output, "-" for STDOUT; default is STDOUT' )
26
+ opts.on('-v' , '--[no-]verbose' , 'Run verbosely' )
27
+ }.parse!(args, into: (opts={}))
28
+
29
+ raise OptionParser::ParseError.new('Conflicting options: in-place, output') if opts[:'in-place'] and opts[:output]
30
+
31
+ input = _io_for(opts[:gemfile], 'r')
32
+ output = opts[:'in-place'] ? _io_for(opts[:gemfile]) : opts[:outfile] ? _io_for(opts[:outfile]) : _io_for('-')
33
+
34
+ _commentate(input, output)
35
+ rescue
36
+ raise Bundler::BundlerError.new($!)
37
+ end
38
+
39
+ # get IO for a file or stdio, default to r/w (append, create)
40
+ def _io_for(opt, mode='a+')
41
+ case opt
42
+ when nil
43
+ File.new('Gemfile', mode)
44
+ when '-'
45
+ Module.new do
46
+ def self.read(...); $stdin .read(...); end
47
+ def self.print(...); $stdout.print(...); end
48
+ def self.truncate(...); end
49
+ end
50
+ when String
51
+ File.new(opt, mode)
52
+ end
53
+ end
54
+
55
+ def _commentate(input, output)
56
+ # "Weirich convention"
57
+ # Use { } for blocks that return values
58
+ # Use do / end for blocks that are executed for side effects
59
+ input.read.tap do output.truncate(0) end.lines.each { |line|
60
+ case Parser::CurrentRuby.parse(line).to_a
61
+ in [nil, :gem, gem, ver]
62
+ output.print _commentate_line(gem, ver)
63
+ in [nil, :gem, gem]
64
+ output.print _commentate_line(gem)
65
+ else
66
+ output.print line
67
+ end
68
+ }
69
+ end
70
+
71
+ def _commentate_line(gem, ver=nil)
72
+ g = gem.deconstruct[1]
73
+ v = ver.deconstruct[1] if ver
74
+ c = Gem.latest_spec_for(g).summary
75
+ "gem #{g.inspect}#{", #{v.inspect}" if ver}\t# #{c.inspect}\n"
76
+ end
77
+ end
78
+ end
data/plugins.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/commentate'
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundler-commentate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Frank J. Cameron
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description:
28
+ email:
29
+ - fjc@fastmail.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - bin/console
42
+ - bin/setup
43
+ - bundler-commentate.gemspec
44
+ - lib/bundler/commentate.rb
45
+ - lib/bundler/commentate/version.rb
46
+ - plugins.rb
47
+ homepage: https://gitlab.com/fjc/bundler-commentate
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ homepage_uri: https://gitlab.com/fjc/bundler-commentate
52
+ source_code_uri: https://gitlab.com/fjc/bundler-commentate
53
+ changelog_uri: https://gitlab.com/fjc/bundler-commentate
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.7.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.1.6
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Bundler plugin to add gem summaries to a Gemfile
73
+ test_files: []