skp 0.0.1

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.
@@ -0,0 +1,57 @@
1
+ require "excon"
2
+ require "json"
3
+
4
+ module SKP
5
+ class Gateway
6
+ attr_accessor :domain
7
+
8
+ def initialize(domain, key)
9
+ @domain = domain
10
+ @key = key
11
+ end
12
+
13
+ class Error < StandardError; end
14
+
15
+ def authenticate_key(key)
16
+ Excon.get(domain + "/license", user: key).status == 200
17
+ end
18
+
19
+ def list_content
20
+ response = Excon.get(domain + "/contents?product=sip", user: @key)
21
+ if response.status == 200
22
+ JSON.parse(response.body)
23
+ else
24
+ puts response.inspect
25
+ raise Error, "There was a problem fetching this content."
26
+ end
27
+ end
28
+
29
+ def download_content(content, folder:)
30
+ ::CLI::UI::Progress.progress do |bar|
31
+ downloaded_file = File.open("#{folder}/#{content["s3_key"]}.partial", "w")
32
+ streamer = lambda do |chunk, remaining_bytes, total_bytes|
33
+ downloaded_file.write(chunk)
34
+ bar.tick(set_percent: 1 - (remaining_bytes.to_f / total_bytes).round(2))
35
+ end
36
+ response = Excon.get(content["url"], response_block: streamer)
37
+ unless response.status == 200
38
+ puts response.inspect
39
+ raise Error.new("Server problem: #{response.status}")
40
+ end
41
+ downloaded_file.close
42
+ File.rename(downloaded_file, "#{folder}/#{content["s3_key"]}")
43
+ bar.tick(set_percent: 1)
44
+ end
45
+ end
46
+
47
+ def latest_version?
48
+ resp = Excon.get("https://rubygems.org/api/v1/gems/skp.json")
49
+ data = JSON.parse resp.body
50
+ Gem::Version.new(SKP::VERSION) >= Gem::Version.new(data["version"])
51
+ end
52
+
53
+ def register_email(email)
54
+ Excon.put(domain + "/license?email=#{email}&key=#{@key}").status == 200
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module SKP
2
+ VERSION = "0.0.1"
3
+ end
data/lib/skp.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "skp/version"
2
+ require "skp/client"
3
+ require "skp/client_data"
4
+ require "skp/gateway"
5
+
6
+ module SKP
7
+ class Error < StandardError; end
8
+ end
data/skp.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ require_relative "lib/skp/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "skp"
5
+ spec.version = SKP::VERSION
6
+ spec.authors = ["Nate Berkopec"]
7
+ spec.email = ["nate@speedshop.co"]
8
+
9
+ spec.summary = "A CLI for Sidekiq in Practice."
10
+ spec.homepage = "https://speedshop.co"
11
+ spec.license = "GPL-3.0-or-later"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://www.github.com/speedshop/skp"
16
+ spec.metadata["changelog_uri"] = "https://www.github.com/speedshop/skp/HISTORY.md"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency "thor"
28
+ spec.add_dependency "thor-hollaback"
29
+ spec.add_dependency "excon"
30
+ spec.add_dependency "cli-ui"
31
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nate Berkopec
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 1980-01-01 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
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor-hollaback
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: excon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cli-ui
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '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'
69
+ description:
70
+ email:
71
+ - nate@speedshop.co
72
+ executables:
73
+ - skp
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".github/workflows/test.yml"
78
+ - ".gitignore"
79
+ - ".ruby_version"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - HISTORY.md
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - exe/skp
88
+ - lib/skp.rb
89
+ - lib/skp/README.md
90
+ - lib/skp/cli.rb
91
+ - lib/skp/cli/bannerlord.rb
92
+ - lib/skp/cli/key.rb
93
+ - lib/skp/cli/quiz.rb
94
+ - lib/skp/cli/sub_command_base.rb
95
+ - lib/skp/client.rb
96
+ - lib/skp/client_data.rb
97
+ - lib/skp/gateway.rb
98
+ - lib/skp/version.rb
99
+ - skp.gemspec
100
+ homepage: https://speedshop.co
101
+ licenses:
102
+ - GPL-3.0-or-later
103
+ metadata:
104
+ homepage_uri: https://speedshop.co
105
+ source_code_uri: https://www.github.com/speedshop/skp
106
+ changelog_uri: https://www.github.com/speedshop/skp/HISTORY.md
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 2.6.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.2.26
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: A CLI for Sidekiq in Practice.
126
+ test_files: []