Module: Misoni

Defined in:
lib/misoni.rb,
lib/misoni/cli.rb,
lib/misoni/version.rb

Defined Under Namespace

Classes: CLI, Error

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.authObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/misoni.rb', line 24

def self.auth
  agent = Mechanize.new { |agent|
    agent.user_agent_alias = 'Mac Safari'
    }
  
  begin
    agent.get('http://auth.zokei.ac.jp:16978/') do |page|
       = page.form_with(:action => '/cgi-bin/adeflogin.cgi') do |form|
        config = getConfig
        form.field_with(:name => 'name').value = config["id"]
        form.field_with(:name => 'pass').value = config["password"]
      end.submit
      isSuccess()
    end
  rescue SocketError => e
    puts e.message
  end
end

.getConfigObject



11
12
13
# File 'lib/misoni.rb', line 11

def self.getConfig
  Pit.get("http://auth.zokei.ac.jp:16978", :require => { "id"=> "YOUR_UserID", "password"=> "YOUR_PASSWORD" })
end

.isSuccess(page) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/misoni.rb', line 15

def self.isSuccess(page)
  body = Nokogiri::HTML(page.body)
  body.css('table tr:nth-child(2) td').each do |child|
    unless child.text.include?("成功")
      raise Misoni::Error.new("authentication failed")
    end
  end
end