Class: DocStat::Container
- Inherits:
-
Object
- Object
- DocStat::Container
- Defined in:
- lib/docstat/container.rb
Constant Summary collapse
- QUERY =
"select ZCONTAINERNAME,ZTOKENNAME,ZTYPENAME,ZTOKENMETAINFORMATION.ZABSTRACT,ZDECLARATION from ZTOKEN \ left join ZCONTAINER on ZTOKEN.ZCONTAINER = ZCONTAINER.Z_PK \ left join ZTOKENTYPE on ZTOKEN.ZTOKENTYPE = ZTOKENTYPE.Z_PK \ left join ZTOKENMETAINFORMATION on ZTOKEN.Z_PK = ZTOKENMETAINFORMATION.ZTOKEN \ order by ZCONTAINERNAME"
- QUERY_WITH_RETURN_VALUES =
"select ZCONTAINERNAME,ZTOKENNAME,ZTYPENAME,ZTOKENMETAINFORMATION.ZABSTRACT,ZDECLARATION,ZRETURNVALUE.ZABSTRACT from ZTOKEN \ left join ZCONTAINER on ZTOKEN.ZCONTAINER = ZCONTAINER.Z_PK \ left join ZTOKENTYPE on ZTOKEN.ZTOKENTYPE = ZTOKENTYPE.Z_PK \ left join ZTOKENMETAINFORMATION on ZTOKEN.Z_PK = ZTOKENMETAINFORMATION.ZTOKEN \ left join ZRETURNVALUE on ZTOKENMETAINFORMATION.ZRETURNVALUE = ZRETURNVALUE.Z_PK \ order by ZCONTAINERNAME"
- RETURNVALUES_QUERY =
"SELECT * FROM sqlite_master WHERE type='table'"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(name, tokens) ⇒ Container
constructor
A new instance of Container.
- #method_documentation_ratio ⇒ Object
- #property_documentation_ratio ⇒ Object
- #ratio ⇒ Object
- #to_hash ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/docstat/container.rb', line 7 def name @name end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
7 8 9 |
# File 'lib/docstat/container.rb', line 7 def tokens @tokens end |
Class Method Details
.from_sqlite(path) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/docstat/container.rb', line 24 def self.from_sqlite path db = SQLite3::Database.new(path) rows = has_return_values?(db) ? db.execute(QUERY_WITH_RETURN_VALUES) : db.execute(QUERY) container_groups = rows.group_by {|r| r.first } groups = container_groups.map do |name, tokens| self.new(name, tokens) end db.close groups end |
.has_return_values?(database) ⇒ Boolean
39 40 41 |
# File 'lib/docstat/container.rb', line 39 def self.has_return_values? database database.execute(RETURNVALUES_QUERY).detect {|r| r[1] == 'ZRETURNVALUE'} != nil end |
Instance Method Details
#description ⇒ Object
63 64 65 66 |
# File 'lib/docstat/container.rb', line 63 def description token_description = tokens.map {|t| t.description}.join("\n") "#{name}:\n#{token_description}" end |
#method_documentation_ratio ⇒ Object
55 56 57 |
# File 'lib/docstat/container.rb', line 55 def method_documentation_ratio documentation_ratio(tokens.select(:method?)) end |
#property_documentation_ratio ⇒ Object
59 60 61 |
# File 'lib/docstat/container.rb', line 59 def property_documentation_ratio documentation_ratio(tokens.select(:property?)) end |
#ratio ⇒ Object
51 52 53 |
# File 'lib/docstat/container.rb', line 51 def ratio documentation_ratio(tokens) end |
#to_hash ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/docstat/container.rb', line 43 def to_hash { "name" => name, "tokens" => tokens.map(&:to_hash), "ratio" => ratio } end |