organize_gemfile 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d2b9281b4ed27d214456d4e96e33a6254f8002731df1ad29e947778c93db77f
4
- data.tar.gz: f7e1c47f3869d94c961a5dada7e1b151f01b4298a8ba3a54d02206a5d99b0635
3
+ metadata.gz: 6e792164dde3e1157e0f179ab1fa026958c556b097436aacbd0bdaf829c52f76
4
+ data.tar.gz: 3b867429dade0acb09cb736ee9cd069e8265a4fd8f3d5a2b5cee3e15772bc54c
5
5
  SHA512:
6
- metadata.gz: d6d1f7a14e538d7fb92628e47e3b207ad325932df0ef1dc57e2e8b00e9af22b7c065617d4479f0aa63a96f8337f178cd34a45c630b3f4a74149822344bf76954
7
- data.tar.gz: f70ee5720b715078afd079df17410fa6aeff0d331bb5b30504778d934312eef2eb1282842465430a945adbe7330922a8bf7f7149ec3eca346d18e61e5cb55f6e
6
+ metadata.gz: f3da6ad4029a3b19f9c1d823906a48f0b267a10a6faedeb082d85025573b8ce671d731852884d0ab72d06178574f077fdd8fae553e5baac8ab238bcf77f07d83
7
+ data.tar.gz: c0a1e837ff3ad854566c54b6f9593e0cdd4d048cf719055efedd509ca6dbe5d076087a827223cf7e8e9325d873b5d7b083247b1916c4088217259a34c0522614
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
- ## [Unreleased]
1
+ ## [0.1.1] - 2022-09-07
2
+
3
+ - Add `--help` and `--gemfile=` options
4
+ - Overwrite existing Gemfile
2
5
 
3
6
  ## [0.1.0] - 2022-06-19
4
7
 
data/Gemfile CHANGED
@@ -1,10 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
1
  source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
3
 
5
- # Specify your gem's dependencies in organize_gemfile.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
- gem "minitest", "~> 5.0"
10
- gem "standard", "~> 1.3"
4
+ gem "minitest", "~> 5.0" # minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
5
+ gem "organize_gemfile" # Organize your Gemfile with annotations
6
+ gem "rake", "~> 13.0" # Rake is a Make-like program implemented in Ruby
7
+ gem "standard", "~> 1.3" # Ruby Style Guide, with linter & automatic code fixer
8
+ gem "bump", "~> 0.6" # Bump is a command line tool to help you version your Ruby projects
data/Gemfile.lock CHANGED
@@ -1,48 +1,48 @@
1
- PATH
2
- remote: .
3
- specs:
4
- organize_gemfile (0.1.0)
5
-
6
1
  GEM
7
2
  remote: https://rubygems.org/
8
3
  specs:
9
4
  ast (2.4.2)
10
- minitest (5.16.0)
5
+ bump (0.10.0)
6
+ json (2.6.2)
7
+ minitest (5.16.3)
8
+ organize_gemfile (0.1.0)
11
9
  parallel (1.22.1)
12
- parser (3.1.2.0)
10
+ parser (3.1.2.1)
13
11
  ast (~> 2.4.1)
14
12
  rainbow (3.1.1)
15
13
  rake (13.0.6)
16
14
  regexp_parser (2.5.0)
17
15
  rexml (3.2.5)
18
- rubocop (1.29.0)
16
+ rubocop (1.35.1)
17
+ json (~> 2.3)
19
18
  parallel (~> 1.10)
20
- parser (>= 3.1.0.0)
19
+ parser (>= 3.1.2.1)
21
20
  rainbow (>= 2.2.2, < 4.0)
22
21
  regexp_parser (>= 1.8, < 3.0)
23
22
  rexml (>= 3.2.5, < 4.0)
24
- rubocop-ast (>= 1.17.0, < 2.0)
23
+ rubocop-ast (>= 1.20.1, < 2.0)
25
24
  ruby-progressbar (~> 1.7)
26
25
  unicode-display_width (>= 1.4.0, < 3.0)
27
- rubocop-ast (1.17.0)
26
+ rubocop-ast (1.21.0)
28
27
  parser (>= 3.1.1.0)
29
- rubocop-performance (1.13.3)
28
+ rubocop-performance (1.14.3)
30
29
  rubocop (>= 1.7.0, < 2.0)
31
30
  rubocop-ast (>= 0.4.0)
32
31
  ruby-progressbar (1.11.0)
33
- standard (1.12.0)
34
- rubocop (= 1.29.0)
35
- rubocop-performance (= 1.13.3)
36
- unicode-display_width (2.1.0)
32
+ standard (1.16.1)
33
+ rubocop (= 1.35.1)
34
+ rubocop-performance (= 1.14.3)
35
+ unicode-display_width (2.2.0)
37
36
 
38
37
  PLATFORMS
39
38
  arm64-darwin-21
40
39
 
41
40
  DEPENDENCIES
41
+ bump (~> 0.6)
42
42
  minitest (~> 5.0)
43
- organize_gemfile!
43
+ organize_gemfile
44
44
  rake (~> 13.0)
45
45
  standard (~> 1.3)
46
46
 
47
47
  BUNDLED WITH
