sudokku_cli 0.1.0 → 0.1.3
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 +24 -1
- data/README.md +3 -5
- data/bin/sudokku +1 -1
- data/lib/sudokku_cli/version.rb +1 -1
- data/lib/sudokku_cli.rb +11 -6
- 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: cf4d1e878e25e462944a13634c80a917a85c54c6f201a46647068cb3e6ec02a8
|
4
|
+
data.tar.gz: bd19ae69b90e05a588083c96070659abbe01fbf902c4644af09c40db8946c056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6f9e63b64f139e65e9da03818119a37bd14255f13b6c24a10323df990cafa020d52e12c90e50c410a936ebb234f0c13c918b1467de6c6a3414dfc974a6b09eb
|
7
|
+
data.tar.gz: fadccd47ce0edd1ce31f2922bd109ac631254f5f6bc664be45d4859fa6da7a0d1621e8c06988e89753dd71c17cc52d7687d552625b1daa9beef58772b39a9cd1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sudokku_cli (0.1.
|
4
|
+
sudokku_cli (0.1.2)
|
5
|
+
json
|
6
|
+
net-http
|
7
|
+
netrc
|
8
|
+
open-uri
|
5
9
|
|
6
10
|
GEM
|
7
11
|
remote: https://rubygems.org/
|
8
12
|
specs:
|
13
|
+
date (3.3.3)
|
14
|
+
dotenv (2.8.1)
|
15
|
+
json (2.6.1)
|
9
16
|
minitest (5.17.0)
|
17
|
+
net-http (0.2.0)
|
18
|
+
net-protocol
|
19
|
+
uri
|
20
|
+
net-protocol (0.2.1)
|
21
|
+
timeout
|
22
|
+
netrc (0.11.0)
|
23
|
+
open-uri (0.2.0)
|
24
|
+
stringio
|
25
|
+
time
|
26
|
+
uri
|
10
27
|
rake (13.0.6)
|
28
|
+
stringio (3.0.1)
|
29
|
+
time (0.2.0)
|
30
|
+
date
|
31
|
+
timeout (0.3.2)
|
32
|
+
uri (0.11.0)
|
11
33
|
|
12
34
|
PLATFORMS
|
13
35
|
x86_64-linux
|
14
36
|
|
15
37
|
DEPENDENCIES
|
38
|
+
dotenv
|
16
39
|
minitest (~> 5.0)
|
17
40
|
rake (~> 13.0)
|
18
41
|
sudokku_cli!
|
data/README.md
CHANGED
@@ -4,15 +4,13 @@ A CLI program for logging in to Sudokku git server.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
7
|
+
$ gem install sudokku_cli
|
10
8
|
|
11
9
|
## Usage
|
12
10
|
|
13
11
|
Use `sudokku login` to log in to the Sudokku git server. This will try to connect to the git server using credentials saved
|
14
|
-
in
|
15
|
-
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.
|
16
14
|
|
17
15
|
[//]: # (## Development)
|
18
16
|
|
data/bin/sudokku
CHANGED
data/lib/sudokku_cli/version.rb
CHANGED
data/lib/sudokku_cli.rb
CHANGED
@@ -4,39 +4,44 @@ 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
46
|
puts 'Successfully logged in!'
|
42
47
|
break
|
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.3
|
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
|