rbgithook 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: 95e4c3d3d31aa463261aea3d6cc34e793656610052eda0a95957b8dc8e53e4b4
4
- data.tar.gz: ac2186f68558a37b04572a5c4da527e5aafcf705bb1ac99dcc74bd57bf22d5b0
3
+ metadata.gz: 3f972f2dc37dc0d5ab6ee45fc28370053c0b987bb9e95f641e2a1f66ecdbc2e2
4
+ data.tar.gz: 4b3ac378a6315e18e945e1ada3021955227415e3b2ec2b690f0cad4fb219bb29
5
5
  SHA512:
6
- metadata.gz: 4c776ba19bffbd09fb172e0d35e3ccb51b2d4fbcbcc0b145b56a1ed5295ffb84283b8ecf00409f79d4d0e523f97fc46fc90be9018790af2c298534185a0a8834
7
- data.tar.gz: 8864dd8eeebb383a57cfa344d0813525591e44c28ae9acde92607b275a328a06e91ce34ca5b1200e7d2ae5f9ca7fd9e15d1f1c4233a41ec49d975455ac4fb3e5
6
+ metadata.gz: 8f4b12920b3fa7c693baf53fe8f2a8669d72d35625b31fbdf9292bb7bc4d991c5c8e1208abfc8d84883afe5dd930f514e4fb0237a8ada1fe00e1be67dc07f9be
7
+ data.tar.gz: b29b5234694d0f17c44493eaf0d61a9a82eb87c9376dc409314f1cfd5570e9c184285551fed027ee452fdf834fc9c576676c258ff8159c11f5b91e3b3e3bc829
@@ -1 +1,3 @@
1
+ #!/usr/bin/env sh
2
+
1
3
  bundle exec rspec spec/
data/.rubocop.yml CHANGED
@@ -11,3 +11,9 @@ Style/StringLiteralsInInterpolation:
11
11
 
12
12
  Layout/LineLength:
13
13
  Max: 120
14
+
15
+ Style/FrozenStringLiteralComment:
16
+ Enabled: false
17
+
18
+ Style/Documentation:
19
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbgithook (0.1.0)
4
+ rbgithook (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -44,6 +44,7 @@ GEM
44
44
 
45
45
  PLATFORMS
46
46
  arm64-darwin-21
47
+ x86_64-linux
47
48
 
48
49
  DEPENDENCIES
49
50
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rbgithook
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rbgithook`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Simple Git hook made by Ruby
4
4
 
5
5
  ## Installation
6
6
 
@@ -22,8 +22,9 @@ Or install it yourself as:
22
22
 
23
23
  ```
24
24
  rbgithook install
25
- rbgithook <file> <cmd> ex. rbgithook pre-commit "rspec spec/"
26
- rbgithook
25
+ rbgithook set <file> <cmd> ex. rbgithook add pre-commit "rspec spec/"
26
+ rbgithook add <file> <cmd> ex. rbgithook add pre-commit "rubocop -a"
27
+ rbgithook uninstall
27
28
  ```
28
29
 
29
30
  ## Contributing
data/exe/rbgithook CHANGED
@@ -6,9 +6,8 @@ require "fileutils"
6
6
  command = ARGV[0]
7
7
  args = ARGV[1..]
8
8
 
9
- if command == "add"
10
- Rbgithook.add(args)
9
+ if %w[add set].include?(command)
10
+ Rbgithook.send(command, args)
11
11
  else
12
12
  Rbgithook.send(command)
13
13
  end
14
-
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rbgithook
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/rbgithook.rb CHANGED
@@ -10,15 +10,29 @@ module Rbgithook
10
10
  system("git", "config", "core.hooksPath", dir)
11
11
  end
12
12
 
13
- def self.add(args)
13
+ def self.set(args)
14
14
  file_name = args[0]
15
15
  hook_command = args[1]
16
16
  Dir.chdir(".rbgithook")
17
17
  file = File.open(file_name.to_s, "w")
18
+ file.write("#!/usr/bin/env sh\n")
18
19
  file.write(hook_command)
19
20
  FileUtils.chmod(0o755, file_name)
20
21
  end
21
22
 
23
+ def self.add(args)
24
+ file_name = args[0]
25
+ hook_command = args[1]
26
+ Dir.chdir(".rbgithook")
27
+ if File.exist?(file_name)
28
+ file = File.open(file_name.to_s, "a")
29
+ file.write("\n#{hook_command}")
30
+ FileUtils.chmod(0o755, file_name)
31
+ else
32
+ warn "File not found, please run `rbgithook set #{file_name} #{hook_command}`"
33
+ end
34
+ end
35
+
22
36
  def self.uninstall
23
37
  system("git", "config", "--unset", "core.hooksPath")
24
38
  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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hyuraku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple Git hook made by Ruby
14
14
  email: