Class: StoryboardLint::StoryboardScanner
- Inherits:
-
Object
- Object
- StoryboardLint::StoryboardScanner
- Defined in:
- lib/storyboardlint.rb
Instance Method Summary collapse
- #custom_class_names ⇒ Object
-
#initialize(src_root) ⇒ StoryboardScanner
constructor
A new instance of StoryboardScanner.
- #reuse_ids ⇒ Object
- #scan_files ⇒ Object
- #segue_ids ⇒ Object
- #storyboard_files ⇒ Object
- #storyboard_ids ⇒ Object
Constructor Details
#initialize(src_root) ⇒ StoryboardScanner
Returns a new instance of StoryboardScanner.
10 11 12 13 |
# File 'lib/storyboardlint.rb', line 10 def initialize(src_root) @src_root = src_root @scan_performed = false end |
Instance Method Details
#custom_class_names ⇒ Object
61 62 63 64 |
# File 'lib/storyboardlint.rb', line 61 def custom_class_names scan_files @custom_class_names end |
#reuse_ids ⇒ Object
56 57 58 59 |
# File 'lib/storyboardlint.rb', line 56 def reuse_ids scan_files @reuse_ids end |
#scan_files ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/storyboardlint.rb', line 22 def scan_files if !@scan_performed @segue_ids ||= [] @storyboard_ids ||= [] @reuse_ids ||= [] @custom_class_names = [] storyboard_files.each do |sb_file| sb_source = File.open(sb_file) doc = Nokogiri::XML(sb_source) doc.xpath('//segue').each do |element| seg_id = element.attr('identifier') @segue_ids << {:file => sb_file, :id => seg_id.to_s} if seg_id end @storyboard_ids += doc.xpath("//@storyboardIdentifier").to_a.map {|match| {:file => sb_file, :id => match.to_s}} @reuse_ids += doc.xpath("//@reuseIdentifier").to_a.map {|match| {:file => sb_file, :id => match.to_s}} @custom_class_names += doc.xpath("//@customClass").to_a.map {|match| {:file => sb_file, :class_name => match.to_s}} end @scan_performed = true end end |
#segue_ids ⇒ Object
46 47 48 49 |
# File 'lib/storyboardlint.rb', line 46 def segue_ids scan_files @segue_ids end |
#storyboard_files ⇒ Object
15 16 17 18 19 20 |
# File 'lib/storyboardlint.rb', line 15 def storyboard_files return @sb_files if @sb_files # find all storyboard files... @sb_files = Dir.glob(File.join(@src_root, "**/*.storyboard")) end |
#storyboard_ids ⇒ Object
51 52 53 54 |
# File 'lib/storyboardlint.rb', line 51 def storyboard_ids scan_files @storyboard_ids end |