git-trend 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20c964a7d07ba6be9c6ec62fa23a2e8ba07790fa
4
- data.tar.gz: 572f2a982a671cbcc9934d956427796f837d3013
3
+ metadata.gz: 9f80f0833e1dc5f6f84b38ff16c6c693351b7c1b
4
+ data.tar.gz: 483f4cbd54c05c6d54bb1ad0c76572c4ca3040b9
5
5
  SHA512:
6
- metadata.gz: f2eefa770d4a8bd8f5cd6ae6067319f16e18e8f11ac12c0d1d9a8cd566e1c87dc2390f09a998dc120fa0eb76e086d300f422322daf4a0ce8be25e4bfd8c20068
7
- data.tar.gz: d0ab6972107b84545151790841ae3aec609c1f634421fb20fbef6ac28a1a6677a96010da5a0ffeccc254779f93cffcd1a8f97ce6a3b52bece95fde8c84822a4a
6
+ metadata.gz: 73f27a239bbd0b7f678d9e7afcb154409d89fe54fae33a5ba486852258e43b07f3649391bed8be4bf59911fc17ad1de9f50ddc2ba9d54744425d7a24a91ec774
7
+ data.tar.gz: 17bbf467e9e2165a7686135ab47445506c07bd546018ea3a0d2dd93611558a80392f41c3126643c2be7f3166d3ad760b9dbfc26c412411e87c22e019c03f1165
@@ -1,3 +1,8 @@
1
+ ## v0.0.6
2
+
3
+ * Implement terminal width is not enough, does not display description. (7754a71)
4
+
5
+
1
6
  ## v0.0.5
2
7
 
3
8
  * Fix lack of addressable gem when installing (54ca275)
data/README.md CHANGED
@@ -65,6 +65,43 @@ No. Name Lang Star Fork
65
65
  25 twbs/bootstrap CSS 46 27
