class Repoaccessor::Bundle
Attributes
bundle_path[RW]
host_project[RW]
name[RW]
parsed[RW]
platform[RW]
resources_files[RW]
Public Class Methods
new(path,platform = "ios")
click to toggle source
# File lib/repoaccessor/bundle.rb, line 14 def initialize(path,platform = "ios") @bundle_path = path @platform = platform @name = File.basename(path) @resources_files = [] @parsed = false @host_project = self.host_project end
Public Instance Methods
parse(args = {})
click to toggle source
# File lib/repoaccessor/bundle.rb, line 62 def parse(args = {}) @parsed = true with_comments = args[:with_comments].nil? ? false : args[:with_comments] if @platform == "ios" resource_file_paths.each { |file| file_hash = {} file_hash[:lang] = File.basename(file,".*") file_hash[:kv_pairs] = StringsParser::parse(file).to_hash(:with_comments => with_comments) @resources_files << file_hash } elsif @platform == "android" resource_file_paths.each { |file| file_hash = {} file_hash[:lang] = File.basename(file,".*") file_hash[:kv_pairs] = XMLParser::parse(file).to_hash(:with_comments => with_comments) @resources_files << file_hash } else raise "Unsupported platform" end end
reourcefile_extention()
click to toggle source
# File lib/repoaccessor/bundle.rb, line 23 def reourcefile_extention if @platform == "ios" "*.strings" elsif @platform == "android" "*.xml" end end
resource_file_paths()
click to toggle source
# File lib/repoaccessor/bundle.rb, line 32 def resource_file_paths Dir.chdir(@bundle_path) files = [] extention = reourcefile_extention Dir.glob(File.join("**", "#{extention}")) { |file| files << File.expand_path(file) } files end
to_hash(args={})
click to toggle source
# File lib/repoaccessor/bundle.rb, line 86 def to_hash(args={}) if @parsed == false then self.parse(args) end { :name => @name, :host_project => @host_project, :path => @bundle_path, :platform => @platform, :parsed => @parsed, :resources_files => @resources_files } end
to_json(args={})
click to toggle source
# File lib/repoaccessor/bundle.rb, line 101 def to_json(args={}) self.to_hash.to_json end