eigen.vision 0.2.0 → 0.4.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ev/cli.rb +20 -5
  3. data/lib/ev.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70b4f420c4521e422db7f22428fb850549b42e350e483cbc499a86fcac2f34e6
4
- data.tar.gz: 27397d76c53c976e2a66505c25b979818545e4cdb784c0342dca95c217d14f97
3
+ metadata.gz: 0bbd7ecad839cf56973507982f9a2ac38cce26c42545bf4f93fbd9c3fa0b4380
4
+ data.tar.gz: 6eddde9cc9a965149b7175fd004dc0d1599bbface78fb920f759fd8378b9fd3e
5
5
  SHA512:
6
- metadata.gz: cc53be8ef13d02a0c9d347172e1f6d3e0f1731ecdf0ccf822fe1dfa3ca2a47e32faca060fecc341996695b3cc7ea4f279474809a1fe0e729bd32ecedf65572b5
7
- data.tar.gz: 80cc5716847262aa2585910d52ff4955313d29c7f95acd20a0d2cd3804bd865656a50a1cb7729908c6c4a292e92e02e12512c25cac0f8e112f7228b8c79f11d3
6
+ metadata.gz: 1dd57898b6ce26214c291f67888a25b43708676a81143c7aa175ab08aba9d234e9fd91104cb9e2343d516a10a18ec05853ad7e0b3bba01f10a51a224a4306b93
7
+ data.tar.gz: 9a25877fd3ba0115e27ff9a2f4accf5a1a456c46cf9744fb9031bfb9e91902d3ba4de3a5455bf0c1617bda4fca990370682cd30b52da8173750427f6029bba23
data/lib/ev/cli.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  require "net/http"
2
2
  require "json"
3
+ require "io/console"
3
4
 
4
5
  module EV
5
6
  class CLI
6
7
  attr_reader :output
7
8
 
8
- def initialize(args = [])
9
+ def initialize(args = [], input: $stdin)
9
10
  @args = args
11
+ @input = input
10
12
  @output = ""
11
13
  run if @args.any?
12
14
  end
@@ -38,16 +40,29 @@ module EV
38
40
  ) do |http|
39
41
  http.request(req)
40
42
  end
41
- JSON.parse(res.body).each do |pin|
43
+ data = JSON.parse(res.body)
44
+ if res.code != "200"
45
+ @output = "error: #{data["error"]}\n"
46
+ return
47
+ end
48
+ data.each do |pin|
42
49
  @output += "#{pin["name"]}: " \
43
50
  "#{pin["direction"]}\n"
44
51
  end
45
52
  end
46
53
 
47
54
  def login
48
- email = @args[1]
49
- password = @args[2]
50
- url = @args[3] || "http://localhost:8080"
55
+ url = @args[1] || "http://localhost:8080"
56
+ $stderr.print "Email: "
57
+ email = @input.gets.chomp
58
+ $stderr.print "Password: "
59
+ begin
60
+ password =
61
+ @input.noecho(&:gets).chomp
62
+ $stderr.puts
63
+ rescue NoMethodError, Errno::ENOTTY
64
+ password = @input.gets.chomp
65
+ end
51
66
  uri = URI("#{url}/login")
52
67
  req = Net::HTTP::Post.new(uri)
53
68
  req["Accept"] = "application/json"
data/lib/ev.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module EV
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eigen.vision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - eigen.vision