k_ext-github 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +31 -0
- data/.gitignore +50 -0
- data/.rspec +3 -0
- data/.rubocop.yml +85 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +25 -0
- data/Guardfile +31 -0
- data/LICENSE.txt +21 -0
- data/README.md +115 -0
- data/Rakefile +33 -0
- data/STORIES.md +58 -0
- data/USAGE.md +19 -0
- data/bin/console +16 -0
- data/bin/k +36 -0
- data/bin/kgitsync +76 -0
- data/bin/khotfix +244 -0
- data/bin/setup +11 -0
- data/docs/images/list-repositories-for-organization.png +0 -0
- data/docs/images/list-repositories.png +0 -0
- data/hooks/pre-commit +87 -0
- data/hooks/update-version +33 -0
- data/k_ext-github.gemspec +47 -0
- data/lib/k_ext/github.rb +40 -0
- data/lib/k_ext/github/api.rb +124 -0
- data/lib/k_ext/github/configuration.rb +18 -0
- data/lib/k_ext/github/models/hook.rb +30 -0
- data/lib/k_ext/github/models/owner.rb +19 -0
- data/lib/k_ext/github/models/repository.rb +30 -0
- data/lib/k_ext/github/printer.rb +160 -0
- data/lib/k_ext/github/version.rb +7 -0
- metadata +134 -0
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KExt
|
4
|
+
module Github
|
5
|
+
# Print formatted log for GitHub data such as repositories
|
6
|
+
class Printer
|
7
|
+
extend KLog::Logging
|
8
|
+
|
9
|
+
# ---------------------------------------------
|
10
|
+
# Print Repositories
|
11
|
+
# ---------------------------------------------
|
12
|
+
|
13
|
+
def self.repositories(rows = nil, format = 'default')
|
14
|
+
log.block 'Repositories'
|
15
|
+
|
16
|
+
if rows.nil?
|
17
|
+
Repository.all.each do |_r|
|
18
|
+
repository_with_format(repo, format)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
rows.each do |_r|
|
22
|
+
repository_with_format(repo, format)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.repositories_as_table(rows = nil, format = 'default')
|
28
|
+
log.block 'Repositories'
|
29
|
+
|
30
|
+
rows = Repository.all if rows.nil?
|
31
|
+
|
32
|
+
case format
|
33
|
+
when 'detailed'
|
34
|
+
# tp rows
|
35
|
+
tp rows, :id, :node_id, :name, :full_name, :private, :description, :url, 'owner.login', :created_at, :updated_at, :pushed_at, :git_url
|
36
|
+
else
|
37
|
+
tp rows, :id, :name, :git_url, :full_name, :private, :description, :url, 'owner.login'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.repository_with_format(repo, format)
|
42
|
+
case format
|
43
|
+
when 'detailed'
|
44
|
+
repository_detailed(repo)
|
45
|
+
else
|
46
|
+
repository(repo)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.repository(repo)
|
51
|
+
data = repo_key_values(repo)
|
52
|
+
|
53
|
+
log.kv_hash(data)
|
54
|
+
log.line
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.repository_detailed(repo)
|
58
|
+
data = repo_key_values(repo)
|
59
|
+
|
60
|
+
log.kv_hash(data)
|
61
|
+
log.line
|
62
|
+
|
63
|
+
# Print Relations
|
64
|
+
|
65
|
+
log.line
|
66
|
+
end
|
67
|
+
|
68
|
+
# ---------------------------------------------
|
69
|
+
# Print Hooks
|
70
|
+
# ---------------------------------------------
|
71
|
+
|
72
|
+
def self.hooks(rows = nil, format = 'default')
|
73
|
+
log.block 'Hooks'
|
74
|
+
|
75
|
+
if rows.nil?
|
76
|
+
Hook.all.each do |_r|
|
77
|
+
hook_with_format(repo, format)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
rows.each do |_r|
|
81
|
+
hook_with_format(repo, format)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.hooks_as_table(rows = nil, format = 'default')
|
87
|
+
log.block 'Hooks'
|
88
|
+
|
89
|
+
rows = Hook.all if rows.nil?
|
90
|
+
|
91
|
+
case format
|
92
|
+
when 'detailed'
|
93
|
+
tp rows, :type, :id, :name, :active, :events, :config, :updated_at, :created_at, :url, :test_url, :ping_url, :last_response
|
94
|
+
else
|
95
|
+
tp rows, :type, :id, :name, :active, :url, :config
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.hook_with_format(repo, format)
|
100
|
+
case format
|
101
|
+
when 'detailed'
|
102
|
+
hook_detailed(repo)
|
103
|
+
else
|
104
|
+
hook(repo)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.hook(hook)
|
109
|
+
hook_key_values(hook).each do |key_value|
|
110
|
+
log.kv key_value.key, key_value.vale
|
111
|
+
end
|
112
|
+
|
113
|
+
log.line
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.hook_detailed(hook)
|
117
|
+
hook_key_values(hook).each do |key_value|
|
118
|
+
log.kv key_value.key, key_value.vale
|
119
|
+
end
|
120
|
+
|
121
|
+
# Print Relations
|
122
|
+
|
123
|
+
log.line
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.repo_key_values(repo)
|
127
|
+
{
|
128
|
+
id: repo.id,
|
129
|
+
node_id: repo.node_id,
|
130
|
+
name: repo.name,
|
131
|
+
full_name: repo.full_name,
|
132
|
+
private: repo.private,
|
133
|
+
description: repo.description,
|
134
|
+
url: repo.url,
|
135
|
+
created_at: repo.created_at,
|
136
|
+
updated_at: repo.updated_at,
|
137
|
+
pushed_at: repo.pushed_at,
|
138
|
+
git_url: repo.git_url
|
139
|
+
}
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.hook_key_values(hook)
|
143
|
+
{
|
144
|
+
type: hook.type,
|
145
|
+
id: hook.id,
|
146
|
+
name: hook.name,
|
147
|
+
active: hook.active,
|
148
|
+
events: hook.events,
|
149
|
+
config: hook.config,
|
150
|
+
updated_at: hook.updated_at,
|
151
|
+
created_at: hook.created_at,
|
152
|
+
url: hook.url,
|
153
|
+
test_url: hook.test_url,
|
154
|
+
ping_url: hook.ping_url,
|
155
|
+
last_response: hook.last_response
|
156
|
+
}
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: k_ext-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Cruwys
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: k_log
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: k_type
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octokit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: virtus
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.5
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.5
|
69
|
+
description: " KExt/Github provides useful github extensions specifically for the
|
70
|
+
klueless code generator\n"
|
71
|
+
email:
|
72
|
+
- david@ideasmen.com.au
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".github/workflows/main.yml"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".rubocop.yml"
|
81
|
+
- CODE_OF_CONDUCT.md
|
82
|
+
- Gemfile
|
83
|
+
- Guardfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- STORIES.md
|
88
|
+
- USAGE.md
|
89
|
+
- bin/console
|
90
|
+
- bin/k
|
91
|
+
- bin/kgitsync
|
92
|
+
- bin/khotfix
|
93
|
+
- bin/setup
|
94
|
+
- docs/images/list-repositories-for-organization.png
|
95
|
+
- docs/images/list-repositories.png
|
96
|
+
- hooks/pre-commit
|
97
|
+
- hooks/update-version
|
98
|
+
- k_ext-github.gemspec
|
99
|
+
- lib/k_ext/github.rb
|
100
|
+
- lib/k_ext/github/api.rb
|
101
|
+
- lib/k_ext/github/configuration.rb
|
102
|
+
- lib/k_ext/github/models/hook.rb
|
103
|
+
- lib/k_ext/github/models/owner.rb
|
104
|
+
- lib/k_ext/github/models/repository.rb
|
105
|
+
- lib/k_ext/github/printer.rb
|
106
|
+
- lib/k_ext/github/version.rb
|
107
|
+
homepage: http://appydave.com/gems/k-ext-github
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata:
|
111
|
+
homepage_uri: http://appydave.com/gems/k-ext-github
|
112
|
+
source_code_uri: https://github.com/klueless-io/k_ext-github
|
113
|
+
changelog_uri: https://github.com/klueless-io/k_ext-github/commits/master
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2.5'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubygems_version: 3.2.7
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: KExt/Github provides useful github extensions specifically for the klueless
|
133
|
+
code generator
|
134
|
+
test_files: []
|