amusing_git 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +56 -0
- data/lib/amusing_git/amuser.rb +9 -17
- data/lib/amusing_git/config/config.rb +35 -0
- data/lib/amusing_git/git/git_repository.rb +3 -2
- data/lib/amusing_git/setup.rb +2 -1
- data/lib/amusing_git/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 040c82e8c62df3cf78ab5c5823b886c3ec9b9f65
|
4
|
+
data.tar.gz: 0abd1e0c1a7640df1673ef47b6d8fe6479f3c056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a43a6a6ef0b95d5a1fe29e5006e08f50e9292f0cadaf2cdaa7198e6a1989eb134b9aab4201da2d71a1b37dab12a2f3a21e2e2079ff562d08648b510b78933385
|
7
|
+
data.tar.gz: b5e7ebf7edbf0723112058e000af09568661493ac889a279a4a99978acd9e6fbc02f6cf0c1d32ccbf4ec29f7622eadc27b3fca3f3e33d3ba066cc6ffffccf88e
|
data/README.md
CHANGED
@@ -1,2 +1,58 @@
|
|
1
1
|
# amusing_git
|
2
2
|
Brings fun to the git workflow
|
3
|
+
|
4
|
+
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://opensource.org/licenses/MIT)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/amusing_git.svg)](https://badge.fury.io/rb/gocd)
|
6
|
+
![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/amusing_git?type=total)
|
7
|
+
[![Twitter Follow](https://img.shields.io/twitter/follow/Ajit5ingh.svg?style=social)](https://twitter.com/Ajit5ingh)
|
8
|
+
|
9
|
+
### Installation
|
10
|
+
```bash
|
11
|
+
gem install amusing_git
|
12
|
+
```
|
13
|
+
|
14
|
+
### Usage
|
15
|
+
```bash
|
16
|
+
Commands:
|
17
|
+
amusing_git amuse # Print random message from configured messages, use `amusing_git help amuse` to know how to add your own messages
|
18
|
+
amusing_git help [COMMAND] # Describe available commands or one specific command
|
19
|
+
amusing_git setup # Setup amusing git
|
20
|
+
amusing_git start # Start amusing for the current git repository
|
21
|
+
amusing_git stop # Stop amusing for the current git repository
|
22
|
+
```
|
23
|
+
|
24
|
+
Install the amusing_git gem using the above command. Go to your git repository and type
|
25
|
+
```bash
|
26
|
+
amusing_git start
|
27
|
+
```
|
28
|
+
After the above command whenever you pull or push the code to remote, amusing_git will amuse you some interesting quotes.
|
29
|
+
To stop amusing_git for any git repository just type below command.
|
30
|
+
```bash
|
31
|
+
amusing_git stop
|
32
|
+
```
|
33
|
+
|
34
|
+
LICENSE
|
35
|
+
-------
|
36
|
+
|
37
|
+
```LICENSE
|
38
|
+
MIT License
|
39
|
+
|
40
|
+
Copyright (c) 2018 Ajit Singh
|
41
|
+
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
43
|
+
of this software and associated documentation files (the "Software"), to deal
|
44
|
+
in the Software without restriction, including without limitation the rights
|
45
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
46
|
+
copies of the Software, and to permit persons to whom the Software is
|
47
|
+
furnished to do so, subject to the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be included in all
|
50
|
+
copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
53
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
54
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
55
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
56
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
57
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
58
|
+
SOFTWARE.
|
data/lib/amusing_git/amuser.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
require_relative './pretty_printer'
|
2
2
|
require_relative './git/git_repository'
|
3
|
+
require_relative './config/config'
|
3
4
|
|
4
5
|
module AmusingGit
|
5
6
|
class Amuser
|
6
7
|
include AmusingGit::PrettyPrinter
|
7
8
|
|
9
|
+
def initialize
|
10
|
+
@config = AmusingGit::Config.new
|
11
|
+
end
|
12
|
+
|
8
13
|
def amuse
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
rescue
|
13
|
-
print_error "Error reading amusing git config file\n"
|
14
|
-
return
|
15
|
-
end
|
14
|
+
msgs = @config.messages
|
15
|
+
return if msgs.empty?
|
16
|
+
print_info(msgs[rand(0..msgs.size-1)] + "\n")
|
16
17
|
end
|
17
18
|
|
18
19
|
def start_amusing(dir)
|
@@ -21,7 +22,7 @@ module AmusingGit
|
|
21
22
|
return
|
22
23
|
end
|
23
24
|
|
24
|
-
git_repository = AmusingGit::GitRepository.new dir
|
25
|
+
git_repository = AmusingGit::GitRepository.new dir, @config
|
25
26
|
git_repository.create_hooks! unless git_repository.has_hooks?
|
26
27
|
git_repository.configure_amusing_git!
|
27
28
|
|
@@ -40,14 +41,5 @@ module AmusingGit
|
|
40
41
|
|
41
42
|
print_success "Done :)\n"
|
42
43
|
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def messages
|
46
|
-
File.read(config["messages"]).split("\n")
|
47
|
-
end
|
48
|
-
|
49
|
-
def config
|
50
|
-
JSON.parse(File.read("#{ENV["HOME"]}/.amusing_git/config"))
|
51
|
-
end
|
52
44
|
end
|
53
45
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative '../pretty_printer'
|
3
|
+
|
4
|
+
module AmusingGit
|
5
|
+
class Config
|
6
|
+
include AmusingGit::PrettyPrinter
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@config = read_config
|
10
|
+
end
|
11
|
+
|
12
|
+
def messages
|
13
|
+
messages_file = @config["messages"]
|
14
|
+
if messages_file.nil?
|
15
|
+
print_error("AmusingGit: messages file not found...\n")
|
16
|
+
return []
|
17
|
+
end
|
18
|
+
File.read(messages_file).split("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def hooks
|
22
|
+
@config["hooks"] || []
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def read_config
|
27
|
+
begin
|
28
|
+
JSON.parse(File.read("#{ENV["HOME"]}/.amusing_git/config"))
|
29
|
+
rescue
|
30
|
+
print_error("AmusingGit: Error reading config file.. To fix the issue delete the $HOME/.amusing_git dir and run `amusing_git setup`\n")
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -2,8 +2,9 @@ require_relative './git_hook'
|
|
2
2
|
|
3
3
|
module AmusingGit
|
4
4
|
class GitRepository
|
5
|
-
def initialize(dir)
|
5
|
+
def initialize(dir, config)
|
6
6
|
@dir = dir
|
7
|
+
@hooks = config.hooks
|
7
8
|
end
|
8
9
|
|
9
10
|
def has_hooks?
|
@@ -33,7 +34,7 @@ module AmusingGit
|
|
33
34
|
|
34
35
|
private
|
35
36
|
def hooks
|
36
|
-
|
37
|
+
@hooks.map { |hook_name| "#{@dir}/.git/hooks/#{hook_name}" }.map { |h| AmusingGit::GitHook.new h}
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
data/lib/amusing_git/setup.rb
CHANGED
data/lib/amusing_git/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amusing_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ajit Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/amusing_git.rb
|
55
55
|
- lib/amusing_git/amuser.rb
|
56
56
|
- lib/amusing_git/cli.rb
|
57
|
+
- lib/amusing_git/config/config.rb
|
57
58
|
- lib/amusing_git/git/git_hook.rb
|
58
59
|
- lib/amusing_git/git/git_repository.rb
|
59
60
|
- lib/amusing_git/message_seeder.rb
|