furion 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca26a733e31772883880213f408db1eced1b5e3f1a48a95c929a171c8ce80784
4
- data.tar.gz: 653e973ed7f887dbeabc9f74ae5e829b0a632c3b26f2a8aa491a711025cf38b8
3
+ metadata.gz: f387d44f214f02e701eea0f810ed785014ce72f067b12430360e861b06242b59
4
+ data.tar.gz: 761a639c07a3a5d2e745061f521e38b5af79310a75a483faf56d78f6c79e50ca
5
5
  SHA512:
6
- metadata.gz: bfd9649d727db6827a47c07188311fdfa02bdd39b711d1d2ce4c02166f0f1131d0f4fbb52da11f6498b02459b86ca3462091fbe69549ae164c3d1c7770229f15
7
- data.tar.gz: 85ae79eeb1fb27bb225165546238791879d48d97e32ba0af5ea00b5c3cf69374c90c7fb600f5d538aebbc2b94fe5cc6c64da3c9d817332167bb481afd35e6ea1
6
+ metadata.gz: b1475b39e216840209952488840085e0820c265ddd6ccdae5ecfc82f656bdb2cd67d5daa744b1a096693bdb2e0c1d17e44f155f9a1b213180903eb550e124ee9
7
+ data.tar.gz: 6c40db14e76375109e07765d82e3a351be8662634d093d2085352a36e8f8d699d97e6c77b11d5513c54623af979007a308e27e79af3dad2d5de327608bc7b62e
@@ -17,7 +17,16 @@ class FileEditor
17
17
  end
18
18
 
19
19
  def self.editPodfile
20
+
20
21
  projName = self.getCuriOSProjName
22
+
23
+ if projName.length == 0
24
+ return
25
+ end
26
+
27
+ if !FileTest::exist?("podfile")
28
+ self.initPodfile(projName)
29
+ end
21
30
  File.open("_Podfile", "w") do |out|
22
31
  hasSource = false
23
32
  hasAddRequire = false
@@ -50,9 +59,108 @@ class FileEditor
50
59
  File.rename("_Podfile","Podfile")
51
60
  end
52
61
 
53
- def loadWrapperExample
62
+ def self.initPodfile(target)
63
+ File.open("podfile", "w") do |out|
64
+ out.puts "source 'https://gitlab.huya.com/ci_team/Specs.git'"
65
+ out.puts "source 'https://github.com/CocoaPods/Specs.git'"
66
+ out.puts "platform :ios, '9.0'"
67
+ out.puts "target '"+target+"' do"
68
+ out.puts ""
69
+ out.puts "end"
70
+ end
71
+ end
72
+
73
+ def self.insertExampleCode
74
+
75
+ dict = Plist::parse_xml("MTPSDK.plist")
76
+ wrapperSDKDict = dict["sdkWrapper"]
77
+ params = dict["commonParams"]
78
+ keys = wrapperSDKDict.keys()
79
+ keys.insert(0,"commonCode")
80
+ keys.append("finnalInit")
81
+ puts keys
82
+ targetFilePath = ""
83
+ Find.find(Dir::pwd) do |path|
84
+ if path.end_with? "AppDelegate.m"
85
+ targetFilePath = path
86
+ break
87
+ end
88
+ end
89
+
90
+ File.open("_AppDelegate.m", "w") do |out|
91
+ File.foreach(targetFilePath) do |line|
92
+ out.puts line
93
+ if line.include?"#import \"AppDelegate.h\""
94
+ out.puts "#import <Hosttemplate/HostTemplate.h>"
95
+ end
96
+ if line.include? "application:(UIApplication *)application didFinishLaunchingWithOptions:"
97
+ loadWrapperExample(keys,params,out)
98
+ end
99
+ end
100
+ end
101
+
102
+ File.delete(targetFilePath)
103
+ File.rename("_AppDelegate.m",targetFilePath)
104
+
105
+ end
106
+
107
+ def self.loadWrapperExample(keys,params,file)
108
+
109
+ inRecording = false
110
+ File.foreach("example.code") do |line|
111
+
112
+ if line =~ /\#Furion\#end-/
113
+ inRecording = false
114
+ end
115
+
116
+ if inRecording
117
+ content = line
118
+ if line.include?"$FurionVar_"
119
+ content = self.fillCommonParam(line,params)
120
+ end
121
+ file.puts content
122
+ end
123
+
124
+ if line =~ /\#Furion\#start-/
125
+ target = getTagFromExampleStartLabel(line)
126
+ if keys.include?(target)
127
+ puts "start recording"+target
128
+ inRecording = true
129
+ end
130
+ end
131
+ end
132
+ end
133
+
54
134
 
55
135
 
136
+ def self.fillCommonParam(code,params)
137
+ for key in params.keys
138
+ varStr = "$FurionVar_"+key
139
+ if code.include? varStr
140
+ puts "found "+varStr
141
+ var = varStr
142
+ if params[key].class == String
143
+ var = "@\""+params[key]+"\""
144
+ else
145
+ var = String(params[key])
146
+ end
147
+
148
+ result = code.sub(varStr,var)
149
+ puts "edit "+ result
150
+ return result
151
+ end
152
+ end
153
+ return code
154
+ end
155
+
156
+ def self.getTagFromExampleStartLabel(codeString)
157
+ # #Furion#start-[paramInit_common]
158
+ # removePre = codeString.tr("#Furion#start-[paramInit_", "")
159
+ # removeTail = removePre.tr("]","")
160
+ puts codeString.length
161
+ target = codeString[25,(codeString.length - 27)]
162
+ puts "target "+target
163
+ return target
56
164
  end
57
165
  end
58
166
 
data/lib/furion.rb CHANGED
@@ -19,15 +19,21 @@ class Furion
19
19
  def self.makeConfig
20
20
  self.fetchFile("GenConfig.py")
21
21
  self.fetchFile("furionpod")
22
+ self.fetchFile("example.code")
22
23
  result = `python GenConfig.py `
23
24
  File.write('data.json', result)
24
25
  puts "finish writting"
25
26
  FileEditor.editPodfile
26
27
  `plutil -convert xml1 data.json -o MTPSDK.plist`
28
+ File.delete('GenConfig.py')
27
29
  File.delete('data.json')
28
- puts "Config finished, run 'pod install' to continue "
30
+ FileEditor.insertExampleCode
31
+ File.delete('example.code')
32
+ `pod install`
33
+ projName = FileEditor.getCuriOSProjName
34
+ puts "Config finished, run "+projName+".xcworkspace to continue "
29
35
  end
30
36
  end
31
- Furion.makeConfig
32
37
 
38
+ Furion.makeConfig
33
39
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: furion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MTP Huya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-24 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: MTP Huya is the best!!!
14
14
  email: mtphuya@yandex.com