Class: Atig::Db::Db
Constant Summary collapse
- Path =
::Dir.tmpdir
- 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.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/atig/db/db.rb', line 21 def initialize(context, opt={}) @log = context.log @me = opt[:me] @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.
16 17 18 |
# File 'lib/atig/db/db.rb', line 16 def dms @dms end |
#followings ⇒ Object (readonly)
Returns the value of attribute followings.
16 17 18 |
# File 'lib/atig/db/db.rb', line 16 def followings @followings end |
#lists ⇒ Object (readonly)
Returns the value of attribute lists.
16 17 18 |
# File 'lib/atig/db/db.rb', line 16 def lists @lists end |
#me ⇒ Object
Returns the value of attribute me.
17 18 19 |
# File 'lib/atig/db/db.rb', line 17 def me @me end |
#noretweets ⇒ Object (readonly)
Returns the value of attribute noretweets.
16 17 18 |
# File 'lib/atig/db/db.rb', line 16 def noretweets @noretweets end |
#statuses ⇒ Object (readonly)
Returns the value of attribute statuses.
16 17 18 |
# File 'lib/atig/db/db.rb', line 16 def statuses @statuses end |
Instance Method Details
#cleanup ⇒ Object
53 54 55 56 57 58 |
# File 'lib/atig/db/db.rb', line 53 def cleanup transaction do @statuses.cleanup @dms.cleanup end end |
#dir(id) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/atig/db/db.rb', line 34 def dir(id) dir = File. "atig/#{@me.screen_name}/", Path log :debug, "db(#{id}) = #{dir}" FileUtils.mkdir_p dir File. "#{id}.#{VERSION}.db", dir end |
#transaction(&f) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/atig/db/db.rb', line 41 def transaction(&f) @followings.transaction do|_| @statuses.transaction do|_| @dms.transaction do|_| @lists.transaction do|_| f.call self end end end end end |