git_timelog 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: 1ad5a0fd175534fbb4452af0d37fdf542609548d
4
- data.tar.gz: 5a5482d4613e43d9e55364db4ea459a3d8b2d799
3
+ metadata.gz: c9d41a6ba5cf6b1b15ffd1e860dea4fd9336ec1d
4
+ data.tar.gz: bad0f86918025502f3f8371e367a5719da901ec3
5
5
  SHA512:
6
- metadata.gz: 6781fb989628dab50fc7ff986d5d4dba60e895749e395f613c8ca84af5e1695b4d28269cca5c507c55bec58393a97a04f52f1b9878d0af31ef1339ade7e4999b
7
- data.tar.gz: e0ad94957492610755710c9b185cd52155082ea24e4bb336e7d11fe0f1b30b99aae540bd8d8885656080501cd32509192cd62957754de1ec0dff38f0e7617e4e
6
+ metadata.gz: b50ec1d7adf31f6f4ce15310c821d576c0a27263d05bdcfdfaa335c75332092cbb027694490906d35e4db4435b027264e01d31f59ac8cc623465c5a43bc408da
7
+ data.tar.gz: 9c8c7077f4be7b0b1d9f67053c06206e6d18d2f0d22d591ee92698f2a2dc7ccfb0fc11895f74d72080ef1928c658ecd9083350ed869d46dd4a2150c76578d294
data/bin/git_timelog ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'git_timelog'
3
+ include GitTimelog
4
+ user_input
@@ -0,0 +1,23 @@
1
+ require "httparty"
2
+
3
+ class EmitiiApiConnector
4
+ attr_accessor :access_token, :params, :project_name, :emitii_subdomain
5
+
6
+ def initialize(access_token='amhVvo8j8MCVzWS6kxuvQg', project_name='git_timelog', emitii_subdomain='jhackathon')
7
+ @access_token = access_token
8
+ @project_name = project_name
9
+ @emitii_subdomain = emitii_subdomain
10
+ end
11
+
12
+ def update_time_tracks(params)
13
+ params = {
14
+ timetrack: params
15
+ }
16
+ response = HTTParty.post("http://#{@emitii_subdomain}.emitii.com/api/timetracks?access_token=#{@access_token}&project=#{@project_name}&format=json",
17
+ {
18
+ :body => params.to_json,
19
+ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
20
+ })
21
+ return response
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module GitTimelog
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/git_timelog.rb CHANGED
@@ -1,27 +1,93 @@
1
1
  require "git_timelog/version"
2
+ require "git_timelog/emitii_api_connector"
2
3
  require "git_formatter"
3
4
  require "json"
5
+ require 'optparse'
6
+ require 'ostruct'
4
7
 
5
8
  module GitTimelog
6
9
  # TODO: make the time changeable
10
+
11
+ def user_input
12
+ options = OpenStruct.new
13
+ options.format = "unordered"
14
+ options.since = "6am"
15
+ options.emitii = false
16
+ option_parse = OptionParser.new do |option|
17
+ option.banner = "Hint: git_timelog -s 6am -f json"
18
+ option.on("-f","--format=FORMAT","which format do you want to get returned") do |format|
19
+ options.format = format
20
+ end
21
+ option.on("-s", "--since=SINCE", "When do you want your time logged.") do |since|
22
+ options.since = since
23
+ end
24
+ option.on("-e", "--emitii", "update time log in emitii?") do |since|
25
+ options.emitii = true
26
+ end
27
+ option.on("-h","--help","help") do
28
+ puts option_parse
29
+ end
30
+ end
31
+ begin
32
+ option_parse.parse! ARGV
33
+ if options.emitii == true
34
+ to_emitii(options.since)
35
+ else
36
+ if options.format == "json"
37
+ json_format(options.since)
38
+ elsif options.format == "ordered" || options.format == "unordered"
39
+ to_clipboard(options.format, options.since)
40
+ puts 'Copied to clipboard. Please paste as required.'
41
+ else
42
+ puts 'invalid format'
43
+ end
44
+ end
45
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument , OptionParser::ParseError => e
46
+ puts e
47
+ puts "Type -h or --help for help"
48
+ end
49
+ end
50
+
7
51
  def git_timelog(from_time = '6am')
8
- `git log --pretty=format:"git__title:%sgit__description:%bgit__date:%cd" --author="#{current_author}" --since={#{from_time}} --reverse`
52
+ `git log --pretty=format:"git__title:%sgit__description:%bgit__date:%cd" --author="#{current_author}" --since={#{from_time}} --reverse --all`
9
53
  end
10
54
 
11
55
  def current_author
12
- `git config user.name`
56
+ `git config user.name`.chomp
13
57
  end
14
58
 
15
- def json_format
16
- data = git_timelog
59
+ def json_format(from_time = '6am')
60
+ data = git_timelog(from_time)
17
61
  gf = GitFormatter.new(data)
18
- gf.json_formatted.to_json
62
+ puts gf.json_formatted.to_json
19
63
  end
20
64
 
21
65
  # list_style = 'ordered' || 'unordered'
