k_ext-github 0.0.2 → 0.0.8

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
  SHA256:
3
- metadata.gz: 7d5b45fe84e6b83feec59c4f83c163c5caf362cba680d4e206e6610830997cfc
4
- data.tar.gz: 6055446e7bf8334c3284a7e8c807c6803ed450216711f372525ba5efacfa5f4a
3
+ metadata.gz: 307c9926733fcb3b6b43a5a5f613e4e66bd22cd8a421f264cc91f494f96face2
4
+ data.tar.gz: f99987025255cad0f76e62a679e95873c80d3dd362303634243d49b687820d84
5
5
  SHA512:
6
- metadata.gz: 48e9ac5682bb7f21be6a13c0edf934e6e397d85bda9611ac25d685d36099612432a94631ba3537c0b8d70c67b01644e3b2c4ee1a72c7520bbe5a41ff8abf3fb6
7
- data.tar.gz: 18eaeab365570929f264d4686e9a05da3b235ebaefc513ae19d907889a88ae33995bc6b61a1bf73af0e87563890c0a06e7e5bdbe328adc08138c6aaa566fa5eb
6
+ metadata.gz: ea1bf4c3d1d1fdb48e776571dafd5fd433d49afa02005d45c2635c1137b5fb6afe5a4a74944f1b90eac79f80fb4c7941750eb9222c6d47b01b29583bccfa2386
7
+ data.tar.gz: 5a1f0041d5b1a0eece0811d55746f8efc3f1ffa31ece8206de2bfe82b72e3df1e2bf5cf9842b46c0dfbe1936f9a4f5b0d22ddff67c4690c937d84c38ed9b3e95
@@ -1,5 +1,4 @@
1
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
2
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
1
+ # check https://www.githubstatus.com/ if any issues
3
2
  name: Ruby
4
3
 
5
4
  on:
@@ -9,22 +8,19 @@ on:
9
8
  branches: [ master ]
10
9
 
11
10
  jobs:
12
- test:
13
-
11
+ build:
14
12
  runs-on: ubuntu-latest
15
-
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby: ['2.7.1']
16
17
  steps:
17
18
  - uses: actions/checkout@v2
18
19
  - name: Set up Ruby
19
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
20
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
21
20
  uses: ruby/setup-ruby@v1
22
21
  with:
23
22
  ruby-version: 2.7.1
24
- - name: Install dependencies
25
- run: |
26
- gem install bundler -v 2.2.5
27
- bundle install
23
+ bundler-cache: true
28
24
  - name: Run tests
29
25
  run: bundle exec rspec
30
26
  - name: Run rubocop
