hooke 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80fd2b7d6a26d4a019dba10f671da342732289d1
4
+ data.tar.gz: 1f98ef0e57868730ddaa2d8aa583ac4aa2bf391a
5
+ SHA512:
6
+ metadata.gz: 3dfea0e47a02050484e8331266fb8a4db410d9ff6db158638943de7e5b468031a2f7a251cf9a13b50f8f8df9ab6861ae8c313c5923e6cd87225bc150867ff5ae
7
+ data.tar.gz: 148783307f4fc7886cfff4e46a741b1345a9ebd54695d4cdfb61552968842bde39b4fb9d93a775c3da5528fc7399f0ebe71bed930b137980e2c249088aaf1223
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.history/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - 'Rakefile'
4
+ - '**/*.rake'
5
+ - 'spec/**/*.rb'
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ - 2.3.4
6
+ - 2.2.7
7
+ before_install: gem install bundler -v 1.16.0.pre.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hooke.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Ramkumar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Hooke
2
+
3
+ Links your git hooks from your repository.
4
+ With this gem, you can commit and share git hooks as part of your repository
5
+
6
+ [![Dependency Status](https://gemnasium.com/badges/github.com/ramkumar-kr/hooke.svg)](https://gemnasium.com/github.com/ramkumar-kr/hooke)
7
+ [![Build Status](https://travis-ci.org/ramkumar-kr/hooke.svg?branch=master)](https://travis-ci.org/ramkumar-kr/hooke)
8
+ ## Requirements
9
+
10
+ To ensure that the gem installs and works properly, you need
11
+
12
+ - `bundler` with version >1.15
13
+ - `git` installed on your system
14
+ - `.git` directory in your repository root path
15
+ - `git_hooks` directory in your repository root path
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'hooke'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install hooke
32
+
33
+ ## Usage
34
+
35
+ The hooks are linked using a symbolic link after installing the gem.
36
+
37
+
38
+ ## Example
39
+
40
+ This project itself is a good example on using the gem.
41
+
42
+ A pre-commit hook is added which runs the linter and tests and can be found in the `git_hooks` directory
43
+
44
+
45
+ ## Development
46
+
47
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+
51
+ ## Contributing
52
+
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ramkumar-kr/hooke.
54
+
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
59
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hooke'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+
3
+ # Run linter before commit
4
+ echo "Running rubocop..."
5
+ bundle exec rubocop
6
+ # Run tests before commit
7
+ echo "Running Tests...."
8
+ bundle exec rake
data/hooke.gemspec ADDED
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hooke/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'hooke'
8
+ spec.version = Hooke::VERSION
9
+ spec.authors = ['Ramkumar']
10
+ spec.email = ['ramkumar.kr94@gmail.com']
11
+
12
+ spec.summary = 'Copy and share your git hooks'
13
+ spec.description = 'Creates a soft link from '
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
16
+ spec.post_install_message = 'You are now hooked'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency 'bundler', '> 1.15'
26
+
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'rubocop', '~> 0.50'
30
+ spec.add_development_dependency 'simplecov', '~> 0.12'
31
+ end
@@ -0,0 +1,50 @@
1
+ require 'bundler'
2
+ module Hooke
3
+ # Link .git_hooks directory to .git/hooks
4
+ class Linker
5
+ attr_reader :app_dir
6
+
7
+ def initialize
8
+ @app_dir = File.expand_path(Bundler.root)
9
+ end
10
+
11
+ def symlink
12
+ fail_with_link_error unless linkable?
13
+ install_status = Dir.chdir(app_dir) do
14
+ backup_directory('./.git/hooks')
15
+ File.symlink("#{app_dir}/git_hooks", "#{app_dir}/.git/hooks")
16
+ end
17
+ install_status
18
+ end
19
+
20
+ private
21
+
22
+ def backup_directory(path)
23
+ return unless Dir.exist?(path)
24
+ if File.symlink?(path)
25
+ File.unlink(path)
26
+ else
27
+ STDOUT.puts "Renaming #{path}"
28
+ File.rename(path, "#{path}_bk_#{Time.now}")
29
+ end
30
+ end
31
+
32
+ def linkable?
33
+ Bundler.git_present? &&
34
+ Dir.exist?("#{app_dir}/.git") &&
35
+ Dir.exist?("#{app_dir}/git_hooks")
36
+ end
37
+
38
+ def fail_with_link_error
39
+ STDERR.puts(
40
+ ['-' * 60,
41
+ 'The following conditions are not satisfied',
42
+ "1. Git installed? - #{Bundler.git_present?}",
43
+ "2. .git present? - #{Dir.exist?("#{app_dir}/.git")}",
44
+ "3. git_hooks present? - #{Dir.exist?("#{app_dir}/git_hooks")}",
45
+ '-' * 60]
46
+ )
47
+ raise 'Cannot be linked'
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module Hooke
2
+ VERSION = '1.0.0'.freeze
3
+ end
data/lib/hooke.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'hooke/version'
2
+ require 'hooke/linker'
3
+ # Takes care of all hook management
4
+ module Hooke
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'hooke/linker'
3
+ require 'bundler'
4
+
5
+ Gem.post_install do |_installer|
6
+ Hooke::Linker.new.symlink
7
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hooke
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ramkumar
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.50'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.50'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.12'
83
+ description: 'Creates a soft link from '
84
+ email:
85
+ - ramkumar.kr94@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - git_hooks/pre-commit
101
+ - hooke.gemspec
102
+ - lib/hooke.rb
103
+ - lib/hooke/linker.rb
104
+ - lib/hooke/version.rb
105
+ - lib/rubygems_plugin.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message: You are now hooked
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.5.1
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Copy and share your git hooks
130
+ test_files: []