trendhub 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +52 -0
- data/bin/console +15 -0
- data/bin/setup +6 -0
- data/bin/trendhub +6 -0
- data/data/languages +499 -0
- data/lib/trendhub.rb +12 -0
- data/lib/trendhub/cli.rb +32 -0
- data/lib/trendhub/commands/languages.rb +13 -0
- data/lib/trendhub/commands/repo.rb +40 -0
- data/lib/trendhub/language.rb +27 -0
- data/lib/trendhub/repositories.rb +52 -0
- data/lib/trendhub/repository.rb +36 -0
- data/lib/trendhub/utils/color.rb +46 -0
- data/lib/trendhub/version.rb +5 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6f355a1f10c692f91ef2c1316f0cb114ea917e23a9f8f0dabbae9bc8bb3a152
|
4
|
+
data.tar.gz: f316fb812021f46b92b369aabc9c3e0cfe50a6389e19c947042a58afcf1fc99b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 12302f1920024a61ccda9586645bfe4ae8e860025b3d28e28f09e7877d679cb1bffe81a0c760ad19629971c8953456dbab70322388074eff35c17722afb809c6
|
7
|
+
data.tar.gz: 1fd7b947ac63dd0c2a2140b06b0db1a2cac268efb20cb4d92fcfe0d178c573c8144509f401b94f10e35860534f0d6ccc3e29d974a3d98076460246813a784062
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Son Dang
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Trendhub
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sondnm/trendhub.svg?branch=master)](https://travis-ci.org/sondnm/trendhub)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/961c76d5f9d2014eedc5/maintainability)](https://codeclimate.com/github/sondnm/trendhub/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/961c76d5f9d2014eedc5/test_coverage)](https://codeclimate.com/github/sondnm/trendhub/test_coverage)
|
6
|
+
|
7
|
+
`trendhub` is a CLI gem to fetch github trending repositories.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install this gem yourself as:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ gem install trendhub
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### `trendhub repo`
|
20
|
+
List trending repositories from Github
|
21
|
+
Supported options:
|
22
|
+
```
|
23
|
+
trendhub repo
|
24
|
+
--for # Allow listing trending repositories
|
25
|
+
in time range of daily, weekly or monthly.
|
26
|
+
--language # Allow listing trending repositories
|
27
|
+
in a supported language, unknown ones or all.
|
28
|
+
```
|
29
|
+
|
30
|
+
### `trendhub languages`
|
31
|
+
List all supported languages in format of slug
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
|
36
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
37
|
+
|
38
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
39
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
40
|
+
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/trendhub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
49
|
+
|
50
|
+
## Code of Conduct
|
51
|
+
|
52
|
+
Everyone interacting in the Trendhub project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sondnm/trendhub/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "trendhub"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/trendhub
ADDED
data/data/languages
ADDED
@@ -0,0 +1,499 @@
|
|
1
|
+
1c-enterprise
|
2
|
+
abap
|
3
|
+
abnf
|
4
|
+
ags-script
|
5
|
+
ampl
|
6
|
+
antlr
|
7
|
+
api-blueprint
|
8
|
+
apl
|
9
|
+
asn.1
|
10
|
+
asp
|
11
|
+
ats
|
12
|
+
actionscript
|
13
|
+
ada
|
14
|
+
adobe-font-metrics
|
15
|
+
agda
|
16
|
+
alloy
|
17
|
+
alpine-abuild
|
18
|
+
angelscript
|
19
|
+
ant-build-system
|
20
|
+
apacheconf
|
21
|
+
apex
|
22
|
+
apollo-guidance-computer
|
23
|
+
applescript
|
24
|
+
arc
|
25
|
+
asciidoc
|
26
|
+
aspectj
|
27
|
+
assembly
|
28
|
+
asymptote
|
29
|
+
augeas
|
30
|
+
autohotkey
|
31
|
+
autoit
|
32
|
+
awk
|
33
|
+
ballerina
|
34
|
+
batchfile
|
35
|
+
befunge
|
36
|
+
bison
|
37
|
+
bitbake
|
38
|
+
blade
|
39
|
+
blitzbasic
|
40
|
+
blitzmax
|
41
|
+
bluespec
|
42
|
+
boo
|
43
|
+
brainfuck
|
44
|
+
brightscript
|
45
|
+
bro
|
46
|
+
c
|
47
|
+
c#
|
48
|
+
c++
|
49
|
+
c-objdump
|
50
|
+
c2hs-haskell
|
51
|
+
clips
|
52
|
+
cmake
|
53
|
+
cobol
|
54
|
+
collada
|
55
|
+
cson
|
56
|
+
css
|
57
|
+
csv
|
58
|
+
cweb
|
59
|
+
cap'n-proto
|
60
|
+
cartocss
|
61
|
+
ceylon
|
62
|
+
chapel
|
63
|
+
charity
|
64
|
+
chuck
|
65
|
+
cirru
|
66
|
+
clarion
|
67
|
+
clean
|
68
|
+
click
|
69
|
+
clojure
|
70
|
+
closure-templates
|
71
|
+
cloud-firestore-security-rules
|
72
|
+
conll-u
|
73
|
+
coffeescript
|
74
|
+
coldfusion
|
75
|
+
coldfusion-cfc
|
76
|
+
common-lisp
|
77
|
+
common-workflow-language
|
78
|
+
component-pascal
|
79
|
+
cool
|
80
|
+
coq
|
81
|
+
cpp-objdump
|
82
|
+
creole
|
83
|
+
crystal
|
84
|
+
csound
|
85
|
+
csound-document
|
86
|
+
csound-score
|
87
|
+
cuda
|
88
|
+
cycript
|
89
|
+
cython
|
90
|
+
d
|
91
|
+
d-objdump
|
92
|
+
digital-command-language
|
93
|
+
dm
|
94
|
+
dns-zone
|
95
|
+
dtrace
|
96
|
+
darcs-patch
|
97
|
+
dart
|
98
|
+
dataweave
|
99
|
+
diff
|
100
|
+
dockerfile
|
101
|
+
dogescript
|
102
|
+
dylan
|
103
|
+
e
|
104
|
+
ebnf
|
105
|
+
ecl
|
106
|
+
eclipse
|
107
|
+
ejs
|
108
|
+
eml
|
109
|
+
eq
|
110
|
+
eagle
|
111
|
+
easybuild
|
112
|
+
ecere-projects
|
113
|
+
edje-data-collection
|
114
|
+
eiffel
|
115
|
+
elixir
|
116
|
+
elm
|
117
|
+
emacs-lisp
|
118
|
+
emberscript
|
119
|
+
erlang
|
120
|
+
f#
|
121
|
+
f*
|
122
|
+
figlet-font
|
123
|
+
flux
|
124
|
+
factor
|
125
|
+
fancy
|
126
|
+
fantom
|
127
|
+
filebench-wml
|
128
|
+
filterscript
|
129
|
+
formatted
|
130
|
+
forth
|
131
|
+
fortran
|
132
|
+
freemarker
|
133
|
+
frege
|
134
|
+
g-code
|
135
|
+
gams
|
136
|
+
gap
|
137
|
+
gcc-machine-description
|
138
|
+
gdb
|
139
|
+
gdscript
|
140
|
+
glsl
|
141
|
+
gn
|
142
|
+
game-maker-language
|
143
|
+
genie
|
144
|
+
genshi
|
145
|
+
gentoo-ebuild
|
146
|
+
gentoo-eclass
|
147
|
+
gerber-image
|
148
|
+
gettext-catalog
|
149
|
+
gherkin
|
150
|
+
git-attributes
|
151
|
+
git-config
|
152
|
+
glyph
|
153
|
+
glyph-bitmap-distribution-format
|
154
|
+
gnuplot
|
155
|
+
go
|
156
|
+
golo
|
157
|
+
gosu
|
158
|
+
grace
|
159
|
+
gradle
|
160
|
+
grammatical-framework
|
161
|
+
graph-modeling-language
|
162
|
+
graphql
|
163
|
+
graphviz-(dot)
|
164
|
+
groovy
|
165
|
+
groovy-server-pages
|
166
|
+
haproxy
|
167
|
+
hcl
|
168
|
+
hlsl
|
169
|
+
html
|
170
|
+
html+django
|
171
|
+
html+ecr
|
172
|
+
html+eex
|
173
|
+
html+erb
|
174
|
+
html+php
|
175
|
+
html+razor
|
176
|
+
http
|
177
|
+
hxml
|
178
|
+
hack
|
179
|
+
haml
|
180
|
+
handlebars
|
181
|
+
harbour
|
182
|
+
haskell
|
183
|
+
haxe
|
184
|
+
hiveql
|
185
|
+
hy
|
186
|
+
hyphy
|
187
|
+
idl
|
188
|
+
igor-pro
|
189
|
+
ini
|
190
|
+
irc-log
|
191
|
+
idris
|
192
|
+
ignore-list
|
193
|
+
inform-7
|
194
|
+
inno-setup
|
195
|
+
io
|
196
|
+
ioke
|
197
|
+
isabelle
|
198
|
+
isabelle-root
|
199
|
+
j
|
200
|
+
jflex
|
201
|
+
json
|
202
|
+
json-with-comments
|
203
|
+
json5
|
204
|
+
jsonld
|
205
|
+
jsoniq
|
206
|
+
jsx
|
207
|
+
jasmin
|
208
|
+
java
|
209
|
+
java-properties
|
210
|
+
java-server-pages
|
211
|
+
javascript
|
212
|
+
jison
|
213
|
+
jison-lex
|
214
|
+
jolie
|
215
|
+
julia
|
216
|
+
jupyter-notebook
|
217
|
+
krl
|
218
|
+
kicad-layout
|
219
|
+
kicad-legacy-layout
|
220
|
+
kicad-schematic
|
221
|
+
kit
|
222
|
+
kotlin
|
223
|
+
lfe
|
224
|
+
llvm
|
225
|
+
lolcode
|
226
|
+
lsl
|
227
|
+
ltspice-symbol
|
228
|
+
labview
|
229
|
+
lasso
|
230
|
+
latte
|
231
|
+
lean
|
232
|
+
less
|
233
|
+
lex
|
234
|
+
lilypond
|
235
|
+
limbo
|
236
|
+
linker-script
|
237
|
+
linux-kernel-module
|
238
|
+
liquid
|
239
|
+
literate-agda
|
240
|
+
literate-coffeescript
|
241
|
+
literate-haskell
|
242
|
+
livescript
|
243
|
+
logos
|
244
|
+
logtalk
|
245
|
+
lookml
|
246
|
+
loomscript
|
247
|
+
lua
|
248
|
+
m
|
249
|
+
m4
|
250
|
+
m4sugar
|
251
|
+
matlab
|
252
|
+
maxscript
|
253
|
+
mql4
|
254
|
+
mql5
|
255
|
+
mtml
|
256
|
+
muf
|
257
|
+
makefile
|
258
|
+
mako
|
259
|
+
markdown
|
260
|
+
marko
|
261
|
+
mask
|
262
|
+
mathematica
|
263
|
+
maven-pom
|
264
|
+
max
|
265
|
+
mediawiki
|
266
|
+
mercury
|
267
|
+
meson
|
268
|
+
metal
|
269
|
+
minid
|
270
|
+
mirah
|
271
|
+
modelica
|
272
|
+
modula-2
|
273
|
+
modula-3
|
274
|
+
module-management-system
|
275
|
+
monkey
|
276
|
+
moocode
|
277
|
+
moonscript
|
278
|
+
myghty
|
279
|
+
ncl
|
280
|
+
nl
|
281
|
+
nsis
|
282
|
+
nearley
|
283
|
+
nemerle
|
284
|
+
netlinx
|
285
|
+
netlinx+erb
|
286
|
+
netlogo
|
287
|
+
newlisp
|
288
|
+
nextflow
|
289
|
+
nginx
|
290
|
+
nim
|
291
|
+
ninja
|
292
|
+
nit
|
293
|
+
nix
|
294
|
+
nu
|
295
|
+
numpy
|
296
|
+
ocaml
|
297
|
+
objdump
|
298
|
+
objective-c
|
299
|
+
objective-c++
|
300
|
+
objective-j
|
301
|
+
omgrofl
|
302
|
+
opa
|
303
|
+
opal
|
304
|
+
opencl
|
305
|
+
openedge-abl
|
306
|
+
openrc-runscript
|
307
|
+
openscad
|
308
|
+
opentype-feature-file
|
309
|
+
org
|
310
|
+
ox
|
311
|
+
oxygene
|
312
|
+
oz
|
313
|
+
p4
|
314
|
+
php
|
315
|
+
plsql
|
316
|
+
plpgsql
|
317
|
+
pov-ray-sdl
|
318
|
+
pan
|
319
|
+
papyrus
|
320
|
+
parrot
|
321
|
+
parrot-assembly
|
322
|
+
parrot-internal-representation
|
323
|
+
pascal
|
324
|
+
pawn
|
325
|
+
pep8
|
326
|
+
perl
|
327
|
+
perl-6
|
328
|
+
pic
|
329
|
+
pickle
|
330
|
+
picolisp
|
331
|
+
piglatin
|
332
|
+
pike
|
333
|
+
pod
|
334
|
+
pod-6
|
335
|
+
pogoscript
|
336
|
+
pony
|
337
|
+
postcss
|
338
|
+
postscript
|
339
|
+
powerbuilder
|
340
|
+
powershell
|
341
|
+
processing
|
342
|
+
prolog
|
343
|
+
propeller-spin
|
344
|
+
protocol-buffer
|
345
|
+
public-key
|
346
|
+
pug
|
347
|
+
puppet
|
348
|
+
pure-data
|
349
|
+
purebasic
|
350
|
+
purescript
|
351
|
+
python
|
352
|
+
python-console
|
353
|
+
python-traceback
|
354
|
+
qml
|
355
|
+
qmake
|
356
|
+
quake
|
357
|
+
r
|
358
|
+
raml
|
359
|
+
rdoc
|
360
|
+
realbasic
|
361
|
+
rexx
|
362
|
+
rhtml
|
363
|
+
rmarkdown
|
364
|
+
rpc
|
365
|
+
rpm-spec
|
366
|
+
runoff
|
367
|
+
racket
|
368
|
+
ragel
|
369
|
+
rascal
|
370
|
+
raw-token-data
|
371
|
+
reason
|
372
|
+
rebol
|
373
|
+
red
|
374
|
+
redcode
|
375
|
+
regular-expression
|
376
|
+
ren'py
|
377
|
+
renderscript
|
378
|
+
ring
|
379
|
+
robotframework
|
380
|
+
roff
|
381
|
+
roff-manpage
|
382
|
+
rouge
|
383
|
+
ruby
|
384
|
+
rust
|
385
|
+
sas
|
386
|
+
scss
|
387
|
+
smt
|
388
|
+
sparql
|
389
|
+
sqf
|
390
|
+
sql
|
391
|
+
sqlpl
|
392
|
+
srecode-template
|
393
|
+
ston
|
394
|
+
svg
|
395
|
+
sage
|
396
|
+
saltstack
|
397
|
+
sass
|
398
|
+
scala
|
399
|
+
scaml
|
400
|
+
scheme
|
401
|
+
scilab
|
402
|
+
self
|
403
|
+
shaderlab
|
404
|
+
shell
|
405
|
+
shellsession
|
406
|
+
shen
|
407
|
+
slash
|
408
|
+
slice
|
409
|
+
slim
|
410
|
+
smali
|
411
|
+
smalltalk
|
412
|
+
smarty
|
413
|
+
solidity
|
414
|
+
sourcepawn
|
415
|
+
spline-font-database
|
416
|
+
squirrel
|
417
|
+
stan
|
418
|
+
standard-ml
|
419
|
+
stata
|
420
|
+
stylus
|
421
|
+
subrip-text
|
422
|
+
sugarss
|
423
|
+
supercollider
|
424
|
+
swift
|
425
|
+
systemverilog
|
426
|
+
ti-program
|
427
|
+
tla
|
428
|
+
toml
|
429
|
+
txl
|
430
|
+
tcl
|
431
|
+
tcsh
|
432
|
+
tex
|
433
|
+
tea
|
434
|
+
terra
|
435
|
+
text
|
436
|
+
textile
|
437
|
+
thrift
|
438
|
+
turing
|
439
|
+
turtle
|
440
|
+
twig
|
441
|
+
type-language
|
442
|
+
typescript
|
443
|
+
unified-parallel-c
|
444
|
+
unity3d-asset
|
445
|
+
unix-assembly
|
446
|
+
uno
|
447
|
+
unrealscript
|
448
|
+
urweb
|
449
|
+
vcl
|
450
|
+
vhdl
|
451
|
+
vala
|
452
|
+
verilog
|
453
|
+
vim-script
|
454
|
+
visual-basic
|
455
|
+
volt
|
456
|
+
vue
|
457
|
+
wavefront-material
|
458
|
+
wavefront-object
|
459
|
+
web-ontology-language
|
460
|
+
webassembly
|
461
|
+
webidl
|
462
|
+
windows-registry-entries
|
463
|
+
world-of-warcraft-addon-data
|
464
|
+
x-bitmap
|
465
|
+
x-font-directory-index
|
466
|
+
x-pixmap
|
467
|
+
x10
|
468
|
+
xc
|
469
|
+
xcompose
|
470
|
+
xml
|
471
|
+
xpages
|
472
|
+
xproc
|
473
|
+
xquery
|
474
|
+
xs
|
475
|
+
xslt
|
476
|
+
xojo
|
477
|
+
xtend
|
478
|
+
yaml
|
479
|
+
yang
|
480
|
+
yara
|
481
|
+
yasnippet
|
482
|
+
yacc
|
483
|
+
zephir
|
484
|
+
zig
|
485
|
+
zimpl
|
486
|
+
desktop
|
487
|
+
ec
|
488
|
+
edn
|
489
|
+
fish
|
490
|
+
mupad
|
491
|
+
nanorc
|
492
|
+
nesc
|
493
|
+
ooc
|
494
|
+
q
|
495
|
+
restructuredtext
|
496
|
+
sed
|
497
|
+
wdl
|
498
|
+
wisp
|
499
|
+
xbase
|
data/lib/trendhub.rb
ADDED
data/lib/trendhub/cli.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "trendhub/commands/repo"
|
5
|
+
require "trendhub/commands/languages"
|
6
|
+
|
7
|
+
module Trendhub
|
8
|
+
class CLI < Thor
|
9
|
+
package_name "Trendhub CLI"
|
10
|
+
desc "repo", "List trending repositories"
|
11
|
+
|
12
|
+
method_option :for,
|
13
|
+
type: :string,
|
14
|
+
enum: %w(daily weekly monthly),
|
15
|
+
default: "daily",
|
16
|
+
desc: "Select from daily, weekly, monthly"
|
17
|
+
method_option :language,
|
18
|
+
type: :string,
|
19
|
+
default: "",
|
20
|
+
desc: "Select from list of supported languages"
|
21
|
+
|
22
|
+
def repo
|
23
|
+
Trendhub::Commands::Repo.new(options).execute
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "languages", "List all supported languages"
|
27
|
+
|
28
|
+
def languages
|
29
|
+
Trendhub::Commands::Languages.new.execute
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'trendhub/repositories'
|
4
|
+
require 'trendhub/utils/color'
|
5
|
+
|
6
|
+
module Trendhub
|
7
|
+
module Commands
|
8
|
+
class Repo
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
repositories = Trendhub::Repositories.new.fetch(options[:for], options[:language])
|
15
|
+
repositories.each do |repo|
|
16
|
+
$stdout.puts "-" * 100
|
17
|
+
$stdout.puts "#{colorizer.decorate(repo.name, :bold)} has #{colorizer.decorate(repo.added_stars, :bold, :red)} stars added #{repo.time_period}"
|
18
|
+
$stdout.puts repo.desc
|
19
|
+
repo_info = blank?(repo.language) ? "" : "#{repo.language} "
|
20
|
+
repo_info += "★ #{repo.stars} "
|
21
|
+
repo_info += "#{repo.forks} forks"
|
22
|
+
$stdout.puts repo_info
|
23
|
+
$stdout.puts "URL: #{repo.url}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :options
|
30
|
+
|
31
|
+
def blank?(str)
|
32
|
+
str.nil? || str.empty? || str.match?(/^\s+$/)
|
33
|
+
end
|
34
|
+
|
35
|
+
def colorizer
|
36
|
+
@colorizer ||= Trendhub::Utils::Color.new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Trendhub
|
4
|
+
class Language
|
5
|
+
attr_reader :language_path
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@language_path = "#{Trendhub.root}/data/languages"
|
9
|
+
end
|
10
|
+
|
11
|
+
def all
|
12
|
+
File.read(language_path).split("\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
require 'http'
|
17
|
+
require 'yaml'
|
18
|
+
|
19
|
+
language_url = "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml"
|
20
|
+
response = HTTP.get(language_url)
|
21
|
+
languages = YAML.load(response.to_s).keys.map do |language|
|
22
|
+
language.downcase.gsub(" ", "-")
|
23
|
+
end
|
24
|
+
File.write(language_path, languages.join("\n"))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "http"
|
4
|
+
require "oga"
|
5
|
+
require "trendhub/repository"
|
6
|
+
require "trendhub/language"
|
7
|
+
|
8
|
+
module Trendhub
|
9
|
+
class Repositories
|
10
|
+
InvalidLanguage = Class.new(StandardError)
|
11
|
+
|
12
|
+
def fetch(time_range, language = nil)
|
13
|
+
validate_language(language)
|
14
|
+
|
15
|
+
response = HTTP.get("https://github.com/trending/#{language}?since=#{time_range}")
|
16
|
+
doc = Oga.parse_xml(response.to_s)
|
17
|
+
doc.css(".repo-list li").map do |repo_doc|
|
18
|
+
repo_link = repo_doc.at_css("div h3 a")
|
19
|
+
repo_name = repo_link.text.strip
|
20
|
+
repo_path = repo_link.attr('href').value
|
21
|
+
repo_url = "https://github.com#{repo_path}"
|
22
|
+
repo_desc = repo_doc.at_css("div p").text.strip
|
23
|
+
repo_info = repo_doc.css("div")[3]
|
24
|
+
repo_language = repo_info.at_css("span[itemprop='programmingLanguage']")&.text&.strip
|
25
|
+
repo_stars = repo_info.at_css("a[href='#{repo_path}/stargazers']").text.strip
|
26
|
+
repo_forks = repo_info.at_css("a[href='#{repo_path}/network']").text.strip
|
27
|
+
repo_added_stars = repo_info.css("svg.octicon-star").last.parent.text.gsub(/[^\d,]/, '')
|
28
|
+
|
29
|
+
Trendhub::Repository.new(
|
30
|
+
name: repo_name,
|
31
|
+
url: repo_url,
|
32
|
+
desc: repo_desc,
|
33
|
+
language: repo_language,
|
34
|
+
added_stars: repo_added_stars,
|
35
|
+
forks: repo_forks,
|
36
|
+
stars: repo_stars,
|
37
|
+
time_range: time_range
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def validate_language(language)
|
45
|
+
raise InvalidLanguage if language && language == "developers"
|
46
|
+
end
|
47
|
+
|
48
|
+
def languages
|
49
|
+
@languages ||= Trendhub::Language.new.all
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Trendhub
|
4
|
+
class Repository
|
5
|
+
attr_reader :name
|
6
|
+
attr_reader :time_range
|
7
|
+
attr_reader :url
|
8
|
+
attr_reader :desc
|
9
|
+
attr_reader :language
|
10
|
+
attr_reader :added_stars
|
11
|
+
attr_reader :stars
|
12
|
+
attr_reader :forks
|
13
|
+
|
14
|
+
TIME_ALIASES = {
|
15
|
+
"daily" => "today",
|
16
|
+
"weekly" => "this week",
|
17
|
+
"monthly" => "this month",
|
18
|
+
}
|
19
|
+
|
20
|
+
def initialize(data)
|
21
|
+
@name = data.fetch(:name)
|
22
|
+
@time_range = data.fetch(:time_range)
|
23
|
+
@url = data.fetch(:url)
|
24
|
+
@desc = data.fetch(:desc)
|
25
|
+
@language = data.fetch(:language)
|
26
|
+
@added_stars = data.fetch(:added_stars)
|
27
|
+
@stars = data.fetch(:stars)
|
28
|
+
@forks = data.fetch(:forks)
|
29
|
+
end
|
30
|
+
|
31
|
+
def time_period
|
32
|
+
return 'today' unless self.time_range
|
33
|
+
TIME_ALIASES[self.time_range]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Trendhub
|
4
|
+
module Utils
|
5
|
+
class Color
|
6
|
+
InvalidColorFormat = Class.new(StandardError)
|
7
|
+
|
8
|
+
ANSI = {
|
9
|
+
reset: 0,
|
10
|
+
bold: 1,
|
11
|
+
dim: 2,
|
12
|
+
italic: 3,
|
13
|
+
underline: 4,
|
14
|
+
black: 30,
|
15
|
+
red: 31,
|
16
|
+
green: 32,
|
17
|
+
yellow: 33,
|
18
|
+
blue: 34,
|
19
|
+
magenta: 35,
|
20
|
+
cyan: 36,
|
21
|
+
light_gray: 37,
|
22
|
+
dark_gray: 90,
|
23
|
+
light_red: 91,
|
24
|
+
light_green: 92,
|
25
|
+
light_yellow: 93,
|
26
|
+
light_blue: 94,
|
27
|
+
light_magenta: 95,
|
28
|
+
light_cyan: 96,
|
29
|
+
white: 97,
|
30
|
+
}.freeze
|
31
|
+
|
32
|
+
def decorate(str, *formats)
|
33
|
+
return str if blank?(str) || formats.empty?
|
34
|
+
raise InvalidColorFormat unless (formats - ANSI.keys).empty?
|
35
|
+
format_codes = formats.map { |format| ANSI[format] }
|
36
|
+
"\e[#{format_codes.join(';')}m#{str}\e[0m"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def blank?(str)
|
42
|
+
str.nil? || str.empty? || str.match?(/^\s+$/)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trendhub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Son Dang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.20'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.20'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: http
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oga
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.17'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.17'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.12'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.12'
|
111
|
+
description: View github trending repositories from your terminal.
|
112
|
+
email:
|
113
|
+
- sondangdev@gmail.com
|
114
|
+
executables:
|
115
|
+
- trendhub
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- LICENSE
|
120
|
+
- README.md
|
121
|
+
- bin/console
|
122
|
+
- bin/setup
|
123
|
+
- bin/trendhub
|
124
|
+
- data/languages
|
125
|
+
- lib/trendhub.rb
|
126
|
+
- lib/trendhub/cli.rb
|
127
|
+
- lib/trendhub/commands/languages.rb
|
128
|
+
- lib/trendhub/commands/repo.rb
|
129
|
+
- lib/trendhub/language.rb
|
130
|
+
- lib/trendhub/repositories.rb
|
131
|
+
- lib/trendhub/repository.rb
|
132
|
+
- lib/trendhub/utils/color.rb
|
133
|
+
- lib/trendhub/version.rb
|
134
|
+
homepage: https://github.com/sondnm/trendhub
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata:
|
138
|
+
allowed_push_host: https://rubygems.org
|
139
|
+
homepage_uri: https://github.com/sondnm/trendhub
|
140
|
+
source_code_uri: https://github.com/sondnm/trendhub
|
141
|
+
changelog_uri: https://github.com/sondnm/trendhub/blob/master/CHANGELOG.md
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubygems_version: 3.0.1
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: View github trending repositories from your terminal.
|
161
|
+
test_files: []
|