gig 0.0.5 → 0.0.7

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -0
  3. data/gig.gemspec +28 -0
  4. data/lib/gig/version.rb +1 -1
  5. data/lib/gig.rb +23 -19
  6. metadata +9 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5824cec3310a22127e9e6fcdd09bd8ff7dd630a0fe962cb7d34a33f7b9a14f82
4
- data.tar.gz: 93d618046e0d53530239adae5a45be06787e7a21877eb8ef710be511c83ddf63
3
+ metadata.gz: 785f02b1f7a04d0fa96af92511cf12c29a1c763b7d43025121c98b099b1691e7
4
+ data.tar.gz: 144e595ca087d97893d91cb33057748061bb8b096c2418941339a3af51807636
5
5
  SHA512:
6
- metadata.gz: ce2d191605eeb94d1477f4e3ba74a84ddd96de98f3a56308b14e9563275ba79b80b86381854cf8172dbe437a462a7f0f5873d0a15b313dadccfab8233bbf7808
7
- data.tar.gz: 31924bae77ce18d61e7dd9d023080cb7e69b1def46fa665bbe05c2e5d7e19e63364f8de60aafe90f1e8aa7bf8e07b64c2cd47b0baa5f802e56fce7cd48eca885
6
+ metadata.gz: a77901432fc4f2d3fef4801e10359ab6dd7194e3fdf008fefa637a1066fbe12dde02d203e1caf64bfd302e9ce9b12dbfd0b332a45216f1f41d3c187982bb8d14
7
+ data.tar.gz: 8016de8c6e26aa710017abb65cab68051e244660b57ff9486878585eaa8dfc19259828cc0f401574a3936cbdc7253013b9b1c95146e5ba87cc3cf705ce33c3cb
data/README.md CHANGED
@@ -1,5 +1,23 @@
1
1
  `gig` contains a rake task of the same name to check for consistency of files between git, gemspec, and the filesystem before building.
2
2
 