48
- 2.3.10
48
+ 2.3.17
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Organize Gemfile
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/organize_gemfile.svg)](https://badge.fury.io/rb/organize_gemfile)
4
+
3
5
  Organizize your Gemfile with this gem.
4
6
 
5
7
  ## Installation
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ Rake::TestTask.new(:test) do |t|
13
13
  end
14
14
 
15
15
  require "standard/rake"
16
+ require "bump/tasks"
16
17
 
17
18
  task default: %i[test standard]
18
19
 
@@ -30,4 +31,4 @@ end
30
31
 
31
32
  task :clean do
32
33
  system "rm *.gem"
33
- end
34
+ end
data/exe/organize_gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "organize_gemfile"
3
- puts OrganizeGemfile::execute
3
+ puts OrganizeGemfile::execute ARGV
@@ -20,7 +20,13 @@ module OrganizeGemfile
20
20
  spec_lines = specs.sort_by { |s| s[:name] }.map do |spec|
21
21
  parts = []
22
22
  parts << "gem \"#{spec[:name]}\""
23
- parts << "\"#{spec[:version]}\"" if spec[:version] && spec[:version] != ">= 0"
23
+ if spec[:version] && spec[:version] != ">= 0"
24
+ version_parts = []
25
+ spec[:version].split(",").each do |version|
26
+ version_parts << "\"#{version.strip}\""
27
+ end
28
+ parts << version_parts.join(", ")
29
+ end
24
30
  parts << "require: \"#{spec[:requires].first}\"" if spec[:requires].first && spec[:requires].first != spec[:name]
25
31
  parts << "require: false" if spec[:requires] == []
26
32
  parts << "platforms: %i[ #{spec[:platforms].join(" ")} ]" if spec[:platforms].any?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OrganizeGemfile
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -1,24 +1,62 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "organize_gemfile/bundle_parser.rb"
4
- require_relative "organize_gemfile/gemfile_group.rb"
5
- require_relative "organize_gemfile/builder.rb"
6
- require_relative "organize_gemfile/version"
3
+ require_relative 'organize_gemfile/bundle_parser.rb'
4
+ require_relative 'organize_gemfile/gemfile_group.rb'
5
+ require_relative 'organize_gemfile/builder.rb'
6
+ require_relative 'organize_gemfile/version'
7
+ require 'optparse'
7
8
 
8
9
  module OrganizeGemfile
9
- class Error < StandardError; end
10
+ class Error < StandardError
11
+ end
12
+
13
+ def self.execute(*args)
14
+ options = parse_options(args)
15
+
16
+ gemfile_path = options[:gemfile] ||= File.expand_path('Gemfile')
17
+ unless File.exist?(gemfile_path)
18
+ puts "Gemfile not found at #{gemfile_path}"
19
+ return
20
+ end
10
21
 
11
- def self.execute
12
- gemfile_path = File.expand_path("Gemfile")
13
- raise "Gemfile not found" unless File.exist?(gemfile_path)
22
+ gemfile_lock_path = Pathname.new(gemfile_path).parent.join('Gemfile.lock')
23
+ unless gemfile_lock_path.exist?
24
+ puts "Gemfile.lock not found at #{gemfile_lock_path}. Be sure to run `bundle install` before running this command."
25
+ return
26
+ end
14
27
 
15
- gemfile_lock_path = File.expand_path("Gemfile.lock")
16
- raise "Gemfile.lock not found" unless File.exist?(gemfile_lock_path)
28
+ gemfile_lock_path = File.expand_path('Gemfile.lock')
29
+ raise 'Gemfile.lock not found' unless File.exist?(gemfile_lock_path)
17
30
 
18
31
  parser = BundleParser.new(gemfile_path, gemfile_lock_path)
19
32
  ruby_version = parser.ruby_version
20
33
  groups = parser.groups
21
- builder = Builder.new(gemfile_path, ruby_version: ruby_version, groups: groups)
22
- builder.build
34
+ builder =
35
+ Builder.new(gemfile_path, ruby_version: ruby_version, groups: groups)
36
+ revised_gemfile = builder.build
37
+
38
+ File.open(gemfile_path, 'w') { |f| f.write(revised_gemfile) }
39
+
40
+ puts 'Gemfile organized!'
41
+ end
42
+
43
+ def self.parse_options(args)
44
+ options = {}
45
+
46
+ opts = OptionParser.new
47
+ opts.banner = 'Usage: organize_gemfile [options]'
48
+
49
+ opts.on('-h', '--help', 'Prints this help') do
50
+ puts opts
51
+ exit
52
+ end
53
+
54
+ opts.on('-gPATH', '--gemfile=PATH', 'Path to Gemfile') do |path|
55
+ options[:gemfile] = File.expand_path(path)
56
+ end
57
+
58
+ opts.parse!(into: options)
59
+
60
+ options
23
61
  end
24
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: organize_gemfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Berry
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-06 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Organize your Gemfile with annotations
14
14
  email:
@@ -42,7 +42,7 @@ metadata:
42
42
  homepage_uri: https://github.com/coderberry/organize_gemfile
43
43
  source_code_uri: https://github.com/coderberry/organize_gemfile
44
44
  changelog_uri: https://github.com/coderberry/organize_gemfile/CHANGELOG.md
45
- post_install_message:
45
+ post_install_message:
46
46
  rdoc_options: []
47
47
  require_paths:
48
48
  - lib
@@ -57,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.3.7
61
- signing_key:
60
+ rubygems_version: 3.1.6
61
+ signing_key:
62
62
  specification_version: 4
63
63
  summary: Organize your Gemfile with annotations
64
64
  test_files: []