Class: Atig::Db::Db
Constant Summary collapse
- VERSION =
4
Instance Attribute Summary collapse
-
#dms ⇒ Object
readonly
Returns the value of attribute dms.
-
#followings ⇒ Object
readonly
Returns the value of attribute followings.
-
#lists ⇒ Object
readonly
Returns the value of attribute lists.
-
#me ⇒ Object
Returns the value of attribute me.
-
#noretweets ⇒ Object
readonly
Returns the value of attribute noretweets.
-
#statuses ⇒ Object
readonly
Returns the value of attribute statuses.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #dir(id) ⇒ Object
-
#initialize(context, opt = {}) ⇒ Db
constructor
A new instance of Db.
- #transaction(&f) ⇒ Object
Methods included from ExceptionUtil
Constructor Details
#initialize(context, opt = {}) ⇒ Db
Returns a new instance of Db.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/atig/db/db.rb', line 19 def initialize(context, opt={}) @log = context.log @me = opt[:me] @tmpdir = opt[:tmpdir] @followings = Followings.new dir('following') @statuses = Statuses.new dir('status') @dms = Statuses.new dir('dm') @lists = Lists.new dir('lists.%s') @noretweets = Array.new log :info, "initialize" end |
Instance Attribute Details
#dms ⇒ Object (readonly)
Returns the value of attribute dms.
15 16 17 |
# File 'lib/atig/db/db.rb', line 15 def dms @dms end |
#followings ⇒ Object (readonly)
Returns the value of attribute followings.
15 16 17 |
# File 'lib/atig/db/db.rb', line 15 def followings @followings end |
#lists ⇒ Object (readonly)
Returns the value of attribute lists.
15 16 17 |
# File 'lib/atig/db/db.rb', line 15 def lists @lists end |
#me ⇒ Object
Returns the value of attribute me.
16 17 18 |
# File 'lib/atig/db/db.rb', line 16 def me @me end |
#noretweets ⇒ Object (readonly)
Returns the value of attribute noretweets.
15 16 17 |
# File 'lib/atig/db/db.rb', line 15 def noretweets @noretweets end |
#statuses ⇒ Object (readonly)
Returns the value of attribute statuses.
15 16 17 |
# File 'lib/atig/db/db.rb', line 15 def statuses @statuses end |
Instance Method Details
#cleanup ⇒ Object
52 53 54 55 56 57 |
# File 'lib/atig/db/db.rb', line 52 def cleanup transaction do @statuses.cleanup @dms.cleanup end end |
#dir(id) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/atig/db/db.rb', line 33 def dir(id) dir = File. "atig/#{@me.screen_name}/", @tmpdir log :debug, "db(#{id}) = #{dir}" FileUtils.mkdir_p dir File. "#{id}.#{VERSION}.db", dir end |
#transaction(&f) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/atig/db/db.rb', line 40 def transaction(&f) @followings.transaction do|_| @statuses.transaction do|_| @dms.transaction do|_| @lists.transaction do|_| f.call self end end end end end |