git_timer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91a127413b1a21f96e9fd3655fd0111b9af9d406
4
- data.tar.gz: dc5ca37250cc7bbc14e56ce8f0402f757eb90289
3
+ metadata.gz: 57df702d08bbadfdbdf1112c1b2e045d18b947d6
4
+ data.tar.gz: 3322ceb55b9bee5ec3dbfff1070072bc84229e91
5
5
  SHA512:
6
- metadata.gz: 508980173f1e81c052b0d0f4b991d77d7b4a3ea1cae88ce08940d7dac193c58eabf67acf24984c380b2a6b8d34813720cb86da243204dc5d83d39a7a4536e288
7
- data.tar.gz: 10921b70bb74793cb7f183184457e739809eb1289de08ae1ea65dc9824eb5b764960a2ecaad5a7cc77b4d139a6520b332ec1610a750ecd7a108b017e5113550b
6
+ metadata.gz: a0bae838271839cf660b8bf7e018d3a165ea483ff2795877fa1bd92da261e15058710a717e9e72878d71cc965574adc5ed25581b2f17bad8701b56de9d91bb54
7
+ data.tar.gz: 550329039fd5d9476764f0d915474a7bfc1dc545aadb72ab6595394c9c7273f4d936e9c68413c70f0d70ffe2f2a3318d37959558c4dd9c008be6788b71d32003
data/lib/git_timer/cli.rb CHANGED
@@ -5,16 +5,22 @@ module GitTimer
5
5
  desc "work ACTION", "This will start or stop your work tracking"
6
6
  long_desc <<-WORK
7
7
 
8
- `work start` will insert 'Work started | 2018-01-01 00:00:00 -0300' in the git log
8
+ `work start` will insert 'Work | Start | 2018-01-01 00:00:00 -0300' in the user-log file
9
9
 
10
- `work stop` will insert 'Work stopped | 2018-01-01 00:00:00 -0300' in the git log
10
+ `work stop` will insert 'Work | Stop | 2018-01-01 00:00:00 -0300' in the user-log file
11
11
 
12
12
  With the timestamp being the current time with the format %yyyy-MM-dd hh:mm:ss time_zone
13
13
  WORK
14
- option :upcase
14
+
15
15
  def work(action)
16
- "#{action}".upcase! if options[:upcase]
17
- puts action
16
+ case action
17
+ when 'start', 'START', 'Start'
18
+ GitTimer.register_activity({ ticket_id: 'Work', ticket_state: 'Start' })
19
+ when 'stop', 'STOP', 'Stop'
20
+ GitTimer.register_activity({ ticket_id: 'Work', ticket_state: 'Stop' })
21
+ else
22
+ puts 'Invalid action, please use `git_timer start` or `git_timer stop`. Type `git_timer help` for more information.'
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -1,3 +1,3 @@
1
1
  module GitTimer
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/git_timer.rb CHANGED
@@ -5,19 +5,20 @@ module GitTimer extend self
5
5
  require 'fileutils'
6
6
  require 'time'
7
7
 
8
- MAIN_PATH = './user-log'
8
+ MAIN_PATH = '.git/user-log'
9
9
  PRE_PUSH_PATH = '.git/hooks/pre-push'
10
10
  POST_CHECKOUT_PATH = '.git/hooks/post-checkout'
11
11
  LOG_TITLE = "# Git log \n"
12
12
 
13
13
  def main
14
- content = LOG_TITLE
15
- File.open(MAIN_PATH, 'w+') do |f|
16
- f.write content
14
+ unless File.exist?(MAIN_PATH)
15
+ File.open(MAIN_PATH, 'w+') do |f|
16
+ f.write LOG_TITLE
17
+ end
18
+ File.chmod(0777, MAIN_PATH)
17
19
  end
18
- File.chmod(0777, MAIN_PATH)
19
- initialize_git_hook(POST_CHECKOUT_PATH, 'post_checkout')
20
- initialize_git_hook(PRE_PUSH_PATH, 'pre_push')
20
+ initialize_git_hook(POST_CHECKOUT_PATH, 'post_checkout') unless File.exist?(POST_CHECKOUT_PATH)
21
+ initialize_git_hook(PRE_PUSH_PATH, 'pre_push') unless File.exist?(PRE_PUSH_PATH)
21
22
  end
22
23
 
23
24
  def initialize_git_hook(hook_path, hook_method)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_timer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauro Mottini