3
+ ## Usage
4
+
5
+ In your rakefile, `require 'gig'` and invoke [Gig.make_task](https://rubydoc.info/gems/gig/Gig), passing `gemspec_filename` and `ignore_files`. Globs are useful for `ignore_files`, and `File::FNM_DOTMATCH` should be used when globs may contain dotfiles. For example:
6
+
7
+ ```ruby
8
+ require 'gig'
9
+
10
+ ignore_files = %w(
11
+ .github/**/*
12
+ .gitignore
13
+ .gitmodules
14
+ Gemfile
15
+ Rakefile.rb
16
+ test/**/*
17
+ ).map { |glob| Dir.glob(glob, File::FNM_DOTMATCH) }.inject([], &:|)
18
+ Gig.make_task(gemspec_filename: 'my_gem.gemspec', ignore_files: ignore_files)
19
+ ```
20
+
3
21
  ## License
4
22
 
5
23
  The gem is available under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/gig.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "gig/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "gig"
9
+ spec.version = Gig::VERSION
10
+ spec.authors = ["Ethan"]
11
+ spec.email = ["ethan@unth.net"]
12
+
13
+ spec.summary = "gig"
14
+ spec.description = "a rake task to check a gem's consistency with git and the filesystem before building"
15
+ spec.homepage = "https://github.com/notEthan/gig"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = [
19
+ 'LICENSE.txt',
20
+ 'README.md',
21
+ 'gig.gemspec',
22
+ *Dir['lib/**/*'],
23
+ ].reject { |f| File.lstat(f).ftype == 'directory' }
24
+
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency 'rake'
28
+ end
data/lib/gig/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gig
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.7"
5
5
  end
data/lib/gig.rb CHANGED
@@ -6,7 +6,7 @@ module Gig
6
6
  class << self
7
7
  # @param name [#to_s] rake task name
8
8
  # @param gemspec_filename
9
- # @param ignore_files [Enumerable]
9
+ # @param ignore_files [Enumerable<String>]
10
10
  def make_task(name: 'gig', gemspec_filename: , ignore_files: )
11
11
  Rake.application.last_description = "check consistency of gemspec files with git and filesystem before building the gem"
12
12
  Rake::Task.define_task(name) do
@@ -18,8 +18,9 @@ module Gig
18
18
  fs_files = Dir.glob('**/*', File::FNM_DOTMATCH).reject { |f| File.lstat(f).ftype == 'directory' }
19
19
 
20
20
  spec = Gem::Specification.load(gemspec_filename) || abort("gemspec did not load: #{gemspec_filename}")
21
+ spec_files = spec.files + spec.test_files + spec.executables.map { |fn| File.join(spec.bindir, fn) }
21
22
 
22
- files = Set.new + git_files + fs_files + spec.files + spec.test_files
23
+ files = Set.new + git_files + fs_files + spec_files
23
24
 
24
25
  file_errors = []
25
26
  file_error = -> (msg) {
@@ -30,36 +31,39 @@ module Gig
30
31
  files.each do |file|
31
32
  in_git = git_files.include?(file)
32
33
  in_fs = fs_files.include?(file)
33
- in_spec = spec.files.include?(file) || spec.test_files.include?(file)
34
+ in_spec = spec_files.include?(file)
34
35
  in_ignore = ignore_files.include?(file)
35
36
 
36
- if in_git
37
- if in_fs
38
- if in_spec
39
- if in_ignore
40
- file_error.("file is ignored, but present in gemspec: #{file}")
41
- end
37
+ if in_spec
38
+ if in_ignore
39
+ file_error.("file in gig ignore_files, but present in gemspec: #{file}")
40
+ end
41
+
42
+ if in_git
43
+ if in_fs
42
44
  git_status = `git status --porcelain #{Shellwords.escape(file)}`
43
45
  if git_status.empty?
44
46
  # pass
45
47
  else
46
- file_error.("file modified from git: #{file}")
48
+ file_error.("file in gemspec, but modified from git: #{file}")
47
49
  end
48
50
  else
49
- if in_ignore
50
- # pass
51
- else
52
- file_error.("git file not in gemspec: #{file}")
53
- end
51
+ file_error.("file in gemspec, but not in filesystem: #{file}")
54
52
  end
55
53
  else
56
- file_error.("git file not in fs: #{file}")
54
+ if in_fs
55
+ file_error.("file in gemspec and filesystem, but not in git: #{file}")
56
+ else
57
+ file_error.("file in gemspec, but not in git and not in filesystem: #{file}")
58
+ end
57
59
  end
60
+ elsif in_ignore
61
+ # in ignore_files, and not in gemspec: pass (regardless of git or fs)
58
62
  else
59
- if in_spec
60
- file_error.("file in gemspec but not in git: #{file}")
63
+ if in_git
64
+ file_error.("file in git, but in neither gemspec nor gig ignore_files: #{file}")
61
65
  else
62
- # in fs but ignored by git and spec: pass
66
+ # not in gemspec, not in ignore_files, not in git: pass - it's in the filesystem but can be ignored
63
67
  end
64
68
  end
65
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-04 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,7 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: ''
27
+ description: a rake task to check a gem's consistency with git and the filesystem
28
+ before building
28
29
  email:
29
30
  - ethan@unth.net
30
31
  executables: []
@@ -33,13 +34,14 @@ extra_rdoc_files: []
33
34
  files:
34
35
  - LICENSE.txt
35
36
  - README.md
37
+ - gig.gemspec
36
38
  - lib/gig.rb
37
39
  - lib/gig/version.rb
38
40
  homepage: https://github.com/notEthan/gig
39
41
  licenses:
40
42
  - MIT
41
43
  metadata: {}
42
- post_install_message:
44
+ post_install_message:
43
45
  rdoc_options: []
44
46
  require_paths:
45
47
  - lib
@@ -54,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
56
  - !ruby/object:Gem::Version
55
57
  version: '0'
56
58
  requirements: []
57
- rubygems_version: 3.1.2
58
- signing_key:
59
+ rubygems_version: 3.5.22
60
+ signing_key:
59
61
  specification_version: 4
60
62
  summary: gig
61
63
  test_files: []