HostileGit 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjA3ZDk4MTA2OGNhMDBiYTYyM2M5ZjkyNzQ2ZjUyNzM1NjYxMDVmZg==
5
+ data.tar.gz: !binary |-
6
+ MzdlNDEyYzMyYzRlMGQzNjQ1ZTkxZjA4M2Y3ODM4YjA1M2Y1YWZkMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MjU2MDI0ODY4NTk3MjgwN2ZhMzE1N2RjZWFmODgxZTFiY2MzNWQ0ZDI2MDRl
10
+ Y2Y3OGJiMjE4MmFlZDEzNjA5MWRhZWQyNTM0NGE3ODI2MGEwMjVhMjQ0N2Ix
11
+ MmM3YmFmYzVkNTRkOGUyYzA0ODg4NzAzMDUxYTZiNDRkMWFiNjM=
12
+ data.tar.gz: !binary |-
13
+ MGVhNDVhMDRkNzY2MGY1MzFjYWVmMDZiNGE3OTA1OTQ2MmJmM2VlYjAwYjI1
14
+ ZjQxOWU5ZDEzMjdjZDBlNjFhZDNkYjk3ZjVkYjc2YTU1Nzg0ODc3ZmZiZmQx
15
+ ODg0ZmQ5MTQ2MjQ1NzZhZmZjMDQ0NDljYTVkYmRiMjMwOWIyM2Q=
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.2.0
5
+ - 2.1.5
6
+ script: bundle exec rspec
7
+ deploy:
8
+ provider: rubygems
9
+ api_key:
10
+ secure: SS4qIzUG/sm3DaheunoIB2DhRiYeHo4R6MInffSAKzJz6yathdub10PQdKLfFQYGwQ/iejlUsNBoq4GW799i+ESsDSG6WQrPs243RSFH58uPbz4CWGj6+60ChPVdA83b2yCY0TyS/G/UZVyk+RbIH+1ihBPJYzaGjc5XJGFP+pc=
11
+ gem: HostileGit
12
+ on:
13
+ repo: whatisinternet/HostileGit
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in HostileGit.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
76
+ end
77
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'HostileGit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+
8
+ spec.name = "HostileGit"
9
+ spec.version = HostileGit::VERSION
10
+ spec.authors = "Whatisinternet"
11
+ spec.email = "joshteeter@gmail.com"
12
+ spec.summary = "Resets you repo with hard head after a timeout"
13
+ spec.description = "This will reset your git repo after a set time"
14
+ spec.homepage = "https://github.com/whatisinternet/HostileGit"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "git", "~> 1.2"
23
+ spec.add_dependency "listen", "~> 2.8"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "rspec-expectations"
29
+ spec.add_development_dependency "rspec-nc"
30
+ spec.add_development_dependency "guard"
31
+ spec.add_development_dependency "guard-rspec"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "pry-remote"
34
+ spec.add_development_dependency "pry-nav"
35
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
36
+
37
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Whatisinternet
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ [![Build
2
+ Status](https://travis-ci.org/whatisinternet/HostileGit.png?branch=master)](https://travis-ci.org/whatisinternet/HostileGit) [![Gem
3
+ Version](https://badge.fury.io/rb/HostileGit.png)](http://badge.fury.io/rb/HostileGit) [![Code Climate](https://codeclimate.com/github/whatisinternet/HostileGit/badges/gpa.svg)](https://codeclimate.com/github/whatisinternet/HostileGit) [![Test Coverage](https://codeclimate.com/github/whatisinternet/HostileGit/badges/coverage.svg)](https://codeclimate.com/github/whatisinternet/HostileGit)
4
+
5
+ # HostileGit
6
+
7
+ The whole point of this gem is to be hostile to you for not committing
8
+ frequently.
9
+
10
+
11
+ By default every 10 minutes that a commit hasn't occurred, this will run:
12
+
13
+ ```shell
14
+ git reset --hard HEAD
15
+ ```
16
+
17
+ ## Installation
18
+
19
+ Gem install the gem:
20
+
21
+ ```shell
22
+ $ gem instal HostileGit
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install HostileGit
32
+
33
+ ## Usage
34
+
35
+ Default
36
+
37
+ ```shell
38
+ $ HostileGit
39
+ ```
40
+
41
+ Custom timeout of 7 minutes
42
+ ```shell
43
+ $ HostileGit 7
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/[my-github-username]/HostileGit/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'rspec/core/rake_task'
2
+ require "bundler/gem_tasks"
data/bin/HostileGit ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'HostileGit'
4
+
5
+ def main
6
+ puts "\n HostileGit started: \n"
7
+ puts "Starting to watch your directories for changes \n ctrl+c to exit"
8
+ HostileGit::Hostility.new(ARGV[0].to_i).start_being_hostile
9
+ end
10
+
11
+ main
data/lib/HostileGit.rb ADDED
@@ -0,0 +1,48 @@
1
+ require "HostileGit/version"
2
+ require "git"
3
+ require "listen"
4
+ require "date"
5
+
6
+ module HostileGit
7
+
8
+ class Hostility
9
+ attr_accessor :timeout, :initial_time, :git
10
+
11
+ def initialize(timer = 10)
12
+ self.timeout = timer
13
+ self.initial_time = Time.now.to_i
14
+ self.git = Git.init
15
+ end
16
+
17
+ def commited?
18
+ self.git.log.since("#{self.timeout} minutes ago").count > 0
19
+ end
20
+
21
+ def reset!
22
+ self.git.reset_hard("HEAD")
23
+ end
24
+
25
+ def check_and_reset
26
+ if !commited?
27
+ reset!
28
+ end
29
+ end
30
+
31
+ def initial_timeout
32
+ (self.initial_time - Time.now.to_i) < (timeout * -3600)
33
+ end
34
+
35
+ def start_being_hostile
36
+ listener = Listen.to(Dir.pwd) do |modified, added, removed|
37
+ if initial_timeout
38
+ check_and_reset
39
+ end
40
+ end
41
+ listener.start # not blocking
42
+ sleep
43
+ end
44
+
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,3 @@
1
+ module HostileGit
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe HostileGit do
4
+
5
+ before (:each) do
6
+ @hostile = HostileGit::Hostility.new()
7
+ end
8
+
9
+ describe "initalize" do
10
+ it 'should initalize with a given timeout' do
11
+ _hostile = HostileGit::Hostility.new(7)
12
+ expect(_hostile.timeout).to equal(7)
13
+ end
14
+ it 'should initalize without a given timeout to 10 minutes' do
15
+ _hostile = HostileGit::Hostility.new()
16
+ expect(_hostile.timeout).to equal(10)
17
+ end
18
+ end
19
+
20
+ describe "timeout" do
21
+ it 'should return the current timeout' do
22
+ expect(@hostile.timeout).to equal(10)
23
+ end
24
+ end
25
+
26
+ describe "initial_time" do
27
+ it "should be the time the method was initalized" do
28
+ expect(@hostile.initial_time).to be <= Time.now.to_i
29
+ end
30
+ end
31
+
32
+ describe "comitted?" do
33
+ it "should tell us that the repo has been commited" do
34
+ expect(@hostile.commited?).to_not be_nil
35
+ end
36
+ end
37
+
38
+ describe "reset!" do
39
+ it "should reset the repo with a git reset --hard HEAD" do
40
+ expect(@hostile.reset!).to include("HEAD")
41
+ end
42
+ end
43
+
44
+ describe "initial_timeout" do
45
+ it "should not be timed out" do
46
+ expect(@hostile.initial_timeout).to be_falsy
47
+ end
48
+ it "should be timed out" do
49
+ @hostile.initial_time -= (30 * 3600)
50
+ expect(@hostile.initial_timeout).to be_truthy
51
+ end
52
+ end
53
+
54
+ describe "check_and_reset" do
55
+ it "should respond to this method" do
56
+ expect(@hostile).to respond_to(:check_and_reset)
57
+ end
58
+ end
59
+
60
+ describe "start_being_hostile" do
61
+ it "should respond to this method" do
62
+ expect(@hostile).to respond_to(:start_being_hostile)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,5 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ require 'HostileGit'
5
+ require 'git'
metadata ADDED
@@ -0,0 +1,241 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: HostileGit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Whatisinternet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: listen
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-expectations
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-nc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry-remote
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-nav
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: codeclimate-test-reporter
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ~>
186
+ - !ruby/object:Gem::Version
187
+ version: '0.4'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ~>
193
+ - !ruby/object:Gem::Version
194
+ version: '0.4'
195
+ description: This will reset your git repo after a set time
196
+ email: joshteeter@gmail.com
197
+ executables:
198
+ - HostileGit
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - .gitignore
203
+ - .travis.yml
204
+ - Gemfile
205
+ - Guardfile
206
+ - HostileGit.gemspec
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - bin/HostileGit
211
+ - lib/HostileGit.rb
212
+ - lib/HostileGit/version.rb
213
+ - spec/hostileGit_spec.rb
214
+ - spec/spec_helper.rb
215
+ homepage: https://github.com/whatisinternet/HostileGit
216
+ licenses:
217
+ - MIT
218
+ metadata: {}
219
+ post_install_message:
220
+ rdoc_options: []
221
+ require_paths:
222
+ - lib
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ! '>='
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ! '>='
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ requirements: []
234
+ rubyforge_project:
235
+ rubygems_version: 2.4.5
236
+ signing_key:
237
+ specification_version: 4
238
+ summary: Resets you repo with hard head after a timeout
239
+ test_files:
240
+ - spec/hostileGit_spec.rb
241
+ - spec/spec_helper.rb