rbgithook 0.1.2 → 0.1.3

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: c71ca6cde42b02269ac1aeee9e663bb5b516b2fdecc66d79431b44d1562ad996
4
- data.tar.gz: 9b7eb15086882d290128c30e49a127d419957a2eb23868de0611e31cf8d52879
3
+ metadata.gz: 126208371ad980b74efb9d3f90452e9ae9b05616d177a792e07c774e206f1f26
4
+ data.tar.gz: 98e3cff68de8a6946e00084e9d96fdeb1c7a329e6e8158c8b940ad3c6b6b8389
5
5
  SHA512:
6
- metadata.gz: 28ec92618c41e81d9f6170fc708ef2299b2bcfc923efe20cdf0975dcc52ea5cac28da7f95601cec30146a81fe7f1356c17d4ecda2508bd7332a67e1e6040771f
7
- data.tar.gz: 4a027d02efb93afcd777733bb8feb2ce67a2e40a63ce22009d7bf567525fb382cff94c3f82a026324146790131cf04f0835daaa6a5e5a62f157debe0eb9c1fcb
6
+ metadata.gz: 101812bf06163703ea445fb781ccaf8457cb832ec36c37c98a7c978278232d28b12c9f4a5050d472f5d373bb10e3499865afbba7a28303dc87d93feec88752bf
7
+ data.tar.gz: cd6b654b1fba6548bc5453a885c60f8a24496cf09d35f308a6da5da0fa90c1cfff0d5233ddca7792a20e264e65b68835fff7b4a18708cbce8cd2f3b47823f952
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbgithook (0.1.2)
4
+ rbgithook (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ <img src="https://img.shields.io/github/license/hyuraku/rbgithook.svg"> <img src="https://img.shields.io/gem/v/rbgithook.svg">
1
2
  # Rbgithook
2
3
 
3
4
  Simple Git hook made by Ruby
data/Steepfile ADDED
@@ -0,0 +1,6 @@
1
+ target :lib do
2
+ signature "sig"
3
+
4
+ check "lib" # Directory name
5
+ library "fileutils"
6
+ end
data/exe/rbgithook CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "rbgithook"
4
- require "fileutils"
5
4
 
6
5
  command = ARGV[0]
7
6
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rbgithook
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/rbgithook.rb CHANGED
@@ -1,52 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "rbgithook/version"
4
+ require "fileutils"
4
5
 
5
6
  module Rbgithook
7
+ DIRNAME = ".rbgithook"
8
+
6
9
  def self.install
7
- dir = ".rbgithook"
8
- FileUtils.mkdir(dir) unless Dir.exist?(dir)
10
+ FileUtils.mkdir(DIRNAME) unless Dir.exist?(DIRNAME)
9
11
 
10
- system("git", "config", "core.hooksPath", dir)
12
+ system("git", "config", "core.hooksPath", DIRNAME)
11
13
  end
12
14
 
13
15
  def self.set(args)
14
- file_name = args[0]
15
- if file_name.nil?
16
- warn "Please specify a file to hook"
17
- exit 1
18
- end
19
- hook_command = args[1]
20
- if hook_command.nil?
21
- warn "Please specify a command to run"
22
- exit 1
16
+ file_name = get_file_name(args[0])
17
+ hook_command = get_hook_command(args[1])
18
+ Dir.chdir(DIRNAME)
19
+ File.open(file_name.to_s, "w") do |file|
20
+ file.write("#!/usr/bin/env sh\n#{hook_command}")
23
21
  end
24
- Dir.chdir(".rbgithook")
25
- file = File.open(file_name.to_s, "w")
26
- file.write("#!/usr/bin/env sh\n#{hook_command}")
27
22
  FileUtils.chmod(0o755, file_name)
28
23
  end
29
24
 
30
25
  def self.add(args)
31
- file_name = args[0]
32
- if file_name.nil?
33
- warn "Please specify a file to hook"
34
- exit 1
35
- end
36
- hook_command = args[1]
37
- if hook_command.nil?
38
- warn "Please specify a command to run"
39
- exit 1
40
- end
41
- dir_name = ".rbgithook"
42
- unless Dir.exist?(dir_name)
26
+ file_name = get_file_name(args[0])
27
+ hook_command = get_hook_command(args[1])
28
+ unless Dir.exist?(DIRNAME)
43
29
  warning_message("Directory", file_name, hook_command)
44
30
  exit 1
45
31
  end
46
- Dir.chdir(dir_name)
32
+ Dir.chdir(DIRNAME)
47
33
  if File.exist?(file_name)
48
- file = File.open(file_name.to_s, "a")
49
- file.write("\n#{hook_command}")
34
+ File.open(file_name.to_s, "a") do |file|
35
+ file.write("\n#{hook_command}")
36
+ end
50
37
  else
51
38
  warning_message("File", file_name, hook_command)
52
39
  end
@@ -58,7 +45,7 @@ module Rbgithook
58
45
 
59
46
  def self.help
60
47
  puts <<~USAGE
61
- bgithook [command] {file} {command}
48
+ rbgithook [command] {file} {command}
62
49
 
63
50
  install - Install hook
64
51
  set {file} {command} - Set a hook
@@ -71,4 +58,20 @@ module Rbgithook
71
58
  def self.warning_message(target, file_name, hook_command)
72
59
  warn "#{target} not found, please run `rbgithook set #{file_name} '#{hook_command}'`"
73
60
  end
61
+
62
+ def self.get_file_name(file_name)
63
+ if file_name.nil?
64
+ warn "Please specify a file to hook"
65
+ exit 1
66
+ end
67
+ file_name
68
+ end
69
+
70
+ def self.get_hook_command(hook_command)
71
+ if hook_command.nil?
72
+ warn "Please specify a command to run"
73
+ exit 1
74
+ end
75
+ hook_command
76
+ end
74
77
  end
data/sig/rbgithook.rbs ADDED
@@ -0,0 +1,16 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module Rbgithook
5
+ VERSION: String
6
+ DIRNAME: String
7
+
8
+ def self.install: -> void
9
+ def self.set: (Array[String] args) -> void
10
+ def self.add: (Array[String] args) -> void
11
+ def self.uninstall: -> void
12
+ def self.help: -> void
13
+ def self.warning_message: (String target, String file_name, String hook_command) -> void
14
+ def self.get_file_name: (String file_name) -> String
15
+ def self.get_hook_command: (String hook_command) -> String
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbgithook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hyuraku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-14 00:00:00.000000000 Z
11
+ date: 2022-11-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple Git hook made by Ruby
14
14
  email:
@@ -27,10 +27,12 @@ files:
27
27
  - LICENSE.txt
28
28
  - README.md
29
29
  - Rakefile
30
+ - Steepfile
30
31
  - exe/rbgithook
31
32
  - lib/rbgithook.rb
32
33
  - lib/rbgithook/version.rb
33
34
  - rbgithook.gemspec
35
+ - sig/rbgithook.rbs
34
36
  homepage: https://github.com/hyuraku/rbgithook
35
37
  licenses:
36
38
  - MIT