akashiyaki 0.2.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 652a4b0a3b87f208ed5b4e3bf586aafdb943421f
4
- data.tar.gz: 5c4ee1c02c2a749ca78bdf9b04e76b841d8e64b0
3
+ metadata.gz: 5d314ed9673aa72e3f934adb80e31c7e9e2aa007
4
+ data.tar.gz: db38ef8a77e95e410cc6206241f3ffb10fdf066b
5
5
  SHA512:
6
- metadata.gz: b415ece85b90835994b649f888bac5378c22e81ed3041971a43616afbcf599f2f1ae71ee692890c55a09d71c4db73c8f790a802765ffa8f56ae91609ed47f9df
7
- data.tar.gz: cecd482c7b2f9f1ce8f3ad25cdb48ad5592fcb2e85b21d1010d3599debb88b6eb752da82c503fc80373e8410e46d68ea52e31f6f6acea6dd668828608e2ea3f6
6
+ metadata.gz: ab5fff35b7a406a5d01bda8e831146bc6725ef9810e7d928103208df6d261e7053d73ee2da07ede9888c6d00dcda5d0e92bd5503640ca221d11369f2ef9a75f4
7
+ data.tar.gz: a102e8391e54c51070a73f3cee8f72b5765fe493aae699c09380f73f3ea45c6f100aaaece9356746c17f426c5d3e2820f3ae9174429230f6856af940969a30e5
@@ -43,7 +43,9 @@ module Akashiyaki
43
43
  return config[:password] if config[:password]
44
44
 
45
45
  print "Password: "
46
- STDIN.noecho(&:gets).chomp
46
+ password = STDIN.noecho(&:gets).chomp
47
+ puts
48
+ password
47
49
  end
48
50
 
49
51
  def search_config
@@ -1,7 +1,10 @@
1
+ # coding: utf-8
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require "mechanize"
4
5
 
6
+ require "akashiyaki/errors"
7
+
5
8
  module Akashiyaki
6
9
  class Client
7
10
  DEFAULT_REQUEST_HEADERS = {
@@ -16,6 +19,7 @@ module Akashiyaki
16
19
  password: "form[password]",
17
20
  }.freeze
18
21
 
22
+ DAKOKU_PAGE_TITLE_RE = /打刻/
19
23
  DAKOKU_FORM_ID = "new_form"
20
24
  DAKOKU_FORM_FIELDS = {
21
25
  authenticity_token: "authenticity_token",
@@ -45,7 +49,9 @@ module Akashiyaki
45
49
  @account.each do |field, value|
46
50
  login_form[LOGIN_FORM_FIELDS[field]] = value
47
51
  end
48
- login_form.submit
52
+ res = login_form.submit
53
+ raise NotAuthorized, "failed to log in" unless res.title =~ DAKOKU_PAGE_TITLE_RE
54
+ res
49
55
  end
50
56
 
51
57
  def start_work
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "akashiyaki/client"
4
+ require "akashiyaki/errors"
4
5
 
5
6
  module Akashiyaki
6
7
  class Command
@@ -14,6 +15,9 @@ module Akashiyaki
14
15
 
15
16
  def run
16
17
  client.send(:"#{action}_#{mode}")
18
+ puts "Succeeded!"
19
+ rescue NotAuthorized => e
20
+ puts "Failed! #{e.message}"
17
21
  end
18
22
 
19
23
  private
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Akashiyaki
4
+ NotAuthorized = Class.new(StandardError)
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Akashiyaki
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akashiyaki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nownabe
@@ -104,6 +104,7 @@ files:
104
104
  - lib/akashiyaki/cli.rb
105
105
  - lib/akashiyaki/client.rb
106
106
  - lib/akashiyaki/command.rb
107
+ - lib/akashiyaki/errors.rb
107
108
  - lib/akashiyaki/version.rb
108
109
  homepage: https://github.com/nownabe/akashiyaki
109
110
  licenses: