hube 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/hube.rb +13 -0
- data/lib/hube/cli.rb +51 -0
- data/lib/hube/github.rb +50 -0
- data/lib/hube/locale/en.yaml +15 -0
- data/lib/hube/translation.rb +68 -0
- data/lib/hube/user.rb +85 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 18944cf56d43209e485b8edb94500e6d5180b443
|
4
|
+
data.tar.gz: 1b18f5a677ce576d5fbb7877936ec6be58e1ee4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e05a8670d71071c7739a5361299c647cb2e9191d98a0ebffd161b2c948711718d75c2901df3b5aa7ebf85fb8b213684c62c9c5928bec75a5bb081fcaf5761694
|
7
|
+
data.tar.gz: 65a74ac961b8c581193e1a40de23b9177e74b5b7dc57e24735a9636c6e85f2616b6f49a8e60944358da9a86b7f23bc8e5606ddf70f8b70cc7baeb12d7a715a35
|
data/lib/hube.rb
ADDED
data/lib/hube/cli.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Hube
|
2
|
+
class Cli
|
3
|
+
|
4
|
+
# TODO: Make locale optional with lang en default
|
5
|
+
|
6
|
+
def initialize(access_token = nil)
|
7
|
+
@client = Hube::Github.new(access_token)
|
8
|
+
@locale = Hube::Translation.new(File.join(File.dirname(__FILE__), '/locale/en.yaml'))
|
9
|
+
end
|
10
|
+
|
11
|
+
def terminal
|
12
|
+
@locale.hello(@client.user.username)
|
13
|
+
|
14
|
+
loop do
|
15
|
+
option, args = wait_input(@client.user.username)
|
16
|
+
|
17
|
+
case option.chomp.to_s.to_sym
|
18
|
+
when :rs, :repos
|
19
|
+
@locale.repos(@client.repos_formatted)
|
20
|
+
when :gs, :gists
|
21
|
+
@locale.gists(@client.gists_formatted)
|
22
|
+
when :m, :me
|
23
|
+
@locale.t(:user, @client.user.infos)
|
24
|
+
when :w, :whois
|
25
|
+
@locale.t(:user, @client.whois(args.first).infos)
|
26
|
+
when :h, :help
|
27
|
+
@locale.help
|
28
|
+
when :c, :clear
|
29
|
+
clear_terminal
|
30
|
+
when :q, :quit, :exit
|
31
|
+
break
|
32
|
+
else
|
33
|
+
puts "command not found: #{option}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def wait_input(username)
|
41
|
+
print "[github@#{username}]: "
|
42
|
+
input = gets.split()
|
43
|
+
[input.shift, input]
|
44
|
+
end
|
45
|
+
|
46
|
+
def clear_terminal
|
47
|
+
puts `clear`
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
data/lib/hube/github.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module Hube
|
2
|
+
class Github
|
3
|
+
|
4
|
+
attr_accessor :user, :repos, :gists
|
5
|
+
|
6
|
+
def initialize(token = nil)
|
7
|
+
client = Octokit::Client.new(access_token: access_token(token))
|
8
|
+
@user = User.new(client.user.login)
|
9
|
+
@repos = client.repos
|
10
|
+
@gists = client.gists
|
11
|
+
end
|
12
|
+
|
13
|
+
# TODO: Create class for Repository
|
14
|
+
def repos_formatted
|
15
|
+
@repos.map.with_index(1){|r, i|
|
16
|
+
{
|
17
|
+
id: i.to_s,
|
18
|
+
owner: r.owner.login,
|
19
|
+
path: r.full_name,
|
20
|
+
private: r.private,
|
21
|
+
language: r.language,
|
22
|
+
open_issues: r.open_issues
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# TODO: Create class for Gist
|
28
|
+
def gists_formatted
|
29
|
+
@gists.map.with_index(1){|g, i|
|
30
|
+
{
|
31
|
+
id: i.to_s,
|
32
|
+
created_at: g[:created_at].strftime('%Y/%m/%d'),
|
33
|
+
filename: g[:files].to_a[0][1][:filename],
|
34
|
+
language: g[:files].to_a[0][1][:language]
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def whois(username)
|
40
|
+
User.new(username)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def access_token(token)
|
46
|
+
token ? token : ENV['GITHUB_ACCESS_TOKEN']
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
hello: |
|
2
|
+
Hello @%{username}, you are connected with Github!
|
3
|
+
|
4
|
+
Type h or help to display manual.
|
5
|
+
|
6
|
+
user: |
|
7
|
+
Name: %{name}
|
8
|
+
Username: %{username}
|
9
|
+
Email: %{email}
|
10
|
+
Public repositories: %{public_repos}
|
11
|
+
Public gists: %{public_gists}
|
12
|
+
Follwers: %{followers}
|
13
|
+
Follwing: %{following}
|
14
|
+
Created at: %{created_at}
|
15
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'hirb'
|
3
|
+
|
4
|
+
module Hube
|
5
|
+
class Translation
|
6
|
+
|
7
|
+
include Hirb::Console
|
8
|
+
|
9
|
+
OPTIONS = [
|
10
|
+
{shortcut: 'rs', description: 'will list your repos', alias: 'repos'},
|
11
|
+
{shortcut: 'gs', description: 'will list your gits', alias: 'gists'},
|
12
|
+
{shortcut: 'm', description: 'will show you', alias: 'me'},
|
13
|
+
{shortcut: 'w', description: 'will show who is user', alias: 'whois'},
|
14
|
+
{shortcut: 'h', description: 'will show help', alias: 'help'},
|
15
|
+
{shortcut: 'c', description: 'will clear terminal', alias: 'clear'},
|
16
|
+
{shortcut: 'q', description: 'will quit', alias: 'quit'}
|
17
|
+
]
|
18
|
+
|
19
|
+
def initialize(lang)
|
20
|
+
@lang = File.open(lang)
|
21
|
+
@file = YAML.load(@lang.read)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Generic translate
|
26
|
+
#
|
27
|
+
def translate(locale_key, options = {})
|
28
|
+
puts parser(@file[locale_key.to_s], options)
|
29
|
+
end
|
30
|
+
alias :t :translate
|
31
|
+
|
32
|
+
def hello(username)
|
33
|
+
puts parser(@file['hello'], username: username)
|
34
|
+
end
|
35
|
+
|
36
|
+
def repos(repos)
|
37
|
+
table(repos, {markdown: true, fields: repos.first.keys})
|
38
|
+
end
|
39
|
+
|
40
|
+
def gists(gists)
|
41
|
+
table(gists, {markdown: true, fields: gists.first.keys})
|
42
|
+
end
|
43
|
+
|
44
|
+
def help
|
45
|
+
table(OPTIONS, {markdown: true})
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parser(text, options = {})
|
51
|
+
options.keys.each do |key|
|
52
|
+
matchs = regex_keys(key, text)
|
53
|
+
text = text.gsub(matchs.to_s, options[key].to_s) if matchs
|
54
|
+
end
|
55
|
+
|
56
|
+
yaml_safe(text)
|
57
|
+
end
|
58
|
+
|
59
|
+
def regex_keys(key, text)
|
60
|
+
/%{(#{key})}/.match(text)
|
61
|
+
end
|
62
|
+
|
63
|
+
def yaml_safe(text)
|
64
|
+
text.to_yaml[5..-1] + "\n"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
data/lib/hube/user.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
module Hube
|
2
|
+
class User
|
3
|
+
|
4
|
+
def initialize(username)
|
5
|
+
@user = Octokit.user(username)
|
6
|
+
end
|
7
|
+
|
8
|
+
def username
|
9
|
+
@user[:login]
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
@user[:name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def company
|
17
|
+
@user[:company]
|
18
|
+
end
|
19
|
+
|
20
|
+
def blog
|
21
|
+
@user[:blog]
|
22
|
+
end
|
23
|
+
|
24
|
+
def location
|
25
|
+
@user[:location]
|
26
|
+
end
|
27
|
+
|
28
|
+
def email
|
29
|
+
@user[:email]
|
30
|
+
end
|
31
|
+
|
32
|
+
def bio
|
33
|
+
@user[:bio]
|
34
|
+
end
|
35
|
+
|
36
|
+
def public_repos
|
37
|
+
@user[:public_repos]
|
38
|
+
end
|
39
|
+
|
40
|
+
def public_gists
|
41
|
+
@user[:public_gists]
|
42
|
+
end
|
43
|
+
|
44
|
+
def private_gists
|
45
|
+
@user[:private_gists]
|
46
|
+
end
|
47
|
+
|
48
|
+
def followers
|
49
|
+
@user[:followers]
|
50
|
+
end
|
51
|
+
|
52
|
+
def following
|
53
|
+
@user[:following]
|
54
|
+
end
|
55
|
+
|
56
|
+
def created_at(format: nil)
|
57
|
+
format ? @user[:created_at].strftime('%d %b %Y') : @user[:created_at].to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
def infos
|
61
|
+
options.delete_if{|k, v| v.nil?}
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def options
|
67
|
+
{
|
68
|
+
username: username,
|
69
|
+
name: name,
|
70
|
+
company: company,
|
71
|
+
blog: blog,
|
72
|
+
location: location,
|
73
|
+
email: email,
|
74
|
+
bio: bio,
|
75
|
+
public_repos: public_repos,
|
76
|
+
public_gists: public_gists,
|
77
|
+
private_gists: private_gists,
|
78
|
+
followers: followers,
|
79
|
+
following: following,
|
80
|
+
created_at: created_at(format: true)
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hube
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fernando Oliveira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hirb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
description: A simple Ruby gem for working with the GitHub Events
|
56
|
+
email: fernandopso@bsi.ufla.br
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/hube.rb
|
62
|
+
- lib/hube/cli.rb
|
63
|
+
- lib/hube/github.rb
|
64
|
+
- lib/hube/locale/en.yaml
|
65
|
+
- lib/hube/translation.rb
|
66
|
+
- lib/hube/user.rb
|
67
|
+
homepage: https://github.com/fernandopso/hube
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.0.0
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.2.2
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Hube events
|
91
|
+
test_files: []
|