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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b29947682763cb4911ef793a5dbe32919f7eb59eabd8d292b215611129971a6a
4
- data.tar.gz: f0c212058f460242168e83a8d4da27a8334cd33d6441d2e2667b2f8780f9ec11
3
+ metadata.gz: cf4d1e878e25e462944a13634c80a917a85c54c6f201a46647068cb3e6ec02a8
4
+ data.tar.gz: bd19ae69b90e05a588083c96070659abbe01fbf902c4644af09c40db8946c056
5
5
  SHA512:
6
- metadata.gz: 402537721e07e851ebc172888a5cb2350d0f0b014e7665f30b7c281b4d42bddad0eed2612f3ad6d91def032c316cf0504f65c7b8fdf3f6a7e3b8429dfa4c1c42
7
- data.tar.gz: f97626604c206b0b3986b5a27a393d00e2d555dc8caf7a614f35d207f09532c4405f105af3b46286f9e7594bc3dc94873e8755b5c8266ca00a0b8406da6db474
6
+ metadata.gz: a6f9e63b64f139e65e9da03818119a37bd14255f13b6c24a10323df990cafa020d52e12c90e50c410a936ebb234f0c13c918b1467de6c6a3414dfc974a6b09eb
7
+ data.tar.gz: fadccd47ce0edd1ce31f2922bd109ac631254f5f6bc664be45d4859fa6da7a0d1621e8c06988e89753dd71c17cc52d7687d552625b1daa9beef58772b39a9cd1
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "minitest", "~> 5.0"
11
+ gem 'dotenv'
data/Gemfile.lock CHANGED
@@ -1,18 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sudokku_cli (0.1.0)
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
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
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 the .netrc file. If the credentials are not found, or are expired, you will be given a url to visit where you can log in.
15
- After successfully logging in, the program will save the newly generated credentials to the .netrc file.
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
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "sudokku_cli"
4
4
 
5
- SudokkuCli::CLI.start(ARGV)
5
+ SudokkuCli.start(ARGV)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SudokkuCli
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
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, use_ssl: true) do |http|
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', { 'token': response['token'] })
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
- netrc[ENDPOINT] = response['credentials']
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
@@ -1,4 +1,5 @@
1
1
  module SudokkuCli
2
+ ENDPOINT: String
2
3
  VERSION: String
3
4
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
5
  end
data/sudokku_cli.gemspec CHANGED
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency "netrc"
31
31
  spec.add_runtime_dependency "json"
32
32
  spec.add_runtime_dependency "open-uri"
33
+ spec.add_runtime_dependency "net-http"
33
34
  end
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.0
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-17 00:00:00.000000000 Z
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