Class: Inform::Module
- Inherits:
-
Sequel::Model
- #Object
- Object
- Sequel::Model
- Inform::Module
- Defined in:
- lib/story_teller/inform/relational/module.rb
Overview
Deine the Inform::Module class
Class Method Summary collapse
-
.dirty ⇒ Object
rubocop: disable Style/FormatString rubocop: disable Style/FormatStringToken.
-
.stats ⇒ Object
rubocop: disable Style/FormatString rubocop: disable Style/FormatStringToken.
- .tidy ⇒ Object
Instance Method Summary collapse
Methods inherited from Sequel::Model
Methods included from StoryTeller::InheritanceListener
Class Method Details
.dirty ⇒ Object
rubocop: disable Style/FormatString rubocop: disable Style/FormatStringToken
74 75 76 77 78 79 80 81 |
# File 'lib/story_teller/inform/relational/module.rb', line 74 def self.dirty results = db.fetch %{select a.id, a.name from module a group by a.id, a.name having ((select count(b.id) from modularized b where b.module_id = a.id) = 0)} return nil if results.empty? s = ["%5s %20s" % results.first.keys] s.concat(results.collect { |row| "%5d %20s" % row.values }) s.join("\n") end |
.stats ⇒ Object
rubocop: disable Style/FormatString rubocop: disable Style/FormatStringToken
87 88 89 90 91 92 93 94 |
# File 'lib/story_teller/inform/relational/module.rb', line 87 def self.stats results = db.fetch %{select a.*, count(a.id) as "number modularized" from module a, modularized b where b.module_id = a.id group by a.id, a.name} return nil if results.empty? s = ["%5s %20s %15s" % results.first.keys] s.concat(results.collect { |row| "%5d %20s %15s" % row.values }) s.join("\n") end |
.tidy ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/story_teller/inform/relational/module.rb', line 64 def self.tidy db << %{delete from module where id in (select a.id from module a group by a.id, a.name having ((select count(b.id) from modularized b where b.module_id = a.id) = 0))} return nil end |