data/Guardfile CHANGED
@@ -1,31 +1,31 @@
1
- # frozen_string_literal: true
2
-
3
- guard :bundler, cmd: 'bundle install' do
4
- watch('Gemfile')
5
- watch('k_ext_github.gemspec')
6
- end
7
-
8
- group :green_pass_then_cop, halt_on_fail: true do
9
- guard :rspec, cmd: 'bundle exec rspec -f doc' do
10
- require 'guard/rspec/dsl'
11
- dsl = Guard::RSpec::Dsl.new(self)
12
-
13
- # RSpec files
14
- rspec = dsl.rspec
15
- watch(rspec.spec_helper) { rspec.spec_dir }
16
- watch(rspec.spec_support) { rspec.spec_dir }
17
- watch(rspec.spec_files)
18
-
19
- # Ruby files
20
- ruby = dsl.ruby
21
- dsl.watch_spec_files_for(ruby.lib_files)
22
- watch(%r{^lib/k_ext/github/(.+)\.rb$}) { |m| "spec/k_ext/#{m[1]}_spec.rb" }
23
- watch(%r{^lib/k_ext/github/models/(.+)\.rb$}) { |m| "spec/k_ext/models/#{m[1]}_spec.rb" }
24
- watch(%r{^lib/k_ext/github/commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" }
25
- end
26
-
27
- guard :rubocop, all_on_start: false, cli: ['--format', 'clang'] do
28
- watch(/{.+\.rb$/)
29
- watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
30
- end
31
- end
1
+ # frozen_string_literal: true
2
+
3
+ guard :bundler, cmd: 'bundle install' do
4
+ watch('Gemfile')
5
+ watch('k_ext_github.gemspec')
6
+ end
7
+
8
+ group :green_pass_then_cop, halt_on_fail: true do
9
+ guard :rspec, cmd: 'bundle exec rspec -f doc' do
10
+ require 'guard/rspec/dsl'
11
+ dsl = Guard::RSpec::Dsl.new(self)
12
+
13
+ # RSpec files
14
+ rspec = dsl.rspec
15
+ watch(rspec.spec_helper) { rspec.spec_dir }
16
+ watch(rspec.spec_support) { rspec.spec_dir }
17
+ watch(rspec.spec_files)
18
+
19
+ # Ruby files
20
+ ruby = dsl.ruby
21
+ dsl.watch_spec_files_for(ruby.lib_files)
22
+ watch(%r{^lib/k_ext/github/(.+)\.rb$}) { |m| "spec/k_ext/#{m[1]}_spec.rb" }
23
+ watch(%r{^lib/k_ext/github/models/(.+)\.rb$}) { |m| "spec/k_ext/models/#{m[1]}_spec.rb" }
24
+ watch(%r{^lib/k_ext/github/commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" }
25
+ end
26
+
27
+ guard :rubocop, all_on_start: false, cli: ['--format', 'clang'] do
28
+ watch(/{.+\.rb$/)
29
+ watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
30
+ end
31
+ end
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ desc 'Compile all the extensions'
16
16
  task build: :compile
17
17
 
18
18
  Rake::ExtensionTask.new('k_ext_github') do |ext|
19
- ext.lib_dir = 'lib/k_ext_github'
19
+ ext.lib_dir = 'lib/k_ext/github'
20
20
  end
21
21
 
22
22
  desc 'Publish the gem to RubyGems.org'
data/hooks/update-version CHANGED
@@ -30,4 +30,4 @@ end
30
30
  output.push('')
31
31
 
32
32
  printf "%-25<label>s : %<version>s\n", label: 'GEM VERSION', version: version
33
- File.open('lib/k_ext/github/version.rb', 'w+') { |f| f.write(output.join("\n")) }
33
+ File.write('lib/k_ext/github/version.rb', output.join("\n"))
data/k_ext-github.gemspec CHANGED
@@ -1,47 +1,49 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/k_ext/github/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.required_ruby_version = '>= 2.5'
7
- spec.name = 'k_ext-github'
8
- spec.version = KExt::Github::VERSION
9
- spec.authors = ['David Cruwys']
10
- spec.email = ['david@ideasmen.com.au']
11
-
12
- spec.summary = 'KExt/Github provides useful github extensions specifically for the klueless code generator'
13
- spec.description = <<-TEXT
14
- KExt/Github provides useful github extensions specifically for the klueless code generator
15
- TEXT
16
- spec.homepage = 'http://appydave.com/gems/k-ext-github'
17
- spec.license = 'MIT'
18
-
19
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
- # to allow pushing to a single host or delete this section to allow pushing to any host.
21
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
22
-
23
- # spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
24
-
25
- spec.metadata['homepage_uri'] = spec.homepage
26
- spec.metadata['source_code_uri'] = 'https://github.com/klueless-io/k_ext-github'
27
- spec.metadata['changelog_uri'] = 'https://github.com/klueless-io/k_ext-github/commits/master'
28
-
29
- # Specify which files should be added to the gem when it is released.
30
- # The `git ls-files -z` loads the RubyGem files that have been added into git.
31
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
- `git ls-files -z`.split("\x0").reject do |f|
33
- f.match(%r{^(test|spec|features)/})
34
- end
35
- end
36
- spec.bindir = 'exe'
37
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
- spec.require_paths = ['lib']
39
- # spec.extensions = ['ext/k_ext_github/extconf.rb']
40
-
41
- spec.add_dependency 'k_log', '~> 0.0.0'
42
- spec.add_dependency 'k_type', '~> 0.0.0'
43
- # spec.add_dependency 'k_util' , '~> 0.0.0'
44
- spec.add_dependency 'octokit', '~> 4.0'
45
-
46
- spec.add_dependency 'virtus', '~> 1.0.5'
47
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/k_ext/github/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.required_ruby_version = '>= 2.5'
7
+ spec.name = 'k_ext-github'
8
+ spec.version = KExt::Github::VERSION
9
+ spec.authors = ['David Cruwys']
10
+ spec.email = ['david@ideasmen.com.au']
11
+
12
+ spec.summary = 'KExt/Github provides useful github extensions specifically for the klueless code generator'
13
+ spec.description = <<-TEXT
14
+ KExt/Github provides useful github extensions specifically for the klueless code generator
15
+ TEXT
16
+ spec.homepage = 'http://appydave.com/gems/k-ext-github'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
22
+
23
+ # spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
24
+
25
+ spec.metadata['homepage_uri'] = spec.homepage
26
+ spec.metadata['source_code_uri'] = 'https://github.com/klueless-io/k_ext-github'
27
+ spec.metadata['changelog_uri'] = 'https://github.com/klueless-io/k_ext-github/commits/master'
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the RubyGem files that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
+ `git ls-files -z`.split("\x0").reject do |f|
33
+ f.match(%r{^(test|spec|features)/})
34
+ end
35
+ end
36
+ spec.bindir = 'exe'
37
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ['lib']
39
+ # spec.extensions = ['ext/k_ext_github/extconf.rb']
40
+
41
+ spec.add_dependency 'k_config', '~> 0.0.0'
42
+ spec.add_dependency 'k_log', '~> 0.0.0'
43
+ spec.add_dependency 'k_type', '~> 0.0.0'
44
+ spec.add_dependency 'k_util', '~> 0.0.0'
45
+ spec.add_dependency 'octokit', '~> 4.0'
46
+
47
+ spec.add_dependency 'virtus', '~> 1.0.5'
48
+ spec.metadata['rubygems_mfa_required'] = 'true'
49
+ end
@@ -1,124 +1,144 @@
1
- # frozen_string_literal: true
2
-
3
- module KExt
4
- module Github
5
- # Print formatted log for GitHub data such as repositories
6
- require 'octokit'
7
-
8
- # The API provides a limited set of service methods for working against GitHub
9
- class Api
10
- include KLog::Logging
11
- include Virtus.model
12
-
13
- # attribute :client_id, String, :writer => :private
14
- # attribute :secret, String, :writer => :private
15
-
16
- # attribute :sites, Array[Netlify::Site], :writer => :private
17
- attribute :client, Octokit::Client, writer: :private
18
-
19
- def self.instance(access_token)
20
- GithubApi.new(token: access_token)
21
- end
22
-
23
- # Create API for communicating with GitHub
24
- #
25
- # Provide token OR login/password
26
- #
27
- # Create a token here
28
- # https://github.com/settings/tokens/new
29
- #
30
- # @param [String] token
31
- # @param [String] login
32
- # @param [String] password
33
- def initialize(token: nil, login: nil, password: nil)
34
- auth(token: token, login: login, password: password) if token || login || password
35
- end
36
-
37
- # Authenticate against GitHub with username and password or token
38
- #
39
- # Provide token OR login/password
40
- #
41
- # Create a token here
42
- # https://github.com/settings/tokens/new
43
- # @param [String] token
44
- # @param [String] login
45
- # @param [String] password
46
- def auth(token: nil, login: nil, password: nil)
47
- raise 'Provide credentials. Token or username/password' if token.nil? && (login.nil? || password.nil?)
48
-
49
- self.client = if token.nil?
50
- Octokit::Client.new(login: login, password: password)
51
- else
52
- Octokit::Client.new(access_token: token)
53
- end
54
-
55
- # Fetch the current user
56
- log.kv 'GitHub User', client.user.name
57
- end
58
-
59
- # --------------------------------------------------------------------------------
60
- # Service Actions
61
- # --------------------------------------------------------------------------------
62
-
63
- # list of repositories for this user
64
- #
65
- def repositories
66
- items = @client.repositories({}, query: { per_page: 100 })
67
-
68
- items.map { |item| KExt::Github::Models::Repository.new(item) }
69
- end
70
-
71
- # create repository
72
- #
73
- # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
74
- def create_repository(repository_name, **options)
75
- @client.create_repository(repository_name, options)
76
- end
77
-
78
- # delete repository
79
- #
80
- # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
81
- def delete_repository(repository_name, **options)
82
- @client.delete_repository(repository_name, **options)
83
- end
84
-
85
- # list of hooks for repository
86
- #
87
- # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
88
- def hooks(repository_name)
89
- items = @client.hooks(repository_name)
90
-
91
- items.map { |item| KExt::Github::Models::Hook.new(item) }
92
- end
93
-
94
- # list of repositories for organization
95
- #
96
- # @param [String] org_name Organization name
97
- def organization_repositories(org_name)
98
- items = @client.repositories(org_name, query: { per_page: 100 })
99
-
100
- items.map { |item| KExt::Github::Models::Repository.new(item) }
101
- end
102
- # organization_repositories(org, options = {}) => Array<Sawyer::Resource> (also: #org_repositories, #org_repos)
103
-
104
- # remove hook from repository by id
105
- #
106
- # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
107
- # @param [Integer] id hook ID
108
- def remove_hook(repository_name, id)
109
- @client.remove_hook(repository_name, id)
110
- end
111
-
112
- # remove all hooks in a repository
113
- #
114
- # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
115
- def remove_hooks(repository_name)
116
- hooks = hooks(repository_name)
117
-
118
- hooks.each do |hook|
119
- @client.remove_hook(repository_name, hook.id)
120
- end
121
- end
122
- end
123
- end
124
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KExt
4
+ module Github
5
+ # Print formatted log for GitHub data such as repositories
6
+ require 'octokit'
7
+
8
+ # The API provides a limited set of service methods for working against GitHub
9
+ class Api
10
+ include KLog::Logging
11
+ include Virtus.model
12
+
13
+ # attribute :client_id, String, :writer => :private
14
+ # attribute :secret, String, :writer => :private
15
+
16
+ # attribute :sites, Array[Netlify::Site], :writer => :private
17
+ attribute :client, Octokit::Client, writer: :private
18
+
19
+ def self.instance(access_token)
20
+ Api.new(token: access_token)
21
+ end
22
+
23
+ # Create API for communicating with GitHub
24
+ #
25
+ # Provide token OR login/password
26
+ #
27
+ # Create a token here
28
+ # https://github.com/settings/tokens/new
29
+ #
30
+ # @param [String] token
31
+ # @param [String] login
32
+ # @param [String] password
33
+ def initialize(token: nil, login: nil, password: nil)
34
+ auth(token: token, login: login, password: password) if token || login || password
35
+ end
36
+
37
+ # Authenticate against GitHub with username and password or token
38
+ #
39
+ # Provide token OR login/password
40
+ #
41
+ # Create a token here
42
+ # https://github.com/settings/tokens/new
43
+ # @param [String] token
44
+ # @param [String] login
45
+ # @param [String] password
46
+ def auth(token: nil, login: nil, password: nil)
47
+ raise 'Provide credentials. Token or username/password' if token.nil? && (login.nil? || password.nil?)
48
+
49
+ self.client = if token.nil?
50
+ Octokit::Client.new(login: login, password: password)
51
+ else
52
+ Octokit::Client.new(access_token: token)
53
+ end
54
+
55
+ # Fetch the current user
56
+ log.kv 'GitHub User', client.user.name
57
+ end
58
+
59
+ # --------------------------------------------------------------------------------
60
+ # Service Actions
61
+ # --------------------------------------------------------------------------------
62
+
63
+ # list of repositories for this user
64
+ #
65
+ def repositories(per_page: 100, page: 1)
66
+ items = @client.repositories({}, query: { per_page: per_page, page: page })
67
+
68
+ items.map { |item| KExt::Github::Models::Repository.new(item) }
69
+ end
70
+
71
+ # list of ALL repositories for this user
72
+ #
73
+ def all_repositories
74
+ # NOTE: Does not seam to work
75
+ # items = @client.all_repositories({})
76
+
77
+ items = []
78
+ page = 1
79
+ keep_going = true
80
+
81
+ while keep_going
82
+ paged_items = repositories(page: page)
83
+ items += paged_items
84
+ page += 1
85
+ keep_going = paged_items.length.positive? && page <= 50
86
+ end
87
+
88
+ items.map { |item| KExt::Github::Models::Repository.new(item) }
89
+ end
90
+
91
+ # create repository
92
+ #
93
+ # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
94
+ def create_repository(repository_name, **options)
95
+ @client.create_repository(repository_name, options)
96
+ end
97
+
98
+ # delete repository
99
+ #
100
+ # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
101
+ def delete_repository(repository_name, **options)
102
+ @client.delete_repository(repository_name, **options)
103
+ end
104
+
105
+ # list of hooks for repository
106
+ #
107
+ # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
108
+ def hooks(repository_name)
109
+ items = @client.hooks(repository_name)
110
+
111
+ items.map { |item| KExt::Github::Models::Hook.new(item) }
112
+ end
113
+
114
+ # list of repositories for organization
115
+ #
116
+ # @param [String] org_name Organization name
117
+ def organization_repositories(org_name)
118
+ items = @client.repositories(org_name, query: { per_page: 100 })
119
+
120
+ items.map { |item| KExt::Github::Models::Repository.new(item) }
121
+ end
122
+ # organization_repositories(org, options = {}) => Array<Sawyer::Resource> (also: #org_repositories, #org_repos)
123
+
124
+ # remove hook from repository by id
125
+ #
126
+ # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
127
+ # @param [Integer] id hook ID
128
+ def remove_hook(repository_name, id)
129
+ @client.remove_hook(repository_name, id)
130
+ end
131
+
132
+ # remove all hooks in a repository
133
+ #
134
+ # @param [String] repository_name e.g. klueless-io/z-test-aerial.com
135
+ def remove_hooks(repository_name)
136
+ hooks = hooks(repository_name)
137
+
138
+ hooks.each do |hook|
139
+ @client.remove_hook(repository_name, hook.id)
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -1,18 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
- module KExt
4
- module Github
5
- # Configuration class for KExt::Github
6
- class Configuration
7
- attr_accessor :user
8
- attr_accessor :personal_access_token
9
- attr_accessor :personal_access_token_delete
10
-
11
- def initialize
12
- @user = ENV['GITHUB_USER']
13
- @personal_access_token = ENV['GITHUB_PERSONAL_ACCESS_TOKEN']
14
- @personal_access_token_delete = ENV['GITHUB_PERSONAL_ACCESS_TOKEN_DELETE']
15
- end
16
- end
17
- end
18
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KExt
4
+ module Github
5
+ # Configuration class for KExt::Github
6
+ class Configuration
7
+ include KUtil::Data::InstanceVariablesToH
8
+
9
+ attr_accessor :user
10
+ attr_accessor :personal_access_token
11
+ attr_accessor :personal_access_token_delete
12
+
13
+ def initialize
14
+ @user = ENV['GH_USER'] || ENV['GITHUB_USER']
15
+ @personal_access_token = ENV['GITHUB_PERSONAL_ACCESS_TOKEN']
16
+ @personal_access_token_delete = ENV['GITHUB_PERSONAL_ACCESS_TOKEN_DELETE']
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Attach configuration to the KConfig module
4
+ module KExt
5
+ module Github
6
+ # GitHub configuration extension for attachment to KConfig::Configuration
7
+ module GitHubConfigurationExtension
8
+ def github
9
+ @github ||= GitHubConfiguration.new
10
+ end
11
+
12
+ def github_debug
13
+ github.debug
14
+ end
15
+ end
16
+
17
+ # GitHub Configuration
18
+ class GitHubConfiguration
19
+ include KUtil::Data::InstanceVariablesToH
20
+ include KLog::Logging
21
+
22
+ attr_accessor :user
23
+ attr_accessor :personal_access_token
24
+ attr_accessor :personal_access_token_delete
25
+
26
+ def initialize
27
+ @user = ENV['GH_USER'] || ENV['GITHUB_USER']
28
+ @personal_access_token = ENV['GITHUB_PERSONAL_ACCESS_TOKEN']
29
+ @personal_access_token_delete = ENV['GITHUB_PERSONAL_ACCESS_TOKEN_DELETE']
30
+ end
31
+
32
+ def debug
33
+ log.section_heading 'GitHub Configuration'
34
+ log.kv 'user', user
35
+ log.kv 'personal_access_token', '***'
36
+ log.kv 'personal_access_token_delete', '***'
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ KConfig::Configuration.register(:github, KExt::Github::GitHubConfigurationExtension)
@@ -1,30 +1,30 @@
1
- # frozen_string_literal: true
2
-
3
- module KExt
4
- module Github
5
- module Models
6
- # This model represents a GitHub hook
7
- class Hook
8
- include Virtus.model
9
-
10
- def initialize(attributes = nil)
11
- # Virtus will take your attributes and match them to the attribute definitions listed below
12
- super(attributes)
13
- end
14
-
15
- attribute :type, String
16
- attribute :id, String
17
- attribute :name, String
18
- attribute :active, String
19
- attribute :events, String
20
- attribute :config, Hash
21
- attribute :updated_at, String
22
- attribute :created_at, String
23
- attribute :url, String
24
- attribute :test_url, String
25
- attribute :ping_url, String
26
- attribute :last_response, String
27
- end
28
- end
29
- end
30
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KExt
4
+ module Github
5
+ module Models
6
+ # This model represents a GitHub hook
7
+ class Hook
8
+ include Virtus.model
9
+
10
+ def initialize(attributes = nil)
11
+ # Virtus will take your attributes and match them to the attribute definitions listed below
12
+ super(attributes)
13
+ end
14
+
15
+ attribute :type, String
16
+ attribute :id, String
17
+ attribute :name, String
18
+ attribute :active, String
19
+ attribute :events, String
20
+ attribute :config, Hash
21
+ attribute :updated_at, String
22
+ attribute :created_at, String
23
+ attribute :url, String
24
+ attribute :test_url, String
25
+ attribute :ping_url, String
26
+ attribute :last_response, String
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,19 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
- module KExt
4
- module Github
5
- module Models
6
- # This model represents a GitHub owner
7
- class Owner
8
- include Virtus.model
9
-
10
- def initialize(attributes = nil)
11
- # Virtus will take your attributes and match them to the attribute definitions listed below
12
- super(attributes)
13
- end
14
-
15
- attribute :login, String
16
- end
17
- end
18
- end
19
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KExt
4
+ module Github
5
+ module Models
6
+ # This model represents a GitHub owner
7
+ class Owner
8
+ include Virtus.model
9
+
10
+ def initialize(attributes = nil)
11
+ # Virtus will take your attributes and match them to the attribute definitions listed below
12
+ super(attributes)
13
+ end
14
+
15
+ attribute :login, String
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,30 +1,30 @@
1
- # frozen_string_literal: true
2
-
3
- module KExt
4
- module Github
5
- module Models
6
- # This model represents a GitHub Repository
7
- class Repository
8
- include Virtus.model
9
-
10
- def initialize(attributes = nil)
11
- # Virtus will take your attributes and match them to the attribute definitions listed below
12
- super(attributes)
13
- end
14
-
15
- attribute :id, String
16
- attribute :node_id, String
17
- attribute :name, String
18
- attribute :full_name, String
19
- attribute :private, String
20
- attribute :description, String
21
- attribute :url, String
22
- attribute :created_at, String
23
- attribute :updated_at, String
24
- attribute :pushed_at, String
25
- attribute :git_url, String
26
- attribute :owner, KExt::Github::Models::Owner
27
- end
28
- end
29
- end
30
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KExt
4
+ module Github
5
+ module Models
6
+ # This model represents a GitHub Repository
7
+ class Repository
8
+ include Virtus.model
9
+
10
+ def initialize(attributes = nil)
11
+ # Virtus will take your attributes and match them to the attribute definitions listed below
12
+ super(attributes)
13
+ end
14
+
15
+ attribute :id, String
16
+ attribute :node_id, String
17
+ attribute :name, String
18
+ attribute :full_name, String
19
+ attribute :private, String
20
+ attribute :description, String
21
+ attribute :url, String
22
+ attribute :created_at, String
23
+ attribute :updated_at, String
24
+ attribute :pushed_at, String
25
+ attribute :git_url, String
26
+ attribute :owner, KExt::Github::Models::Owner
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,160 +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
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
@@ -1,7 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
- module KExt
4
- module Github
5
- VERSION = '0.0.2'
6
- end
7
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KExt
4
+ module Github
5
+ VERSION = '0.0.8'
6
+ end
7
+ end
data/lib/k_ext/github.rb CHANGED
@@ -1,40 +1,43 @@
1
- # frozen_string_literal: true
2
-
3
- require 'virtus'
4
- require 'k_log'
5
-
6
- require 'k_ext/github/version'
7
- require 'k_ext/github/configuration'
8
- require 'k_ext/github/models/hook'
9
- require 'k_ext/github/models/owner'
10
- require 'k_ext/github/models/repository'
11
- require 'k_ext/github/printer'
12
- require 'k_ext/github/api'
13
-
14
- module KExt
15
- module Github
16
- # raise KExt::Github::Error, 'Sample message'
17
- class Error < StandardError; end
18
-
19
- class << self
20
- def configuration
21
- @configuration ||= KExt::Github::Configuration.new
22
- end
23
-
24
- def reset
25
- @configuration = KExt::Github::Configuration.new
26
- end
27
-
28
- def configure
29
- yield(configuration)
30
- end
31
- end
32
- end
33
- end
34
-
35
- if ENV['KLUE_DEBUG']&.to_s&.downcase == 'true'
36
- namespace = 'KExt::Github::Version'
37
- file_path = $LOADED_FEATURES.find { |f| f.include?('k_ext/github/version') }
38
- version = KExt::Github::VERSION.ljust(9)
39
- puts "#{namespace.ljust(35)} : #{version.ljust(9)} : #{file_path}"
40
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'virtus'
4
+ require 'k_config'
5
+ require 'k_log'
6
+ require 'k_util'
7
+
8
+ require 'k_ext/github/version'
9
+ require 'k_ext/github/configuration'
10
+ require 'k_ext/github/github_configuration'
11
+ require 'k_ext/github/models/hook'
12
+ require 'k_ext/github/models/owner'
13
+ require 'k_ext/github/models/repository'
14
+ require 'k_ext/github/printer'
15
+ require 'k_ext/github/api'
16
+
17
+ module KExt
18
+ module Github
19
+ # raise KExt::Github::Error, 'Sample message'
20
+ class Error < StandardError; end
21
+
22
+ class << self
23
+ def configuration
24
+ @configuration ||= KExt::Github::Configuration.new
25
+ end
26
+
27
+ def reset
28
+ @configuration = KExt::Github::Configuration.new
29
+ end
30
+
31
+ def configure
32
+ yield(configuration)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ if ENV['KLUE_DEBUG']&.to_s&.downcase == 'true'
39
+ namespace = 'KExt::Github::Version'
40
+ file_path = $LOADED_FEATURES.find { |f| f.include?('k_ext/github/version') }
41
+ version = KExt::Github::VERSION.ljust(9)
42
+ puts "#{namespace.ljust(35)} : #{version.ljust(9)} : #{file_path}"
43
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_ext-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-17 00:00:00.000000000 Z
11
+ date: 2022-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: k_config
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
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: k_log
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: 0.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: k_util
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.0
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: octokit
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +127,7 @@ files:
99
127
  - lib/k_ext/github.rb
100
128
  - lib/k_ext/github/api.rb
101
129
  - lib/k_ext/github/configuration.rb
130
+ - lib/k_ext/github/github_configuration.rb
102
131
  - lib/k_ext/github/models/hook.rb
103
132
  - lib/k_ext/github/models/owner.rb
104
133
  - lib/k_ext/github/models/repository.rb
@@ -111,6 +140,7 @@ metadata:
111
140
  homepage_uri: http://appydave.com/gems/k-ext-github
112
141
  source_code_uri: https://github.com/klueless-io/k_ext-github
113
142
  changelog_uri: https://github.com/klueless-io/k_ext-github/commits/master
143
+ rubygems_mfa_required: 'true'
114
144
  post_install_message:
115
145
  rdoc_options: []
116
146
  require_paths:
@@ -126,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
156
  - !ruby/object:Gem::Version
127
157
  version: '0'
128
158
  requirements: []
129
- rubygems_version: 3.2.7
159
+ rubygems_version: 3.2.33
130
160
  signing_key:
131
161
  specification_version: 4
132
162
  summary: KExt/Github provides useful github extensions specifically for the klueless