Class: BigKeeper::LibraryModel
- Inherits:
-
Object
- Object
- BigKeeper::LibraryModel
- Defined in:
- lib/big_keeper/model/library_model.rb
Instance Attribute Summary collapse
-
#file_list ⇒ Object
Returns the value of attribute file_list.
-
#header_file_list ⇒ Object
Returns the value of attribute header_file_list.
-
#keyword_list ⇒ Object
Returns the value of attribute keyword_list.
-
#name ⇒ Object
Returns the value of attribute name.
-
#spec_library ⇒ Object
Returns the value of attribute spec_library.
Instance Method Summary collapse
- #get_all_public_file(path) ⇒ Object
-
#initialize(name) ⇒ LibraryModel
constructor
A new instance of LibraryModel.
- #spec_dependece_library(library_keywords_hash) ⇒ Object
Constructor Details
#initialize(name) ⇒ LibraryModel
Returns a new instance of LibraryModel.
8 9 10 11 12 13 14 |
# File 'lib/big_keeper/model/library_model.rb', line 8 def initialize(name) @name = name @file_list = [] @header_file_list = [] @spec_library = [] @keyword_list = [] end |
Instance Attribute Details
#file_list ⇒ Object
Returns the value of attribute file_list.
7 8 9 |
# File 'lib/big_keeper/model/library_model.rb', line 7 def file_list @file_list end |
#header_file_list ⇒ Object
Returns the value of attribute header_file_list.
7 8 9 |
# File 'lib/big_keeper/model/library_model.rb', line 7 def header_file_list @header_file_list end |
#keyword_list ⇒ Object
Returns the value of attribute keyword_list.
7 8 9 |
# File 'lib/big_keeper/model/library_model.rb', line 7 def keyword_list @keyword_list end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/big_keeper/model/library_model.rb', line 7 def name @name end |
#spec_library ⇒ Object
Returns the value of attribute spec_library.
7 8 9 |
# File 'lib/big_keeper/model/library_model.rb', line 7 def spec_library @spec_library end |
Instance Method Details
#get_all_public_file(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/big_keeper/model/library_model.rb', line 16 def get_all_public_file(path) all_header = FileOperator.find_all_header_file("#{path}/Pods/#{@name}") for file_path in all_header do @header_file_list[@header_file_list.size] = file_path file_name = File.basename(file_path) @keyword_list[@keyword_list.size] = file_name in_note = false File.foreach(file_path) { |line| hash = Hash.new hash["in_note"]=in_note hash["line"]=line OCCodeOperator.in_note_code(hash) in_note = hash["in_note"] line = hash["line"] if line.empty? next end if line.include?("@interface ") line[0,line.index("@interface ")+11]="" column = line.split(/:/) if column.size > 1 class_name = column[0] if class_name.include?("<") class_name = class_name[0, class_name.index("<")] end class_name = class_name.strip if (@keyword_list.include?(class_name+".h")) @keyword_list.delete(class_name+".h") end @keyword_list[@keyword_list.size] = class_name end end } end # if @name == "" # puts @keyword_list # end @file_list = FileOperator.find_all_code_file("#{path}/Pods/#{@name}") end |
#spec_dependece_library(library_keywords_hash) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/big_keeper/model/library_model.rb', line 56 def spec_dependece_library(library_keywords_hash) if library_keywords_hash.include?(@name) library_keywords_hash.delete(@name) end for file_path in @file_list do # note for coding in_note = false File.foreach(file_path) { |line| hash = Hash.new hash["in_note"]=in_note hash["line"]=line OCCodeOperator.in_note_code(hash) in_note = hash["in_note"] line = hash["line"] if line.empty? next end library_keywords_hash.each {|library_name, keyword_list| is_dependence = false tip = "" for keyword in keyword_list do if line.include?(keyword) last_char = '.' last_index = line.index(keyword)-1 if last_index >= 0 last_char = line[last_index] end next_char = '.' next_index = line.index(keyword)+keyword.size if next_index < line.size next_char = line[next_index] end if !(((next_char<='z'&&next_char>='a')||(next_char<='Z'&&next_char>='A')||(next_char<='9'&&next_char>='0')||next_char=='_')||((last_char<='z'&&last_char>='a')||(last_char<='Z'&&last_char>='A')||(last_char<='9'&&last_char>='0')||last_char=='_')) if keyword.include?(".h") && line.include?("import") && line.include?("/"+keyword+">") dependence_library_name = line[line.index("<")+1...line.index("/"+keyword+">")] if dependence_library_name == library_name tip = " [file]:"+File.basename(file_path)+" [line]: "+line.strip+" [keyword]: "+keyword is_dependence = true break end else tip = " [file]:"+File.basename(file_path)+" [line]: "+line.strip+" [keyword]: "+keyword is_dependence = true break end end end end if is_dependence @spec_library[@spec_library.size] = library_name+tip library_keywords_hash.delete(library_name) end } } end end |