organize_gemfile 0.1.0 → 0.1.2

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: 22aa5242f1a189d3cddddb4b6086c50c89d948d18d6cb047dce073d3599399be
4
+ data.tar.gz: e4f5d8a161d25ee9368a22ec3c20761319702c130abd89462dcc708cf0a54a86
5
5
  SHA512:
6
- metadata.gz: d6d1f7a14e538d7fb92628e47e3b207ad325932df0ef1dc57e2e8b00e9af22b7c065617d4479f0aa63a96f8337f178cd34a45c630b3f4a74149822344bf76954
7
- data.tar.gz: f70ee5720b715078afd079df17410fa6aeff0d331bb5b30504778d934312eef2eb1282842465430a945adbe7330922a8bf7f7149ec3eca346d18e61e5cb55f6e
6
+ metadata.gz: 6dc94259988d8048341aaa16f096815b92b68fbe6715f6d0898496b1dc58b7c5fc6200c2c8d29d70d557928f1925f5b1f2873cd362442f7e9d4204960ecb10e2
7
+ data.tar.gz: 6e9e5390bc008577cdaed3fac08c4bc604e11b2a309bf2dd50242319b7d0b23cce999b15043e0e4072af1fae74156b2e3b6520394cbc4a6c3f546c15e0e15fa4
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.1)
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
 
@@ -20,14 +21,15 @@ task :build do
20
21
  system "gem build #{GEM_NAME}.gemspec"
21
22
  end
22
23
 
23
- task :install => :build do
24
+ task install: :build do
24
25
  system "gem install #{GEM_NAME}-#{GEM_VERSION}.gem"
25
26
  end
26
27
 
27
- task :publish => :build do
28
+ task publish: :build do
28
29
  system "gem push #{GEM_NAME}-#{GEM_VERSION}.gem"
30
+ system "gem push --key github --host https://rubygems.pkg.github.com/coderberry #{GEM_NAME}-#{GEM_VERSION}.gem"
29
31
  end
30
32
 
31
33
  task :clean do
32
34
  system "rm *.gem"
33
- end
35
+ 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
@@ -6,7 +6,7 @@ module OrganizeGemfile
6
6
  @gemfile_path = gemfile_path
7
7
  @ruby_version = ruby_version
8
8
  @groups = groups
9
- new_gemfile_code = build
9
+ build
10
10
  end
11
11
 
12
12
  def build
@@ -45,4 +45,4 @@ module OrganizeGemfile
45
45
  @groups["default"]
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -38,6 +38,13 @@ module OrganizeGemfile
38
38
  spec = specs.key?(dep.name) ? specs[dep.name] : nil
39
39
  spec = spec&.to_spec
40
40
 
41
+ version = dep.requirement.to_s
42
+ if version.nil? || version == "" || version == ">= 0"
43
+ if spec&.version
44
+ version = "~> #{spec.version}"
45
+ end
46
+ end
47
+
41
48
  {
42
49
  name: dep.name,
43
50
  summary: spec&.summary,
@@ -47,10 +54,10 @@ module OrganizeGemfile
47
54
  branch: dep.branch,
48
55
  platforms: dep.platforms,
49
56
  gemfile: dep.gemfile,
50
- version: dep.requirement.to_s,
57
+ version: version,
51
58
  source: dep.source,
52
59
  requires: @requires[dep.name],
53
- appear_at_top: @requires[dep.name].include?("dotenv/rails-now")
60
+ appear_at_top: dep.name.include?("dotenv/rails-now")
54
61
  }
55
62
  end
56
63
  end
@@ -20,9 +20,21 @@ 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"
24
- parts << "require: \"#{spec[:requires].first}\"" if spec[:requires].first && spec[:requires].first != spec[:name]
23
+
24
+ if spec[:version] && spec[:version] != ">= 0"
25
+ version_parts = []
26
+ spec[:version].split(",").each do |version|
27
+ version_parts << "\"#{version.strip}\""
28
+ end
29
+ parts << version_parts.join(", ")
30
+ end
31
+
32
+ require_name = spec[:requires]&.first
33
+ if require_name != spec[:name] && !require_name.nil? && require_name != ""
34
+ parts << "require: \"#{require_name}\""
35
+ end
25
36
  parts << "require: false" if spec[:requires] == []
37
+ parts << "path: \"#{spec[:source].path}\"" if spec[:source]
26
38
  parts << "platforms: %i[ #{spec[:platforms].join(" ")} ]" if spec[:platforms].any?
27
39
  line = parts.join(", ")
28
40
 
@@ -40,6 +52,9 @@ module OrganizeGemfile
40
52
  if spec[:summary]
41
53
  line = line.ljust(max_length)
42
54
  line += " # #{spec[:summary]}"
55
+ if spec[:homepage]
56
+ line += " [#{spec[:homepage]}]"
57
+ end
43
58
  end
44
59
  lines << indent_spaces + line
45
60
  end
@@ -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.2"
5
5
  end
@@ -1,16 +1,29 @@
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"
3
+ require_relative "organize_gemfile/bundle_parser"
4
+ require_relative "organize_gemfile/gemfile_group"
5
+ require_relative "organize_gemfile/builder"
6
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
28
  gemfile_lock_path = File.expand_path("Gemfile.lock")
16
29
  raise "Gemfile.lock not found" unless File.exist?(gemfile_lock_path)
@@ -18,7 +31,32 @@ module OrganizeGemfile
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.write(gemfile_path, 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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Berry
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-06 00:00:00.000000000 Z
11
+ date: 2022-10-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Organize your Gemfile with annotations
14
14
  email:
@@ -32,7 +32,6 @@ files:
32
32
  - lib/organize_gemfile/bundle_parser.rb
33
33
  - lib/organize_gemfile/gemfile_group.rb
34
34
  - lib/organize_gemfile/version.rb
35
- - organize_gemfile.gemspec
36
35
  - sig/organize_gemfile.rbs
37
36
  homepage: https://github.com/coderberry/organize_gemfile
38
37
  licenses:
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/organize_gemfile/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "organize_gemfile"
7
- spec.version = OrganizeGemfile::VERSION
8
- spec.authors = ["Eric Berry"]
9
- spec.email = ["eric@berry.sh"]
10
-
11
- spec.summary = "Organize your Gemfile with annotations"
12
- spec.description = spec.summary
13
- spec.homepage = "https://github.com/coderberry/organize_gemfile"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
16
-
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = spec.homepage
21
- spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
22
-
23
- # Specify which files should be added to the gem when it is released.
24
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject do |f|
27
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
- end
29
- end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
33
-
34
- # Uncomment to register a new dependency of your gem
35
- # spec.add_dependency "example-gem", "~> 1.0"
36
-
37
- # For more information and examples about making a new gem, check out our
38
- # guide at: https://bundler.io/guides/creating_gem.html
39
- end