Module: Lazibi::Helper::TaskHelper
- Included in:
- Task
- Defined in:
- lib/helper/task_helper.rb
Instance Method Summary collapse
- #convert_path(path) ⇒ Object
- #get_filters(path) ⇒ Object
- #original_path(path) ⇒ Object
- #sep_line ⇒ Object
- #skip_path?(path) ⇒ Boolean
- #sort_filter(filters) ⇒ Object
Instance Method Details
#convert_path(path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/helper/task_helper.rb', line 12 def convert_path( path ) if path =~ /.*[.]py[.]rb/ from = 'meta' to = 'real' old_ext = '.py.rb' new_ext = '.rb' else from = 'real' to = 'meta' old_ext = '.rb' new_ext = '.py.rb' end dir_name = File.dirname path base_name = File.basename path, old_ext new_dir_name = to + dir_name[from.size..-1] new_path = File.join new_dir_name, base_name + new_ext end |
#get_filters(path) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/helper/task_helper.rb', line 32 def get_filters(path) filters = @config[:filters] return unless filters path_filters = [] for filter in filters.keys path_patterns = filters[filter] for p in path_patterns if original_path(path) =~ Regexp.new(p) path_filters << filter.to_sym next end end end sort_filter path_filters end |
#original_path(path) ⇒ Object
55 56 57 58 |
# File 'lib/helper/task_helper.rb', line 55 def original_path(path) offset = 'meta'.size + 1 path[offset..-1] end |
#sep_line ⇒ Object
60 61 62 |
# File 'lib/helper/task_helper.rb', line 60 def sep_line puts '-' * 40 end |
#skip_path?(path) ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/helper/task_helper.rb', line 4 def skip_path?(path) return false if @config[:exclude].nil? @config[:exclude].each do |f| return true if original_path(path) =~ Regexp.new(f) end false end |
#sort_filter(filters) ⇒ Object
49 50 51 52 53 |
# File 'lib/helper/task_helper.rb', line 49 def sort_filter( filters ) order = @config[:filter_order] if @config order = [:syntax_guard, :beautify, :optional_end, :optional_do] unless order filters.sort{ |a,b| order.index(a) <=> order.index(b) } end |