sudokku_cli 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +10 -1
- data/README.md +2 -2
- data/lib/sudokku_cli/version.rb +1 -1
- data/lib/sudokku_cli.rb +12 -7
- data/sig/sudokku_cli.rbs +1 -0
- data/sudokku_cli.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ac8fbbc9ae4681c6bf1200cdf2caefffb53a21a5841d48d5c1bbd9613f54d47
|
4
|
+
data.tar.gz: 13c6a5e051554e36cc666d8950a63d91faf507bee23ca9d9e81b3ea9d541da66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f215c7fdfdbfc097b6f53b5c9223426517d24d12a39b9fa4480a779b18790c09487f6f2af6cd04c519172d58ecb37425d6baa1dfa481b0b6d328776f504b8a9
|
7
|
+
data.tar.gz: c2b98b71e1507e54510e027e7c4b24f7585939e225a996608fba1d4d180ac32b0ef4f406589ba08efce2340cdda001c62b8cd4715fc68a71740b38d426d815d6
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sudokku_cli (0.1.
|
4
|
+
sudokku_cli (0.1.3)
|
5
5
|
json
|
6
|
+
net-http
|
6
7
|
netrc
|
7
8
|
open-uri
|
8
9
|
|
@@ -10,8 +11,14 @@ GEM
|
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
13
|
date (3.3.3)
|
14
|
+
dotenv (2.8.1)
|
13
15
|
json (2.6.1)
|
14
16
|
minitest (5.17.0)
|
17
|
+
net-http (0.2.0)
|
18
|
+
net-protocol
|
19
|
+
uri
|
20
|
+
net-protocol (0.2.1)
|
21
|
+
timeout
|
15
22
|
netrc (0.11.0)
|
16
23
|
open-uri (0.2.0)
|
17
24
|
stringio
|
@@ -21,12 +28,14 @@ GEM
|
|
21
28
|
stringio (3.0.1)
|
22
29
|
time (0.2.0)
|
23
30
|
date
|
31
|
+
timeout (0.3.2)
|
24
32
|
uri (0.11.0)
|
25
33
|
|
26
34
|
PLATFORMS
|
27
35
|
x86_64-linux
|
28
36
|
|
29
37
|
DEPENDENCIES
|
38
|
+
dotenv
|
30
39
|
minitest (~> 5.0)
|
31
40
|
rake (~> 13.0)
|
32
41
|
sudokku_cli!
|
data/README.md
CHANGED
@@ -9,8 +9,8 @@ A CLI program for logging in to Sudokku git server.
|
|
9
9
|
## Usage
|
10
10
|
|
11
11
|
Use `sudokku login` to log in to the Sudokku git server. This will try to connect to the git server using credentials saved
|
12
|
-
in
|
13
|
-
After successfully logging in, the program will save the newly generated credentials to
|
12
|
+
in your .netrc file. If the credentials are not found, or are expired, you will be given a url to visit where you can log in.
|
13
|
+
After successfully logging in, the program will save the newly generated credentials to your .netrc file.
|
14
14
|
|
15
15
|
[//]: # (## Development)
|
16
16
|
|
data/lib/sudokku_cli/version.rb
CHANGED
data/lib/sudokku_cli.rb
CHANGED
@@ -4,41 +4,46 @@ require_relative "sudokku_cli/version"
|
|
4
4
|
require 'netrc'
|
5
5
|
require 'json'
|
6
6
|
require 'open-uri'
|
7
|
+
require 'net/http'
|
8
|
+
require 'dotenv/load'
|
7
9
|
|
8
10
|
module SudokkuCli
|
9
11
|
class Error < StandardError; end
|
10
12
|
|
11
|
-
ENDPOINT = 'https://git.sudokku.com'
|
13
|
+
ENDPOINT = ENV["ENDPOINT"] || 'https://git.sudokku.com'
|
12
14
|
|
13
|
-
def send_request(path, params = {})
|
15
|
+
def self.send_request(path, params = {})
|
14
16
|
uri = URI.join(ENDPOINT, path)
|
15
17
|
uri.query = URI.encode_www_form(params)
|
16
18
|
request = Net::HTTP::Get.new(uri.request_uri)
|
17
19
|
netrc = Netrc.read
|
18
20
|
user, password = netrc[uri.host]
|
19
21
|
request.basic_auth(user, password)
|
20
|
-
response = Net::HTTP.start(uri.host, uri.port
|
22
|
+
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
21
23
|
http.request(request)
|
22
24
|
end
|
23
25
|
JSON.parse(response.body)
|
24
26
|
end
|
25
27
|
|
26
|
-
def login
|
28
|
+
def self.login
|
27
29
|
response = send_request('/login')
|
28
30
|
if response['status'] == 'success'
|
29
31
|
puts 'You are logged in!'
|
30
32
|
else
|
33
|
+
token = response['token']
|
31
34
|
# credentials are not valid, prompt user to authenticate via browser
|
32
35
|
puts "Please visit #{response['url']} to authenticate."
|
36
|
+
puts "Waiting for authentication..."
|
33
37
|
# check for new credentials
|
34
38
|
loop do
|
35
|
-
response = send_request('/check-authentication', {
|
39
|
+
response = send_request('/check-authentication', { token: token })
|
36
40
|
if response['status'] == 'success'
|
37
41
|
# new credentials received, save to .netrc file
|
38
42
|
netrc = Netrc.read
|
39
|
-
|
43
|
+
host = ENDPOINT.gsub('https://', '').gsub('http://', '')
|
44
|
+
netrc[host] = response['credentials']
|
40
45
|
netrc.save
|
41
|
-
puts
|
46
|
+
puts "Successfully logged in as #{response['credentials'][0]}!"
|
42
47
|
break
|
43
48
|
end
|
44
49
|
sleep(5) # wait 5 seconds before checking again
|
data/sig/sudokku_cli.rbs
CHANGED
data/sudokku_cli.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sudokku_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tasos Maschalidis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04
|
11
|
+
date: 2023-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netrc
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-http
|
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'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- tas.o.s@hotmail.com
|