Class: Pindo::PindoUserLocalConfig
- Inherits:
-
Object
- Object
- Pindo::PindoUserLocalConfig
show all
- Defined in:
- lib/pindo/config/pindouserlocalconfig.rb
Defined Under Namespace
Modules: PindoUserLocalMixin
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PindoUserLocalConfig.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 11
def initialize( )
if !File.exist?(Pindoconfig.instance.pindo_dir)
FileUtils.mkdir(Pindoconfig.instance.pindo_dir)
end
@pindo_user_local_config_json = nil
@pindo_user_local_config_file = File.join(File::expand_path(Pindoconfig.instance.pindo_dir), ".pindo_use_local_config.json")
if File.exist?(@pindo_user_local_config_file)
begin
@pindo_user_local_config_json = JSON.parse(File.read(@pindo_user_local_config_file))
rescue => exception
puts "Error !!! +++++++++++ load Pindo local config error !!!"
end
if @pindo_user_local_config_json.nil?
begin
FileUtils.rm_rf(@pindo_user_local_config_file)
rescue => exception
end
end
end
end
|
Class Attribute Details
.instance ⇒ Object
103
104
105
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 103
def self.instance
@instance ||= new
end
|
Instance Attribute Details
#pindo_user_local_config_json ⇒ Object
Returns the value of attribute pindo_user_local_config_json.
9
10
11
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 9
def pindo_user_local_config_json
@pindo_user_local_config_json
end
|
Class Method Details
.reload_instance ⇒ Object
99
100
101
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 99
def self.reload_instance
@instance = new
end
|
Instance Method Details
#get_last_work_project_array ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 59
def get_last_work_project_array()
last_work_project_array = nil
if !@pindo_user_local_config_json.nil?
last_work_project_array = @pindo_user_local_config_json["last_work_project_array"] || []
end
last_work_project_array = last_work_project_array || []
return last_work_project_array;
end
|
#read_local_wechat_url ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 39
def read_local_wechat_url
local_wechat_url = nil
if !@pindo_user_local_config_json.nil?
local_wechat_url = @pindo_user_local_config_json["local_wechat_url"]
end
return local_wechat_url;
end
|
#save ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 117
def save
@pindo_user_local_config_json = @pindo_user_local_config_json || {}
File.open(@pindo_user_local_config_file, "w") do |file|
file.write(JSON.pretty_generate(@pindo_user_local_config_json))
file.close
end
end
|
#unity_version ⇒ Object
125
126
127
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 125
def unity_version
@pindo_user_local_config_json['unity_version'] if @pindo_user_local_config_json
end
|
#unity_version=(version) ⇒ Object
129
130
131
132
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 129
def unity_version=(version)
@pindo_user_local_config_json = @pindo_user_local_config_json || {}
@pindo_user_local_config_json['unity_version'] = version
end
|
#write_last_work_project(proj_name: nil) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 69
def write_last_work_project(proj_name:nil)
if proj_name.nil?
return
end
if proj_name.length < 1
return
end
@pindo_user_local_config_json = @pindo_user_local_config_json || {}
last_work_project_array = @pindo_user_local_config_json["last_work_project_array"] || []
last_work_project_array.delete(proj_name)
last_work_project_array.unshift(proj_name)
last_work_project_array.pop if last_work_project_array.length > 6
last_work_project_array.pop if last_work_project_array.length > 6
@pindo_user_local_config_json["last_work_project_array"] = last_work_project_array
File.open(@pindo_user_local_config_file, "w") do |file|
file.write(JSON.pretty_generate(@pindo_user_local_config_json))
file.close
end
end
|
#write_local_wechat_url(wechat_msg_url: nil) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 48
def write_local_wechat_url(wechat_msg_url:nil)
@pindo_user_local_config_json = @pindo_user_local_config_json || {}
@pindo_user_local_config_json["local_wechat_url"] = wechat_msg_url
File.open(@pindo_user_local_config_file, "w") do |file|
file.write(JSON.pretty_generate(@pindo_user_local_config_json))
file.close
end
end
|