Module: Dfb

Defined in:
lib/dfb.rb,
lib/dfb/version.rb

Overview

Add requires for other files you add to your project here, so you just need to require this one file in your bin file www.cnblogs.com/rubylouvre/archive/2011/04/04/2005122.html

Constant Summary collapse

VERSION =
'1.1.7'

Class Method Summary collapse

Class Method Details

.attachObject



61
62
63
64
65
66
67
# File 'lib/dfb.rb', line 61

def self.attach
   if self.isHasProject == false
       return
   end
   puts "执行 flutter attach"
   system self.cdPathWithFlutterModule + ";flutter attach;"
end

.cdPath(path) ⇒ Object



148
149
150
151
152
153
154
155
156
157
# File 'lib/dfb.rb', line 148

def self.cdPath(path)
   if PathManager.containsPath 
       puts '当前目录:'
       puts self.projectPath + path
       return "cd " + self.projectPath + path
   else
       puts "路径有错误"
       return ""
   end
end

.cdPathWithAndroidExampleObject



163
164
165
# File 'lib/dfb.rb', line 163

def self.cdPathWithAndroidExample
   self.cdPath("/android_example")
end

.cdPathWithFlutterModuleObject



159
160
161
# File 'lib/dfb.rb', line 159

def self.cdPathWithFlutterModule
   self.cdPath("/Embed/flutter_module")
end

.changePathObject



129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/dfb.rb', line 129

def self.changePath
   puts "如果您的工程是YDNativeFlutterBridge 路径是 /Users/chedch/YDDictFlutter/YDNativeFlutterBridge,则输入此路径"
   puts "请输入您的新的YDNativeFlutterBridge工程路径:"
   
   val = STDIN.gets
   if val =~ /(.*)\/YDNativeFlutterBridge/ 
       PathManager.inputPath(val.chop)
       return
   else
       puts "'change path' fails"
       return
   end
   
end

.checkEnvObject



94
95
96
97
# File 'lib/dfb.rb', line 94

def self.checkEnv 
   self.checkFlutter
   self.checkProject
end

.checkFlutterObject



99
100
101
102
103
104
105
106
107
# File 'lib/dfb.rb', line 99

def self.checkFlutter
   outputs = system 'flutter --version'
   if outputs == nil
       puts '安装flutter...'
       self.init_flutter
   else
       puts '已安装flutter环境'
   end 
end

.checkProjectObject



109
110
111
112
113
114
115
116
117
# File 'lib/dfb.rb', line 109

def self.checkProject
   outputs = system self.cdPathWithFlutterModule + ";"
   if outputs == false
       puts '工程已存在'
   else
       puts '正在下载工程..'
       self.clone
   end
end

.cloneObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dfb.rb', line 17

def self.clone
   puts "请输入您要放此工程的位置:"
   val = STDIN.gets
   val = val.chop
   path = val + "/YDNativeFlutterBridge"
   puts "您的工程的路径为" + val + path
   PathManager.inputPath(path)
   puts "git clone ..."

   system 'cd ' + val +'; git clone  [email protected]:luna-dev/YDNativeFlutterBridge.git;'
   system 'cd ' + path + ';git submodule init;git submodule update;'
end

.create_package(packageName) ⇒ Object



69
70
71
72
73
74
75
76
77
78
# File 'lib/dfb.rb', line 69

def self.create_package(packageName)
   if self.isHasProject == false
       return
   end
    self.checkEnv
    puts "创建flutter package"
    command = self.cdPathWithFlutterModule + "/Business;flutter create --template=package " + packageName
    p command
    system command
end

.flutter_cleanObject



87
88
89
90
91
92
# File 'lib/dfb.rb', line 87

def self.flutter_clean
   if self.isHasProject == false
       return
   end
     system self.cdPathWithFlutterModule + ";flutter clean;"
end

.helloObject

Your code goes here…



11
12
13
14
15
# File 'lib/dfb.rb', line 11

def self.hello
    p "hello world"
    system ('echo ' + outputs)
    system "echo hello world"
end

.init_flutterObject



30
31
32
33
34
35
36
# File 'lib/dfb.rb', line 30

def self.init_flutter
   puts "正在配置flutter环境"
   outputs = File.dirname(__FILE__)
   outputs = outputs.chop.chop.chop.chop #看到这行代码别骂作者,作者也不熟悉ruby,这个意思是说去除/lib
   puts outputs
   system "sh " + outputs + "/install_flutter_env.sh"
end

.isHasProjectObject



119
120
121
122
123
124
125
126
127
# File 'lib/dfb.rb', line 119

def self.isHasProject
   outputs = system self.cdPathWithFlutterModule + ";"
   if outputs == false
       puts '工程不存在'
       return false
   else
       return true
   end
end

.projectPathObject



144
145
146
# File 'lib/dfb.rb', line 144

def self.projectPath 
   return PathManager.outputPath
end

.pub_getObject



80
81
82
83
84
85
# File 'lib/dfb.rb', line 80

def self.pub_get
   if self.isHasProject == false
       return
   end
    system self.cdPathWithFlutterModule + ";sh flutter_pub_get.sh"
end

.run_androidObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/dfb.rb', line 47

def self.run_android
   #https://blog.csdn.net/tymatlab/article/details/80989769
   if self.isHasProject == false
       return
   end
   self.flutter_clean
   self.pub_get
   #打包
   system self.cdPathWithAndroidExample + ";./gradlew assembleDebug;"
   #装载,运行
   system self.cdPathWithAndroidExample + "/app/build/outputs/apk/debug/;adb install -r app-debug.apk;adb shell am start -n com.example.android_example/.MainActivity;"
    
end

.run_iosObject



38
39
40
41
42
43
44
45
# File 'lib/dfb.rb', line 38

def self.run_ios
   #ideviceinstaller https://www.jianshu.com/p/92273e86ab2b
   #  system "pod install"
   if self.isHasProject == false
       return
   end
   p "还没有实现"
end