divide lib files

diff --git a/.ruby-version b/.ruby-version
index c82eec7..c031dda 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-1.9.3-p448
+2.0.0-p0
diff --git a/Gemfile b/Gemfile
index 85b96f0..1264e98 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,8 +3,8 @@
 # Specify your gem's dependencies in kptchan.gemspec
 gemspec

-# gem 'zircon', git: "git@github.com:hdemon/zircon.git"
-gem 'zircon'
-gem 'okura'
+gem 'zircon', git: "git@github.com:hdemon/zircon.git"
+# gem 'zircon'
+# gem 'okura'
 # gem 'mecab', path: "./"
 # gem 'mecab', ">= 0.99", require: "./"
diff --git a/lib/kptchan.rb b/lib/kptchan.rb
index 5e7a69b..6c2b9e6 100644
--- a/lib/kptchan.rb
+++ b/lib/kptchan.rb
@@ -1,11 +1,11 @@
-# coding: utf-8
-
 require "active_support/all"
 require "zircon"
-require "yaml"
-require "mongoid"
-require "pp"
-require "pry"
+
+
+require "./lib/kptchan/kptchan_controller"
+require "./lib/kptchan/behavior"
+require "./lib/kptchan/interpreter"
+require "./lib/kptchan/task"

 REQUEST_DICTIONARIES = [
@@ -32,165 +32,5 @@ until session[:tasks].present?
 end

-class Task
-  include Mongoid::Document
-
-  field :inc_id, type: Integer
-  field :nickname
-  field :category, type: Symbol
-  field :content
-  field :created_at, type: Time
-  field :done, type: Boolean
-  field :available, type: Boolean
-end
-
-
-class Interpreter
-  def interpret(parsed_sentence, speaker_nickname)
-    @sentence = parsed_sentence
-
-    {
-      speaker_nickname: speaker_nickname,
-      request: request,
-      category: category,
-      content: content,
-      specified_inc_id: specified_inc_id
-    }
-  end
-
-  private
-
-  def category
-    retrieve_word(CATEGORY_DICTIONARIES, @sentence)
-  end
-
-  def request
-    retrieve_word(REQUEST_DICTIONARIES, @sentence)
-  end
-
-  def retrieve_word(dictionary, sentence)
-    dic = dictionary.find do |element|
-      element[1].any? do |request_word|
-        sentence =~ /#{request_word}/
-      end
-    end
-
-    return if dic.nil?
-    dic[0]
-  end
-
-  def content
-    @sentence =~ /(?<=\").{1,}(?=\")/
-    $&
-  end
-
-  def specified_inc_id
-    @sentence =~ /(?<=id\:)\d{1,}/
-    $&.to_i
-  end
-end
-
-
-class KPTChanController
-  def initialize
-    @config = YAML.load_file "config/config.yaml"
-    @interpreter = Interpreter.new
-
-    @client = Zircon.new(
-      :server   => @config["server"],
-      :port     => @config["port"],
-      :password => @config["password"],
-      :channel  => @config["channel"],
-      :username => @config["username"],
-      :ssl      => @config["ssl"]
-    )
-
-    @client.on_privmsg do |message|
-      interpreted_msg = @interpreter.interpret message.body, self.parseSpeaker(message.prefix)
-      react_to interpreted_msg
-    end
-  end
-
-  def run
-    @client.run!
-  end
-
-  def parseSpeaker(message_prefix)
-    message_prefix.split('!')[0]
-  end
-
-  private
-
-  def react_to(interpreted_message)
-    msg = interpreted_message
-    p msg
-    # TODO: 条件はこれでいいのか？
-    return until msg[:request] && msg[:category]
-
-    options = {
-      category: msg[:category],
-      content: msg[:content],
-      specified_inc_id: msg[:specified_inc_id]
-    }
-
-    Behavior.send msg[:request].to_sym,
-                  @client, msg[:speaker_nickname], options
-  end
-end
-
-
-module Behavior
-  def self.add(client, speaker_nickname, options)
-    return until options[:content].present?
-
-    category = options[:category].presence || ''
-    # content = options[:content].presence || ''
-    inc_id = get_max_inc_id(category) + 1
-
-    task = Task.new(
-      inc_id: inc_id,
-      nickname: speaker_nickname,
-      category: category,
-      content: content,
-      created_at: Time.now,
-      done: false,
-      available: true
-    )
-
-    task.save
-  end
-
-  def self.done(client, speaker_nickname, options)
-    Task.where(inc_id: options[:specified_inc_id]).update(done: true)
-    client.notice "#{client.channel}", "#{options[:specified_inc_id]}を完了しました。"
-  end
-
-  def self.remove(client, speaker_nickname, options)
-    Task.where(inc_id: options[:specified_inc_id]).update(available: false)
-    client.notice "#{client.channel}", "#{options[:specified_inc_id]}を削除しました。"
-  end
-
-  def self.list(client, speaker_nickname, options)
-    list = Task.where(category: options[:category], done: false, available: true)
-
-    if list.length == 0
-      client.notice "#{client.channel}", "登録がありません。"
-      return
-    end
-
-    client.notice "#{client.channel}", "#{options[:category]}"
-    list.each do |elem|
-      # TODO: spaceや:が途中に入ると上手く出力できない。必要であればzirconのコードを修正。
-      client.notice "#{client.channel}", "#{elem.inc_id}.#{elem.content}(#{elem.created_at.strftime('%Y-%m-%d_%H:%M')})"
-    end
-  end
-
-  def self.get_max_inc_id(category)
-    result = Task.where(category: category).order_by(inc_id: :desc).limit(1)[0]
-    result.present? ? result.inc_id.to_i : 0
-  end
-end
-
-
 kpt = KPTChanController.new
 kpt.run
diff --git a/lib/kptchan/behavior.rb b/lib/kptchan/behavior.rb
new file mode 100644
index 0000000..985fe74
--- /dev/null
+++ b/lib/kptchan/behavior.rb
@@ -0,0 +1,53 @@
+require "active_support/all"
+
+
+module Behavior
+  def self.add(client, speaker_nickname, options)
+    return until options[:content].present
+    category = options[:category].presence || ''
+    # content = options[:content].presence || ''
+    inc_id = get_max_inc_id(category) + 1
+
+    task = Task.new(
+      inc_id: inc_id,
+      nickname: speaker_nickname,
+      category: category,
+      content: content,
+      created_at: Time.now,
+      done: false,
+      available: true
+    )
+
+    task.save
+  end
+
+  def self.done(client, speaker_nickname, options)
+    Task.where(inc_id: options[:specified_inc_id]).update(done: true)
+    client.notice "#{client.channel}", "#{options[:specified_inc_id]}を完了しました。"
+  end
+
+  def self.remove(client, speaker_nickname, options)
+    Task.where(inc_id: options[:specified_inc_id]).update(available: false)
+    client.notice "#{client.channel}", "#{options[:specified_inc_id]}を削除しました。"
+  end
+
+  def self.list(client, speaker_nickname, options)
+    list = Task.where(category: options[:category], done: false, available: true)
+
+    if list.length == 0
+      client.notice "#{client.channel}", "登録がありません。"
+      return
+    end
+
+    client.notice "#{client.channel}", "#{options[:category]}"
+    list.each do |elem|
+      # TODO: spaceや:が途中に入ると上手く出力できない。必要であればzirconのコードを修正。
+      client.notice "#{client.channel}", "#{elem.inc_id}.#{elem.content}(#{elem.created_at.strftime('%Y-%m-%d_%H:%M')})"
+    end
+  end
+
+  def self.get_max_inc_id(category)
+    result = Task.where(category: category).order_by(inc_id: :desc).limit(1)[0]
+    result.present? ? result.inc_id.to_i : 0
+  end
+end
diff --git a/lib/kptchan/config.rb b/lib/kptchan/config.rb
deleted file mode 100644
index acc92d3..0000000
--- a/lib/kptchan/config.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module Config
-  SERVER = 'irc.aiming-inc.biz'
-  PORT = 6697
-  NICK = 'kpt-chan'
-  USER = 'kpt-chan'
-  REAL = 'kpt-chan'
-end
\ No newline at end of file
diff --git a/lib/kptchan/interpreter.rb b/lib/kptchan/interpreter.rb
new file mode 100644
index 0000000..c543f04
--- /dev/null
+++ b/lib/kptchan/interpreter.rb
@@ -0,0 +1,47 @@
+require "active_support/all"
+
+
+class Interpreter
+  def interpret(parsed_sentence, speaker_nickname)
+    @sentence = parsed_sentence
+
+    {
+      speaker_nickname: speaker_nickname,
+      request: request,
+      category: category,
+      content: content,
+      specified_inc_id: specified_inc_id
+    }
+  end
+
+  private
+
+  def category
+    retrieve_word(CATEGORY_DICTIONARIES, @sentence)
+  end
+
+  def request
+    retrieve_word(REQUEST_DICTIONARIES, @sentence)
+  end
+
+  def retrieve_word(dictionary, sentence)
+    dic = dictionary.find do |element|
+      element[1].any? do |request_word|
+        sentence =~ /#{request_word}/
+      end
+    end
+
+    return if dic.nil?
+    dic[0]
+  end
+
+  def content
+    @sentence =~ /(?<=\").{1,}(?=\")/
+    $&
+  end
+
+  def specified_inc_id
+    @sentence =~ /(?<=id\:)\d{1,}/
+    $&.to_i
+  end
+end
diff --git a/lib/kptchan/kptchan_controller.rb b/lib/kptchan/kptchan_controller.rb
new file mode 100644
index 0000000..0ab8cf5
--- /dev/null
+++ b/lib/kptchan/kptchan_controller.rb
@@ -0,0 +1,49 @@
+require "active_support/all"
+require "yaml"
+
+
+class KPTChanController
+  def initialize
+    @config = YAML.load_file "config/config.yaml"
+    @interpreter = Interpreter.new
+
+    @client = Zircon.new(
+      :server   => @config["server"],
+      :port     => @config["port"],
+      :password => @config["password"],
+      :channel  => @config["channel"],
+      :username => @config["username"],
+      :ssl      => @config["ssl"]
+    )
+
+    @client.on_privmsg do |message|
+      interpreted_msg = @interpreter.interpret message.body, self.parseSpeaker(message.prefix)
+      react_to interpreted_msg
+    end
+  end
+
+  def run
+    @client.run!
+  end
+
+  def parseSpeaker(message_prefix)
+    message_prefix.split('!')[0]
+  end
+
+  private
+
+  def react_to(interpreted_message)
+    msg = interpreted_message
+    # TODO: 条件はこれでいいのか？
+    return until msg[:request] && msg[:category]
+
+    options = {
+      category: msg[:category],
+      content: msg[:content],
+      specified_inc_id: msg[:specified_inc_id]
+    }
+
+    Behavior.send msg[:request].to_sym,
+                  @client, msg[:speaker_nickname], options
+  end
+end
diff --git a/lib/kptchan/task.rb b/lib/kptchan/task.rb
new file mode 100644
index 0000000..752ca4f
--- /dev/null
+++ b/lib/kptchan/task.rb
@@ -0,0 +1,15 @@
+require "active_support/all"
+require "mongoid"
+
+
+class Task
+  include Mongoid::Document
+
+  field :inc_id, type: Integer
+  field :nickname
+  field :category, type: Symbol
+  field :content
+  field :created_at, type: Time
+  field :done, type: Boolean
+  field :available, type: Boolean
+end
adapt to ruby 2.0.0
modified
fix encoding error
add words to dictionary