gish 0.9.1 → 0.9.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: dfb7fb990c3cdb87b71e18e6c5222d3140267053
4
- data.tar.gz: 50d20693d7686fcdc8b63d564f039f95584eab15
3
+ metadata.gz: e283a3ac502b0f0efd93450c90296764f0e9f01a
4
+ data.tar.gz: 20d202eaa7eabab441e4defa1db8d38df8930362
5
5
  SHA512:
6
- metadata.gz: dcd82b98b59e716825b14783f3cec8f79db4a84f4057b4e65eaed86b32a27c3a607d0d491bd81caa287ddc1d6687421b0d5b636e5e00c09670f81a3adb0eef0c
7
- data.tar.gz: dbbea0db7d48771fce4f63529f08212666613149bc7594b8db3d7e029a8d948816363abc58bd29277306922ae5e0687465d40349171f372ff6ee5324ede6417d
6
+ metadata.gz: 8c3bcbb5d692c97acbb1109c88417a8c92026def1112c636325068cded81c41e8ab141e68964fb2471de272f2cb4aef8b016e6f2534fc686f5fade89f74cfdd1
7
+ data.tar.gz: 0a7527664a089df782d2465b52ff63fe4840855159056ab5cd06e7fc7c06e076fee20818e36f5d5dbe2cc4cee967833f6979bcd4a8eeef7ca1cd4b4b9229117f
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.9.2
4
+
5
+ * Express issue/comment creation times in time passed rather than as a date. Thanks to [despo](https://github.com/despo).
6
+
7
+ ## 0.9.1
8
+
9
+ * Added a [PR] tag for issues in the list screen.
10
+
11
+ ## 0.9.0
12
+
13
+ * Initial release.
data/CONTRIBUTING.md CHANGED
@@ -1,4 +1,4 @@
1
- Contributions are very welcome, whether it's refactoring or taking care of the [issues](http://github.com/gish/issues).
1
+ Contributions are very welcome, whether it's refactoring or taking care of the [issues](http://github.com/barisbalic/gish/issues).
2
2
 
3
3
  Quick guide to contributing:
4
4
 
data/README.md CHANGED
@@ -37,7 +37,7 @@ Here are some examples to get you started.
37
37
 
38
38
  |command|outcome|
39
39
  |-------|-------|
40
- |gish list | List 20 issues|
40
+ |gish list | List 20 issues (default count) |
41
41
  |gish show 1 | Show issue #1|
42
42
  |gish show 1 -i| Show issue #1 and include comments|
43
43
  |gish comment 1 -m ":+1"| Comment on issue #1|
@@ -45,10 +45,10 @@ Here are some examples to get you started.
45
45
  |gish close 1| Close issue #1|
46
46
  |gish label 1 such-feature| Add the label such-feature to issue #1|
47
47
 
48
- When listing issues, the number of comments on an issue will be displayed at the end of a line.
48
+ When listing issues, the number of comments on an issue will be displayed at the end of a line, along with a tag indicating if the issue is a pull request.
49
49
 
50
50
  ```
51
- #9 barisbalic Emoji! [2]
51
+ #9 barisbalic Emoji! [PR] [2]
52
52
  #8 barisbalic Fix editor input for open command [0]
53
53
  #7 barisbalic Support API paging [0]
54
54
  #6 barisbalic Current repository check is lame [1]
@@ -62,10 +62,10 @@ When listing issues, the number of comments on an issue will be displayed at the
62
62
 
63
63
  ## Contributing
64
64
 
65
- Contributions are very welcome, whether it's refactoring or taking care of the [issues](http://github.com/gish/issues).
65
+ Contributions are very welcome, whether it's refactoring or taking care of the [issues](http://github.com/barisbalic/gish/issues).
66
66
 
67
67
  1. Fork the repo.
68
- 2. create your branch `git checkout -b branch-name` **bonus for feature branches**
68
+ 2. Create your branch `git checkout -b branch-name` **bonus for feature branches**
69
69
  3. Make your changes
70
70
  4. Test to make sure you have not broken any existing functionality
71
71
  4. Commit your changes
@@ -0,0 +1,61 @@
1
+ module Gish
2
+ module DateHelpers
3
+
4
+ A_DAY = 1440
5
+ A_MONTH = A_DAY*30
6
+ A_YEAR = A_MONTH*12
7
+
8
+ def time_in_words(now=Time.now, time)
9
+ minutes = ((now - time)/60).round
10
+
11
+ return format_year_string(minutes) if minutes >= A_YEAR
12
+
13
+ case minutes
14
+ when 0
15
+ "less than one minute ago"
16
+ when 1...50
17
+ "#{minutes} minutes ago"
18
+ when 51...90
19
+ "about 1 hour ago"
20
+ when 91...A_DAY
21
+ "about #{hours_ago(minutes)} hours ago"
22
+ when A_DAY...2520
23
+ "one day ago"
24
+ when 2521...A_MONTH
25
+ "#{days_ago(minutes)} days ago"
26
+ when A_MONTH...A_YEAR
27
+ "#{months_ago(minutes)} months ago"
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def format_year_string(minutes)
34
+ remaining_minutes = minutes % A_YEAR
35
+
36
+ if remaining_minutes < A_YEAR*0.25
37
+ "about #{years_ago(minutes)} years ago"
38
+ elsif remaining_minutes < A_YEAR*0.75
39
+ "more than #{years_ago(minutes)} years ago"
40
+ else
41
+ "almost #{years_ago(minutes)+1} years ago"
42
+ end
43
+ end
44
+
45
+ def hours_ago(minutes)
46
+ minutes/60
47
+ end
48
+
49
+ def days_ago(minutes)
50
+ hours_ago(minutes)/24
51
+ end
52
+
53
+ def months_ago(minutes)
54
+ days_ago(minutes)/30
55
+ end
56
+
57
+ def years_ago(minutes)
58
+ months_ago(minutes)/12
59
+ end
60
+ end
61
+ end
@@ -1,18 +1,19 @@
1
1
  module Gish
2
2
  class Comment
3
3
  include TerminalHelpers
4
+ include DateHelpers
4
5
 
5
6
  def initialize(github_comment)
6
7
  @body = github_comment.body.gsub("\r\n", "\n")
7
8
  @user = github_comment.user.login
8
9
  @id = github_comment.id
9
- @created_at = github_comment.created_at
10
+ @created_at = time_in_words(github_comment.created_at)
10
11
  end
11
12
 
12
13
  def to_s
13
- output = "\n#{@id} #{bold(@user)} commented on #{@created_at}"
14
+ output = "\n#{@id} #{bold(@user)} commented #{@created_at}"
14
15
  output << "\n\"#{@body}\"\n"
15
16
  output
16
17
  end
17
18
  end
18
- end
19
+ end
@@ -1,7 +1,8 @@
1
1
  module Gish
2
2
  class Issue
3
3
  include TerminalHelpers
4
-
4
+ include DateHelpers
5
+
5
6
  def initialize(github_issue)
6
7
  @url = github_issue.html_url
7
8
  @number = github_issue.number.to_s
@@ -12,13 +13,13 @@ module Gish
12
13
  @user = github_issue.user.login
13
14
  @comment_count = github_issue.comments
14
15
  @assignee = github_issue.assignee.login rescue nil
15
- @created_at = github_issue.created_at
16
+ @created_at = time_in_words(github_issue.created_at)
16
17
  @pull_request = !github_issue.pull_request.rels.keys.empty?
17
18
  end
18
19
 
19
20
  def headline
20
21
  user = @user.ljust(20, ' ')
21
- title = short_title.ljust(70, ' ')
22
+ title = short_title.ljust(70, ' ')
22
23
  number = @number.ljust(5, ' ')
23
24
  type = @pull_request ? '[PR]' : ' '
24
25
  "##{number} #{bold(user)} #{title} #{bold(type)} [#{@comment_count}]"
@@ -27,7 +28,7 @@ module Gish
27
28
  def to_s
28
29
  output = underline("##{@number} #{@title}")
29
30
  output << " [#{@state}]"
30
- output << "\nOpened by #{bold(@user)} on #{@created_at}"
31
+ output << "\nOpened by #{bold(@user)} #{@created_at}"
31
32
  output << "\nAssigned to #{bold(@assignee)}" unless @assignee.nil?
32
33
  output << "\n\n#{@body}\n\n"
33
34
  output << "#{label_names.join(' ')}" unless @labels.empty?
@@ -45,4 +46,4 @@ module Gish
45
46
  @labels.map{ |l| format_label(l.name) }
46
47
  end
47
48
  end
48
- end
49
+ end
data/lib/gish/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gish
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
data/lib/gish.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "gish/version"
2
2
  require "gish/helpers/input_helpers"
3
3
  require "gish/helpers/terminal_helpers"
4
+ require "gish/helpers/date_helpers"
4
5
  require "gish/configuration"
5
6
  require "gish/commands/issue"
6
7
  require "gish/commands/comment"
@@ -0,0 +1,53 @@
1
+ require_relative '../../test_helper'
2
+
3
+ class DateTestClass
4
+ include Gish::DateHelpers
5
+ end
6
+
7
+ class TestDateHelpers < MiniTest::Test
8
+ def setup
9
+ @date_helper = DateTestClass.new
10
+ @now = Time.new(2013,12,27)
11
+ end
12
+
13
+ def time_in_words time
14
+ @date_helper.time_in_words(@now, time)
15
+ end
16
+
17
+ def test_seconds_ago
18
+ assert_equal(time_in_words(Time.new(2013,12,27)), "less than one minute ago")
19
+ end
20
+
21
+ def test_minutes_ago
22
+ assert_equal(time_in_words(Time.new(2013,12,26,23,58)), "2 minutes ago")
23
+ end
24
+
25
+ def test_about_an_hour_ago
26
+ assert_equal(time_in_words(Time.new(2013,12,26,23,8)), "about 1 hour ago")
27
+ end
28
+
29
+ def test_x_hours_ago
30
+ assert_equal(time_in_words(Time.new(2013,12,26,19)), "about 5 hours ago")
31
+ end
32
+
33
+ def test_x_days_ago
34
+ assert_equal(time_in_words(Time.new(2013,12,23)), "4 days ago")
35
+ end
36
+
37
+ def test_x_months_ago
38
+ assert_equal(time_in_words(Time.new(2013,9,23)), "3 months ago")
39
+ end
40
+
41
+ def test_about_x_years_ago
42
+ assert_equal(time_in_words(Time.new(2011,12,27)), "about 2 years ago")
43
+ end
44
+
45
+ def test_about_x_years_ago
46
+ assert_equal(time_in_words(Time.new(2011,9,27)), "more than 2 years ago")
47
+ end
48
+
49
+ def test_almost_x_years_ago
50
+ assert_equal(time_in_words(Time.new(2011,2,27)), "almost 3 years ago")
51
+ end
52
+
53
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+
3
+ require './lib/gish/helpers/date_helpers'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Baris Balic
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
+ - CHANGELOG.md
78
79
  - CONTRIBUTING.md
79
80
  - Gemfile
80
81
  - LICENSE.txt
@@ -90,6 +91,7 @@ files:
90
91
  - lib/gish/commands/issue.rb
91
92
  - lib/gish/commands/label.rb
92
93
  - lib/gish/configuration.rb
94
+ - lib/gish/helpers/date_helpers.rb
93
95
  - lib/gish/helpers/input_helpers.rb
94
96
  - lib/gish/helpers/terminal_helpers.rb
95
97
  - lib/gish/presentation/comment.rb
@@ -97,6 +99,8 @@ files:
97
99
  - lib/gish/presentation/label.rb
98
100
  - lib/gish/runner.rb
99
101
  - lib/gish/version.rb
102
+ - test/gish/helpers/date_helpers_test.rb
103
+ - test/test_helper.rb
100
104
  homepage: http://github.com/barisbalic/gish
101
105
  licenses:
102
106
  - MIT
@@ -121,4 +125,6 @@ rubygems_version: 2.0.3
121
125
  signing_key:
122
126
  specification_version: 4
123
127
  summary: A fairly functional command-line interface for the most excellent Gitub Issues.
124
- test_files: []
128
+ test_files:
129
+ - test/gish/helpers/date_helpers_test.rb
130
+ - test/test_helper.rb