66
66
  ```
67
67
 
68
+ ### daily trending with description
69
+
70
+ git trend -d
71
+
72
+ e.g.:
73
+
74
+ ```
75
+ $ g trend -d
76
+ No. Name Lang Star Fork Description
77
+ --- -------------------------------------------------- ----------- ------ ----- ----------------------------------------------------------------------------
78
+ 1 hummingbird-me/hummingbird JavaScript 535 21 Probably the coolest anime discovery platform around.
79
+ 2 google/flatbuffers Shell 272 14 Memory Efficient Serialization Library
80
+ 3 jakubroztocil/httpie Python 248 14 HTTPie is a command line HTTP client, a user-friendly cURL replacement.
81
+ 4 mephux/komanda JavaScript 199 8 IRC for people who write code
82
+ 5 burocratik/outdated-browser JavaScript 188 24 A simple tool to identify and upgrade old browsers.
83
+ 6 numbbbbb/the-swift-programming-language-in-chinese Python 140 30 中文版 Apple 官方 Swift 教程《The Swift Programming Language》
84
+ 7 pocketjoso/penthouse JavaScript 146 4 Critical Path CSS Generator
85
+ 8 estiens/world_cup_json Ruby 126 9 Rails backend for a scraper that outputs World Cup data as JSON
86
+ 9 medialab/artoo JavaScript 126 0 The client-side scraping companion.
87
+ 10 justjavac/Google-IPs 97 36 Google 全球 IP 地址库
88
+ 11 thusfresh/switchboard Erlang 114 0 Switchboard Server
89
+ 12 greatfire/wiki 97 34
90
+ 13 montagejs/collections JavaScript 96 2 This package contains JavaScript implementations of common data structure...
91
+ 14 thumbtack/angular-smarty JavaScript 94 0 Autocomplete UI written with Angular JS.
92
+ 15 Vestorly/torii JavaScript 91 0 A set of clean abstractions for authentication in Ember.js
93
+ 16 angular/angular.js JavaScript 68 40 HTML enhanced for web apps
94
+ 17 urish/angular-moment JavaScript 79 1 Angular.JS directives for Moment.JS (timeago alternative)
95
+ 18 mattdonnelly/Swifter Swift 76 5 A Twitter framework for iOS & OS X written in Swift
96
+ 19 nimbly/angular-formly JavaScript 72 6 AngularJS directive which takes JSON representing a form and renders to H...
97
+ 20 julianshapiro/velocity JavaScript 71 4 Accelerated JavaScript animation.
98
+ 21 GoogleCloudPlatform/kubernetes Go 64 7 Container Cluster Manager
99
+ 22 twbs/bootstrap CSS 45 34 The most popular front-end framework for developing responsive, mobile fi...
100
+ 23 google/cadvisor Go 58 4 Analyzes resource usage and performance characteristics of running contai...
101
+ 24 CartoDB/odyssey.js JavaScript 57 6 Making it easy to merge map and narrative
102
+ 25 ra1028/RACollectionViewReorderableTripletLayout Objective-C 55 3 The custom collectionView layout that can perform reordering of cells by ...
103
+ ```
104
+
68
105
  ### daily trending by language
69
106
 
70
107
  git trend -l
@@ -14,13 +14,13 @@ module GitTrend
14
14
  say "git-trend version: #{VERSION}", :green
15
15
  end
16
16
 
17
- desc :list, '[List] Trending repository on github'
18
- option :list, aliases:'-l', required: false
19
- option :since, aliases:'-s', required: false
17
+ desc :list, 'List Trending repository on github (default command)'
18
+ option :language, aliases:'-l', required: false
19
+ option :since, aliases:'-s', required: false
20
20
  option :description, aliases:'-d', required: false
21
21
  def list
22
22
  scraper = Scraper.new
23
- projects = scraper.get(options[:list], options[:since])
23
+ projects = scraper.get(options[:language], options[:since])
24
24
  render(projects, !!options[:description])
25
25
  rescue => e
26
26
  say "An unexpected #{e.class} has occurred.", :red
@@ -8,6 +8,7 @@ module GitTrend
8
8
  # header columns:
9
9
  # 'No.', 'Name', 'Lang', 'Star', 'Fork', ['Description']
10
10
  DEFAULT_RULED_LINE_SIZE = [3, 40, 10, 6, 5]
11
+ DESCRIPTION_MIN_SIZE = 20
11
12
 
12
13
  def render(projects, describable=false)
13
14
  @describable = describable
@@ -42,10 +43,15 @@ module GitTrend
42
43
  @ruled_line_size[2] = max_lang_size
43
44
  end
44
45
 
46
+ # setting description size
45
47
  if @describable
46
48
  terminal_width, _terminal_height = detect_terminal_size
47
49
  description_width = terminal_width - @ruled_line_size.inject(&:+) - @ruled_line_size.size
48
- @ruled_line_size << description_width
50
+ if description_width >= DESCRIPTION_MIN_SIZE
51
+ @ruled_line_size << description_width
52
+ else
53
+ @describable = false
54
+ end
49
55
  end
50
56
  end
51
57
 
@@ -59,7 +65,7 @@ module GitTrend
59
65
  header = ['No.', 'Name', 'Lang', 'Star', 'Fork']
60
66
  header << 'Description' if @describable
61
67
  puts fmt % header
62
- puts fmt % @ruled_line_size.map{ |f| '-'*f }
68
+ puts fmt % @ruled_line_size.map{ |field| '-'*field }
63
69
  end
64
70
 
65
71
  def render_to_body(projects)
@@ -87,7 +93,7 @@ module GitTrend
87
93
  else
88
94
  nil
89
95
  end
90
- rescue Exception => e
96
+ rescue
91
97
  nil
92
98
  end
93
99
  end
@@ -1,3 +1,3 @@
1
1
  module GitTrend
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  include GitTrend
@@ -14,36 +15,7 @@ RSpec.describe GitTrend::CLI do
14
15
  end
15
16
 
16
17
  it 'display daily ranking' do
17
- res = <<-'EOS'.unindent
18
- |No. Name Lang Star Fork
19
- |--- -------------------------------------------------- ------------ ------ -----
20
- | 1 prat0318/json_resume Ruby 264 15
21
- | 2 andlabs/ui Go 185 8
22
- | 3 jessepollak/card CSS 174 9
23
- | 4 fullstackio/FlappySwift Swift 148 44
24
- | 5 grant/swift-cheat-sheet 153 13
25
- | 6 Flolagale/mailin Python 155 3
26
- | 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31
27
- | 8 hippyvm/hippyvm PHP 113 1
28
- | 9 neovim/neovim C 83 8
29
- | 10 hiphopapp/hiphop CoffeeScript 77 8
30
- | 11 interagent/http-api-design 78 4
31
- | 12 austinzheng/swift-2048 Swift 69 16
32
- | 13 mdznr/What-s-New Objective-C 72 2
33
- | 14 daneden/animate.css CSS 65 6
34
- | 15 davidmerfield/randomColor JavaScript 66 3
35
- | 16 dawn/dawn Ruby 62 2
36
- | 17 greatfire/wiki 54 9
37
- | 18 swift-jp/swift-guide CSS 45 9
38
- | 19 addyosmani/psi JavaScript 49 0
39
- | 20 mtford90/silk Python 47 0
40
- | 21 agaue/agaue Go 47 0
41
- | 22 mentionapp/mntpulltoreact Objective-C 46 1
42
- | 23 mikepenz/AboutLibraries Java 45 0
43
- | 24 PistonDevelopers/piston-workspace Shell 45 0
44
- | 25 maxpow4h/swiftz Swift 43 1
45
- EOS
46
- expect { @cli.list }.to output(res).to_stdout
18
+ expect { @cli.list }.to output(dummy_result_no_options).to_stdout
47
19
  end
48
20
  end
49
21
 
@@ -84,7 +56,7 @@ RSpec.describe GitTrend::CLI do
84
56
  | 24 sferik/twitter Ruby 0 1
85
57
  | 25 rightscale/rightscale_cookbooks Ruby 0 1
86
58
  EOS
87
- expect { @cli.invoke(:list, [], {list: language}) }.to output(res).to_stdout
59
+ expect { @cli.invoke(:list, [], {language: language}) }.to output(res).to_stdout
88
60
  end
89
61
  end
90
62
 
@@ -124,7 +96,7 @@ RSpec.describe GitTrend::CLI do
124
96
  | 24 Yonsm/CeleWare Objective-C++ 0 0
125
97
  | 25 ccrma/miniAudicle Objective-C++ 0 0
126
98
  EOS
127
- expect { @cli.invoke(:list, [], {list: language}) }.to output(res).to_stdout
99
+ expect { @cli.invoke(:list, [], {language: language}) }.to output(res).to_stdout
128
100
  end
129
101
  end
130
102
  end
@@ -211,6 +183,67 @@ RSpec.describe GitTrend::CLI do
211
183
  end
212
184
  end
213
185
 
186
+ describe 'with -d option' do
187
+
188
+ after do
189
+ ENV['COLUMNS'] = nil
190
+ ENV['LINES'] = nil
191
+ end
192
+
193
+ context 'terminal width is enough' do
194
+ before do
195
+ stub_request_get("trending")
196
+ ENV['COLUMNS'] = '140'
197
+ ENV['LINES'] = '40'
198
+ end
199
+
200
+ it 'display daily ranking with description' do
201
+ res = <<-'EOS'.unindent
202
+ |No. Name Lang Star Fork Description
203
+ |--- -------------------------------------------------- ------------ ------ ----- -----------------------------------------------------------
204
+ | 1 prat0318/json_resume Ruby 264 15 Generates pretty HTML, LaTeX, markdown, with biodata fee...
205
+ | 2 andlabs/ui Go 185 8 Platform-native GUI library for Go.
206
+ | 3 jessepollak/card CSS 174 9 make your credit card form better in one line of code
207
+ | 4 fullstackio/FlappySwift Swift 148 44 swift implementation of flappy bird. More at fullstacked...
208
+ | 5 grant/swift-cheat-sheet 153 13 A short guide to using Apple's new programming language,...
209
+ | 6 Flolagale/mailin Python 155 3 Artisanal inbound emails for every web app
210
+ | 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31 中文版 Apple 官方 Swift 教程《The Swift Programming Lang...
211
+ | 8 hippyvm/hippyvm PHP 113 1 HippyVM - an implementation of the PHP language in RPyth...
212
+ | 9 neovim/neovim C 83 8 vim's rebirth for the 21st century
213
+ | 10 hiphopapp/hiphop CoffeeScript 77 8 Free music streaming app
214
+ | 11 interagent/http-api-design 78 4 HTTP API design guide extracted from work on the Heroku ...
215
+ | 12 austinzheng/swift-2048 Swift 69 16 2048 for Swift
216
+ | 13 mdznr/What-s-New Objective-C 72 2 Easily present the latest changes and features to your u...
217
+ | 14 daneden/animate.css CSS 65 6 A cross-browser library of CSS animations. As easy to us...
218
+ | 15 davidmerfield/randomColor JavaScript 66 3 A color generator for JavaScript.
219
+ | 16 dawn/dawn Ruby 62 2 Docker-based PaaS in Ruby
220
+ | 17 greatfire/wiki 54 9
221
+ | 18 swift-jp/swift-guide CSS 45 9 Appleが公表した新プログラミング言語「Swift」についての資...
222
+ | 19 addyosmani/psi JavaScript 49 0 PageSpeed Insights for Node - with reporting
223
+ | 20 mtford90/silk Python 47 0 Silky smooth profiling for Django
224
+ | 21 agaue/agaue Go 47 0 Golang blog framework
225
+ | 22 mentionapp/mntpulltoreact Objective-C 46 1 One gesture, many actions. An evolution of Pull to Refre...
226
+ | 23 mikepenz/AboutLibraries Java 45 0 AboutLibraries is a library to offer some information of...
227
+ | 24 PistonDevelopers/piston-workspace Shell 45 0 Git submodules of Piston projects
228
+ | 25 maxpow4h/swiftz Swift 43 1 Functional programming in Swift
229
+ EOS
230
+ expect { @cli.invoke(:list, [], {description: 'description'}) }.to output(res).to_stdout
231
+ end
232
+ end
233
+
234
+ context 'terminal width is tiny' do
235
+ before do
236
+ stub_request_get("trending")
237
+ ENV['COLUMNS'] = '100' # it is not enough for description.
238
+ ENV['LINES'] = '40'
239
+ end
240
+
241
+ it 'display daily ranking about the same as no option' do
242
+ expect { @cli.invoke(:list, [], {description: 'description'}) }.to output(dummy_result_no_options).to_stdout
243
+ end
244
+ end
245
+ end
246
+
214
247
  describe 'with -l and -s option' do
215
248
  context 'with ruby and weekly' do
216
249
  before do
@@ -249,7 +282,7 @@ RSpec.describe GitTrend::CLI do
249
282
  | 24 chloerei/campo Ruby 35 9
250
283
  | 25 jordansissel/fpm Ruby 35 4
251
284
  EOS
252
- expect { @cli.invoke(:list, [], {list: language, since: since}) }.to output(res).to_stdout
285
+ expect { @cli.invoke(:list, [], {language: language, since: since}) }.to output(res).to_stdout
253
286
  end
254
287
  end
255
288
  end
@@ -471,4 +504,35 @@ RSpec.describe GitTrend::CLI do
471
504
  :body => load_http_stub(stub_url))
472
505
  end
473
506
 
507
+ def dummy_result_no_options
508
+ <<-'EOS'.unindent
509
+ |No. Name Lang Star Fork
510
+ |--- -------------------------------------------------- ------------ ------ -----
511
+ | 1 prat0318/json_resume Ruby 264 15
512
+ | 2 andlabs/ui Go 185 8
513
+ | 3 jessepollak/card CSS 174 9
514
+ | 4 fullstackio/FlappySwift Swift 148 44
515
+ | 5 grant/swift-cheat-sheet 153 13
516
+ | 6 Flolagale/mailin Python 155 3
517
+ | 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31
518
+ | 8 hippyvm/hippyvm PHP 113 1
519
+ | 9 neovim/neovim C 83 8
520
+ | 10 hiphopapp/hiphop CoffeeScript 77 8
521
+ | 11 interagent/http-api-design 78 4
522
+ | 12 austinzheng/swift-2048 Swift 69 16
523
+ | 13 mdznr/What-s-New Objective-C 72 2
524
+ | 14 daneden/animate.css CSS 65 6
525
+ | 15 davidmerfield/randomColor JavaScript 66 3
526
+ | 16 dawn/dawn Ruby 62 2
527
+ | 17 greatfire/wiki 54 9
528
+ | 18 swift-jp/swift-guide CSS 45 9
529
+ | 19 addyosmani/psi JavaScript 49 0
530
+ | 20 mtford90/silk Python 47 0
531
+ | 21 agaue/agaue Go 47 0
532
+ | 22 mentionapp/mntpulltoreact Objective-C 46 1
533
+ | 23 mikepenz/AboutLibraries Java 45 0
534
+ | 24 PistonDevelopers/piston-workspace Shell 45 0
535
+ | 25 maxpow4h/swiftz Swift 43 1
536
+ EOS
537
+ end
474
538
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-trend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - rochefort
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor