Class: Furion

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

Class Method Summary collapse

Class Method Details

.checkUpdateObject



101
102
103
# File 'lib/furion.rb', line 101

def self.checkUpdate
  FurionVersion.checkUpdate
end

.detectConflictObject



76
77
78
# File 'lib/furion.rb', line 76

def self.detectConflict
    ConflictDetector.detectConflict
end

.fetchFile(fileName) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/furion.rb', line 14

def self.fetchFile(fileName)
    uri = "https://git.huya.com/chenguohao2/FurionTemplateResource/raw/master/iOS/"+fileName
    puts "download from "+uri
    data = open(uri){|f| f.read}
    file = File.new fileName, 'w+'
    file.binmode
    file << data
    file.flush
    file.close
end

.genProj(name) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/furion.rb', line 80

def self.genProj(name)
  fileName = "FurionExample.zip"
  self.fetchFile(fileName)
  system("unzip", fileName)
  File.delete(fileName)
  ProjectGenerater.setupProject("FurionExample",name)
  FileUtils.rm_rf("FurionExample")
end

.makeConfigObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/furion.rb', line 25

def self.makeConfig
    self.fetchFile("GenConfig.py")
    self.fetchFile("furionpod")
    self.fetchFile("example.code")
    result = `python GenConfig.py `
    File.write('data.json', result)
    `plutil -convert xml1 data.json -o MTPSDK.plist`
    if !(File.exist?'MTPSDK.plist')
      puts "error in Config Generation: "+result
    end

    FileEditor.editPodfile

    File.delete('GenConfig.py')
    File.delete('data.json')
    FileEditor.insertExampleCode
    File.delete('example.code')
    puts "pod installing..."
    `pod install`
    projName = FileEditor.getCuriOSProjName
    puts "Config finished, run "+projName+".xcworkspace to continue "
end

.runCMDObject



90
91
92
93
94
95
96
97
98
99
# File 'lib/furion.rb', line 90

def self.runCMD
      cmd = ARGV[0]
      if cmd == "init"
        makeConfig
      end

      if cmd == "create"
        puts "to be continue"
      end
end

.updateConfigObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/furion.rb', line 48

def self.updateConfig

      if !(File.exist?'MTPSDK.plist')
        puts "MTPSDK.plist not exist "
        return
      end

      self.fetchFile("GenConfig.py")
      sdkWrapperDict = Plist::parse_xml("MTPSDK.plist")
      jsonObj = sdkWrapperDict.to_json
      fJson = File.open("cachedConfig.json","w")
      fJson.write(jsonObj)
      fJson.close
      result = `python GenConfig.py update`
      File.write('data.json', result)
      `plutil -convert xml1 data.json -o MTPSDK.plist`
      if !(File.exist?'MTPSDK.plist')
        puts "error in Config Generation: "+result
      end
      puts "pod installing..."
      `pod install`
      File.delete('GenConfig.py')
      File.delete('data.json')
      File.delete("cachedConfig.json")
      projName = FileEditor.getCuriOSProjName
      puts "Config finished, run "+projName+".xcworkspace to continue "
end