Class: Pindo::PindoUserLocalConfig

Inherits:
Object
  • Object
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

#initializePindoUserLocalConfig

Returns a new instance of PindoUserLocalConfig.



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
38
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 12

def initialize( )
  
  # puts "initialize Pindoconfig"
  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

.instanceObject



66
67
68
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 66

def self.instance
  @instance ||= new
end

Instance Attribute Details

#pindo_user_local_config_jsonObject

Returns the value of attribute pindo_user_local_config_json.



10
11
12
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 10

def pindo_user_local_config_json
  @pindo_user_local_config_json
end

Class Method Details

.reload_instanceObject



62
63
64
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 62

def self.reload_instance
  @instance = new
end

Instance Method Details

#read_local_wechat_urlObject



40
41
42
43
44
45
46
47
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 40

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

#write_local_wechat_url(wechat_msg_url: nil) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/pindo/config/pindouserlocalconfig.rb', line 49

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