22
- def to_clipboard(list_style = 'ordered')
23
- data = git_timelog
66
+ def to_clipboard(list_style = 'ordered', from_time = '6am')
67
+ data = git_timelog(from_time)
68
+ gf = GitFormatter.new(data)
69
+ if `uname` == "Darwin\n"
70
+ `echo "#{gf.title_list(list_style)}" | pbcopy`
71
+ elsif `uname` == "Linux\n"
72
+ `echo "#{gf.title_list(list_style)}" | xclip -selection clipboard`
73
+ end
74
+ end
75
+
76
+ def to_emitii(from_time = '6am')
77
+ obj = EmitiiApiConnector.new
78
+ puts "Your Access Token Please:"
79
+ obj.access_token = gets.chomp
80
+ puts "Your Subdomain Please:"
81
+ obj.emitii_subdomain = gets.chomp
82
+ puts "Your Project Name Please:"
83
+ obj.project_name = gets.chomp
84
+ data = git_timelog(from_time)
24
85
  gf = GitFormatter.new(data)
25
- `echo "#{gf.title_list(list_style)}" | pbcopy`
86
+ response = obj.update_time_tracks(gf.json_formatted)
87
+ if response["status"] == 200
88
+ puts "Emitii Successfully Updated."
89
+ else
90
+ puts "Something went wrong. Please try again."
91
+ end
26
92
  end
27
- end
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_timelog
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
  - Sushil Shrestha
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-20 00:00:00.000000000 Z
13
+ date: 2016-02-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -54,6 +54,20 @@ dependencies:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '3.4'
57
+ - !ruby/object:Gem::Dependency
58
+ name: httparty
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.13'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '0.13'
57
71
  description: The tool can return json of the tasks done along with start and end time.
58
72
  As well as simply copy the list of commits done as plain-text list which can be
59
73
  ordered or unordered.
@@ -61,21 +75,18 @@ email:
61
75
  - sushil@jyaasa.com
62
76
  - ganesh@jyaasa.com
63
77
  - surya@jyaasa.com
64
- executables: []
78
+ executables:
79
+ - git_timelog
65
80
  extensions: []
66
81
  extra_rdoc_files: []
67
82
  files:
68
- - ".gitignore"
69
- - Gemfile
70
83
  - LICENSE.txt
71
84
  - README.md
72
- - Rakefile
73
- - git_timelog.gemspec
85
+ - bin/git_timelog
74
86
  - lib/git_formatter.rb
75
87
  - lib/git_timelog.rb
88
+ - lib/git_timelog/emitii_api_connector.rb
76
89
  - lib/git_timelog/version.rb
77
- - spec/git_log_extraction_spec.rb
78
- - spec/spec_helper.rb
79
90
  homepage: http://jyaasa.com/git_timelog
80
91
  licenses:
81
92
  - MIT
@@ -100,6 +111,4 @@ rubygems_version: 2.4.5
100
111
  signing_key:
101
112
  specification_version: 4
102
113
  summary: A tool to extract daily update from GIT commits.
103
- test_files:
104
- - spec/git_log_extraction_spec.rb
105
- - spec/spec_helper.rb
114
+ test_files: []
data/.gitignore DELETED
@@ -1,14 +0,0 @@
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/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "rspec"
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
data/git_timelog.gemspec DELETED
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'git_timelog/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "git_timelog"
8
- spec.version = GitTimelog::VERSION
9
- spec.authors = ["Sushil Shrestha", "Ganesh Kunwar", "Surya Siwakoti"]
10
- spec.email = ["sushil@jyaasa.com", "ganesh@jyaasa.com", "surya@jyaasa.com"]
11
- spec.summary = "A tool to extract daily update from GIT commits."
12
- spec.description = "The tool can return json of the tasks done along with start and end time. As well as simply copy the list of commits done as plain-text list which can be ordered or unordered."
13
- spec.homepage = "http://jyaasa.com/git_timelog"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.4"
24
- end
@@ -1,37 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe GitTimelog do
4
-
5
- # TODO: Refactor
6
- describe '#git_timelog' do
7
- it "should extract git commits" do
8
- expect(git_timelog).to eql(`git log --pretty=format:"git__title:%sgit__description:%bgit__date:%cd" --author="#{current_author}" --since={6am} --reverse`)
9
- end
10
- end
11
-
12
- # TODO: Refactor
13
- describe '#current_author' do
14
- it "should return authors name" do
15
- expect(current_author).to eql(`git config user.name`)
16
- end
17
- end
18
-
19
- describe '#json_format' do
20
- it "should return json formatted update" do
21
- formatted_json = json_format
22
- puts formatted_json
23
- expect(formatted_json).to eql(formatted_json) # LOL
24
- end
25
- end
26
-
27
- describe '#to_clipboard' do
28
- it "should copy ordered list to clipboard" do
29
- to_clipboard
30
- puts "Ordered List copied to clipboard. Paste to test."
31
- end
32
- it "should copy unordered list to clipboard" do
33
- to_clipboard('unordered')
34
- puts "Unordered List copied to clipboard"
35
- end
36
- end
37
- end
data/spec/spec_helper.rb DELETED
@@ -1,6 +0,0 @@
1
- require "git_timelog"
2
- require "json"
3
-
4
- RSpec.configure do |c|
5
- c.include(GitTimelog)
6
- end