Class: RRSE::Command::UpdateDB::BitClustAdaptor
- Inherits:
-
Object
- Object
- RRSE::Command::UpdateDB::BitClustAdaptor
- Defined in:
- lib/rrse/update-db-command.rb
Instance Method Summary collapse
- #extract_params_from_source(name, source) ⇒ Object
- #generate_tables ⇒ Object
-
#initialize(bitclust_config, version, dbpath) ⇒ BitClustAdaptor
constructor
A new instance of BitClustAdaptor.
- #method_typemark?(typemark) ⇒ Boolean
- #normalize_typemark(typemark) ⇒ Object
Constructor Details
#initialize(bitclust_config, version, dbpath) ⇒ BitClustAdaptor
Returns a new instance of BitClustAdaptor.
56 57 58 59 60 |
# File 'lib/rrse/update-db-command.rb', line 56 def initialize(bitclust_config, version, dbpath) version ||= bitclust_config[:default_version] dbpath ||= bitclust_config[:database_prefix] + "-" + version @db = BitClust::MethodDatabase.new(dbpath) end |
Instance Method Details
#extract_params_from_source(name, source) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rrse/update-db-command.rb', line 87 def extract_params_from_source(name, source) source.each_line.find_all{|line| /\A--- #{Regexp.quote(name)}[^a-zA-Z_\[\]=]/ =~ line }.map{|line| line.chomp. gsub(/\A--- #{Regexp.quote(name)}/, ""). gsub(/\t/, ""). gsub(/ +/, ""). gsub(/->nil\Z/, ""). gsub(/->\(\)\Z/, "") } end |
#generate_tables ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rrse/update-db-command.rb', line 62 def generate_tables all_entries = Hash.new{|h, k| h[k] = [] } index_table = Hash.new{|h, k| h[k] = [] } @db.classes.each do |c| c.entries.each do |m| typemark = normalize_typemark(m.typemark) next unless method_typemark?(typemark) m.names.each do |name| spec = "#{c.name}#{typemark}#{name}" all_entries[spec].concat(extract_params_from_source(name, m.source)) index_table[name] << spec end end end return all_entries, index_table end |
#method_typemark?(typemark) ⇒ Boolean
83 84 85 |
# File 'lib/rrse/update-db-command.rb', line 83 def method_typemark?(typemark) typemark == "." || typemark == "#" end |
#normalize_typemark(typemark) ⇒ Object
79 80 81 |
# File 'lib/rrse/update-db-command.rb', line 79 def normalize_typemark(typemark) typemark == ".#" ? "." : typemark end |