gig 0.0.4 → 0.0.6

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 +22 -14
  6. metadata +9 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f93b55797c23f2060a6a00602e4097d19356f80efe0f24daee2fa71c287900
4
- data.tar.gz: cbdeab6b788fbe1c54c0a18b341b667f78fb606d4b607f4564c5ae309f4d99ea
3
+ metadata.gz: f943dab3aba7fb52891beaaeb7408e835a60fc190f964f7afa6bab43145d7e81
4
+ data.tar.gz: 8b1139ef896f849a8013602ceeb16d5d370daa56ad0d0fa2e3f3ded5c7923dfe
5
5
  SHA512:
6
- metadata.gz: 026147464ac6706f93adb5ad6e13395e5a754911575493016caaf2f3761b7f207463794398290aff760af4f696d2a13237262fecc64d080bcbf41033093f02fa
7
- data.tar.gz: ba5e22da9c9bb8b6f59c8f6247991ea9465abdf21a3e4d5edbbad4964f0fd6ff0e9ba2bbc2bfc1321cd81887c54ec4886fb75e61b1476c4ea47a9106d9eca06b
6
+ metadata.gz: 3e3f4a87eee4b3bcfe6cbd517eef485efe2ebb61f902790b81455dfbba57b4d4652803ff533d10fdf816613a8221806b6310c169f554218a4a5b6a029cc4a73e
7
+ data.tar.gz: 29e571ba1108209a2fc4f1d4bafc8ff40f28b03f2f1f55c4dbde1e151fa3bdd930cb202abbc0fa81b19f2fe1d277955c8daf80331c23ff2674c7c1b67fd57de9
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.4"
4
+ VERSION = "0.0.6"
5
5
  end
data/lib/gig.rb CHANGED
@@ -6,8 +6,9 @@ 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
+ Rake.application.last_description = "check consistency of gemspec files with git and filesystem before building the gem"
11
12
  Rake::Task.define_task(name) do
12
13
  require 'shellwords'
13
14
  require 'set'
@@ -30,31 +31,38 @@ module Gig
30
31
  in_git = git_files.include?(file)
31
32
  in_fs = fs_files.include?(file)
32
33
  in_spec = spec.files.include?(file) || spec.test_files.include?(file)
34
+ in_ignore = ignore_files.include?(file)
33
35
 
34
- if in_git
35
- if in_fs
36
- if in_spec
36
+ if in_spec
37
+ if in_ignore
38
+ file_error.("file in gig ignore_files, but present in gemspec: #{file}")
39
+ end
40
+
41
+ if in_git
42
+ if in_fs
37
43
  git_status = `git status --porcelain #{Shellwords.escape(file)}`
38
44
  if git_status.empty?
39
45
  # pass
40
46
  else
41
- file_error.("file modified from git: #{file}")
47
+ file_error.("file in gemspec, but modified from git: #{file}")
42
48
  end
43
49
  else
44
- if ignore_files.include?(file)
45
- # pass
46
- else
47
- file_error.("git file not in gemspec: #{file}")
48
- end
50
+ file_error.("file in gemspec, but not in filesystem: #{file}")
49
51
  end
50
52
  else
51
- file_error.("git file not in fs: #{file}")
53
+ if in_fs
54
+ file_error.("file in gemspec and filesystem, but not in git: #{file}")
55
+ else
56
+ file_error.("file in gemspec, but not in git and not in filesystem: #{file}")
57
+ end
52
58
  end
59
+ elsif in_ignore
60
+ # in ignore_files, and not in gemspec: pass (regardless of git or fs)
53
61
  else
54
- if in_spec
55
- file_error.("file in gemspec but not in git: #{file}")
62
+ if in_git
63
+ file_error.("file in git, but in neither gemspec nor gig ignore_files: #{file}")
56
64
  else
57
- # in fs but ignored by git and spec: pass
65
+ # not in gemspec, not in ignore_files, not in git: pass - it's in the filesystem but can be ignored
58
66
  end
59
67
  end
60
68
  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.4
4
+ version: 0.0.6
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-01 00:00:00.000000000 Z
11
+ date: 2023-01-10 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.1.6
60
+ signing_key:
59
61
  specification_version: 4
60
62
  summary: gig
61
63
  test_files: []