class Repoaccessor::Repo

Attributes

branch_url[RW]
platform[RW]
repo_name[RW]
resource_file_extention[RW]
rootpath[RW]

Public Class Methods

new(path,platform = "ios") click to toggle source
# File lib/repoaccessor/repo.rb, line 16
def initialize(path,platform = "ios")
        @rootpath = path
        @platform = platform
        @resource_file_extention = (platform == "ios" ? "*.strings" : "*.xml")
        @repo_name = File.basename(path,".*")
end

Public Instance Methods

bundle_paths() click to toggle source
# File lib/repoaccessor/repo.rb, line 23
def bundle_paths
        #TODO:  这里根据platform改一下 iOS和android找不同的目录
        Dir.chdir(@rootpath)
        paths = []
        Dir.glob(File.join("**", "*.bundle")) { |file| 
        paths <<  File.expand_path(file) 
        }
        paths
end
parse_repo() click to toggle source
# File lib/repoaccessor/repo_parser.rb, line 35
def parse_repo
        bundles = []
        self.bundle_paths.each { 
                |path|  
                Dir.chdir(path)
                file_pattern = File.join("**", "#{@resource_file_extention}")
                resource_files =  Dir.glob(file_pattern) 
                if !resource_files.empty?
                        bundles << (Bundle.new(path,@platform).to_hash())
                end
        }
        bundles
end
parsed_bundles() click to toggle source
# File lib/repoaccessor/repo.rb, line 33
def parsed_bundles
        bundles = []
        self.bundle_paths.each { 
                |path|  
                Dir.chdir(path)
                file_pattern = File.join("**", "#{@resource_file_extention}")
                resource_files =  Dir.glob(file_pattern) 
                if !resource_files.empty?
                        bundles << (Bundle.new(path,@platform).to_hash())
                end
        }
        bundles
end
to_hash() click to toggle source
# File lib/repoaccessor/repo.rb, line 48
def to_hash
        {
                :repo_name => @repo_name,
                :platform  => @platform,
                :resource_file_extention => @resource_file_extention,
                :bunldes => self.parsed_bundles
        }

end