Class: IosBox::BuildCache

Inherits:
Object
  • Object
show all
Defined in:
lib/build_cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/build_cache.rb', line 22

def method_missing(m, *args, &block)
  if (args.length > 0)
    self.class.class_eval do
      define_method("#{m.to_s[0, m.to_s.length - 1]}") do
        instance_variable_get("@#{m.to_s[0, m.to_s.length - 1]}")
      end

      define_method("#{m.to_s[0, m.to_s.length - 1]}=") do |val|
        instance_variable_set("@#{m.to_s[0, m.to_s.length - 1]}", val)
      end
    end
    return instance_variable_set("@#{m.to_s[0, m.to_s.length - 1]}", args[0])
  end

  self.class.class_eval do
    define_method(m) do
      instance_variable_get("@#{m}")
    end
  end
  return instance_variable_get("@#{m}")
end

Class Method Details

.load(file = ".buildCache") ⇒ Object



13
14
15
16
# File 'lib/build_cache.rb', line 13

def self.load file = ".buildCache"
  return unless File.file?(file)
  YAML.load_file(file)
end

Instance Method Details

#init(config) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/build_cache.rb', line 3

def init config
  # Fill our config object
  # But only if it hasn't been initialized yet and not in XCode env
  if (config.project_dir.nil? && ENV['XCODE_VERSION_ACTUAL'].nil?)
    config.project_dir = @project_dir
    config.infoplist_file = @infoplist_file
    config.plist = File.join(@project_dir, @infoplist_file) unless @project_dir.nil?
  end
end

#save(file = ".buildCache") ⇒ Object



18
19
20
# File 'lib/build_cache.rb', line 18

def save file = ".buildCache"
  File.open(file, 'w') { |io| YAML.dump(self, io) }
end