Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made parsing work multiple times over

  • Loading branch information...
commit 3f5dcae7853983cddf5a4018527bdb02f08a3ffd 1 parent 5cfd6fb
Ian Ownbey authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 lib/parsing.rb
View
17 lib/parsing.rb
@@ -13,7 +13,7 @@ def import!(argv)
options = Options.instance
options.parse(argv, GENERATORS)
-
+
@last_created = nil
start_time = Time.now
@@ -84,6 +84,7 @@ def generate(files)
@methods = []
@in_files = []
+
files.each { |file| add_file(file) }
files.each { |file| process_file(file) }
@@ -210,7 +211,7 @@ def process_method(obj, parent)
if obj.is_alias_for.nil?
@first_comment ||= Digest::MD5.hexdigest(obj.comment) if obj.comment
parent = CodeContainer.find_by_full_name(parent.try(:full_name) || parent.file_absolute_name)
- p = CodeMethod.create(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.id, :name => obj.name, :parameters => obj.params, :block_parameters => obj.block_params, :singleton => obj.singleton, :visibility => obj.visibility.to_s, :force_documentation => obj.force_documentation, :source_code => get_source_code(obj))
+ p = CodeMethod.create_or_update_by_code_file_id_and_name_and_singleton(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.id, :name => obj.name, :parameters => obj.params, :block_parameters => obj.block_params, :singleton => obj.singleton, :visibility => obj.visibility.to_s, :force_documentation => obj.force_documentation, :source_code => get_source_code(obj))
comment = CodeComment.create_or_update_by_owner_id_and_owner_type :exported_body => obj.comment, :owner_id => p.id, :owner_type => p.class unless obj.comment.blank?
@methods << p.id
@comments << comment.id if comment
@@ -223,14 +224,14 @@ def process_alias(obj, parent, from_method = false)
@first_comment ||= Digest::MD5.hexdigest(obj.comment) if obj.comment
parent = CodeContainer.find_by_full_name(parent.try(:full_name) || parent.file_absolute_name)
if from_method
- p = CodeAlias.create({
+ p = CodeAlias.create_or_update_by_code_file_id_and_name_and_old_name({
:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id),
:code_container_id => parent.try(:id),
:name => obj.name,
:old_name => obj.is_alias_for.name,
})
else
- p = CodeAlias.create({
+ p = CodeAlias.create_or_update_by_code_file_id_and_name_and_old_name({
:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id),
:code_container_id => parent.try(:id),
:name => (obj.try(:new_name) || obj.name),
@@ -243,7 +244,7 @@ def process_alias(obj, parent, from_method = false)
def process_constant(obj, parent)
@first_comment ||= Digest::MD5.hexdigest(obj.comment) if obj.comment
parent = CodeContainer.find_by_full_name(parent.try(:full_name) || parent.file_absolute_name)
- p = CodeConstant.create_or_update_by_name_and_code_container_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name, :value => obj.value)
+ p = CodeConstant.create_or_update_by_name_and_code_file_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name, :value => obj.value)
comment = CodeComment.create_or_update_by_owner_id_and_owner_type :exported_body => obj.comment, :owner_id => p.id, :owner_type => p.class unless obj.comment.blank?
@objects << p.id
@comments << comment.id if comment
@@ -252,7 +253,7 @@ def process_constant(obj, parent)
def process_attribute(obj, parent)
@first_comment ||= Digest::MD5.hexdigest(obj.comment) if obj.comment
parent = CodeContainer.find_by_full_name(parent.try(:full_name) || parent.file_absolute_name)
- p = CodeAttribute.create_or_update_by_name_and_code_container_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name, :read_write => obj.rw)
+ p = CodeAttribute.create_or_update_by_name_and_code_file_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name, :read_write => obj.rw)
comment = CodeComment.create_or_update_by_owner_id_and_owner_type :exported_body => obj.comment, :owner_id => p.id, :owner_type => p.class unless obj.comment.blank?
@objects << p.id
@comments << comment.id if comment
@@ -261,7 +262,7 @@ def process_attribute(obj, parent)
def process_require(obj, parent)
@first_comment ||= Digest::MD5.hexdigest(obj.comment) if obj.comment
parent = CodeContainer.find_by_full_name(parent.try(:full_name) || parent.file_absolute_name)
- p = CodeRequire.create_or_update_by_name_and_code_container_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name)
+ p = CodeRequire.create_or_update_by_name_and_code_file_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name)
comment = CodeComment.create_or_update_by_owner_id_and_owner_type :exported_body => obj.comment, :owner_id => p.id, :owner_type => p.class unless obj.comment.blank?
@objects << p.id
@comments << comment.id if comment
@@ -270,7 +271,7 @@ def process_require(obj, parent)
def process_include(obj, parent)
@first_comment ||= Digest::MD5.hexdigest(obj.comment) if obj.comment
parent = CodeContainer.find_by_full_name(parent.try(:full_name) || parent.file_absolute_name)
- p = CodeInclude.create_or_update_by_name_and_code_container_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name)
+ p = CodeInclude.create_or_update_by_name_and_code_file_id(:code_file_id => CodeFile.find_by_full_name(obj.file).try(:id), :code_container_id => parent.try(:id), :name => obj.name)
comment = CodeComment.create_or_update_by_owner_id_and_owner_type :exported_body => obj.comment, :owner_id => p.id, :owner_type => p.class unless obj.comment.blank?
@objects << p.id
@comments << comment.id if comment
Please sign in to comment.
Something went wrong with that request. Please try again.