class Xcadaptor::Adapt

Public Instance Methods

ios(version) click to toggle source
# File lib/xcadaptor/adapt.rb, line 19
def ios(version)
  sub_command_file_path =  File.expand_path "#{File.dirname(__FILE__)}/Adapt/IOS/#{version}"
  begin
    if require_all(sub_command_file_path)
      function_types = options[:category] 
      if function_types 
        #excute specified cateoty update
        function_types.each do |function_type|
          if File.exist? "#{sub_command_file_path}/#{function_type}.rb" 
            run_category function_type  , version
          else
            puts "#{function_type} not found\n"
          end
        end

      else 
        
        #excute all category update
        Dir.glob("#{sub_command_file_path}/*.rb").each do |f_path|
          pn = Pathname.new f_path
          file_name = pn.basename(".*").to_s
          run_category file_name  , version
        end

      end

    else 
      puts "ios version not found."
    end
  rescue => e 
    puts e
  end 
end

Private Instance Methods

require_all(path) click to toggle source

require all file at path directory

# File lib/xcadaptor/adapt.rb, line 57
def require_all(path)
    begin
      Dir.glob("#{path}/*.rb").each do |f_path|
        require f_path
      end 
    rescue => e
      puts e
      return false  
    end
    return true;
end
run_category(category_name,ios_version) click to toggle source

run category task

# File lib/xcadaptor/adapt.rb, line 71
def run_category(category_name,ios_version)
  class_name = "Xcadaptor::AdaptModule::IOS#{ios_version.to_i}Module::#{category_name.capitalize}"
  clazz = class_name.split('::').inject(Object) {|o,c| o.const_get c}
  clazz.run 
end