Class: UserSetting::ProjectSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-devtool/setting/project_setting_tool.rb

Instance Method Summary collapse

Constructor Details

#initializeProjectSetting

Returns a new instance of ProjectSetting.



5
6
7
8
9
10
11
12
13
# File 'lib/cocoapods-devtool/setting/project_setting_tool.rb', line 5

def initialize
  @jsonPath = '../../../setting/project_setting.json'
  path = File.expand_path(@jsonPath, __FILE__)
  data = File.open(path) do |f|
    JSON.load(f)
  end
  @settingData = data
  @settingData = {} if data.nil?
end

Instance Method Details

#get_project_setting(path, target, config, key) ⇒ Object



20
21
22
23
# File 'lib/cocoapods-devtool/setting/project_setting_tool.rb', line 20

def get_project_setting(path,target,config,key)
  real_key = "#{path}_#{target}_#{config}_#{key}"
  return @settingData[real_key]
end

#has_project_setting(path, target, config, key) ⇒ Object



15
16
17
18
# File 'lib/cocoapods-devtool/setting/project_setting_tool.rb', line 15

def has_project_setting(path,target,config,key)
  real_key = "#{path}_#{target}_#{config}_#{key}"
  return @settingData.has_key?(real_key)
end

#saveObject



33
34
35
36
37
# File 'lib/cocoapods-devtool/setting/project_setting_tool.rb', line 33

def save
  path = File.expand_path(@jsonPath, __FILE__)
  json = JSON.generate(@settingData)
  File.write(path,json)
end

#set_project_setting(path, target, config, key, value) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/cocoapods-devtool/setting/project_setting_tool.rb', line 25

def set_project_setting(path, target,config,key, value)
  real_key = "#{path}_#{target}_#{config}_#{key}"
  if value.nil?
    @settingData.delete(real_key)
  else
    @settingData[real_key] = value
  end
end