vvtool 0.1.3 → 0.1.4

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
- SHA1:
3
- metadata.gz: 981351ccbf3b6a5f9d3ef72442bf39a1bd840e42
4
- data.tar.gz: 83a5df6b83dff552eb741e2aeee91803d212d54d
2
+ SHA256:
3
+ metadata.gz: 74ed4763ed8caa9579aeff4f6806856408bc82ab01ae397e34be317f94f0713f
4
+ data.tar.gz: 531a928af8d8f42a79846db6abc66abc04efd02449b7c6e35702245c451c98de
5
5
  SHA512:
6
- metadata.gz: 39e1e7b7936756acaf6cb6338da61d103e36c7d802447489212141129d16285716e1de0f17c1fbee399db1bad359ed5ffca6553fad85c7c521e107f9bfa9fd6d
7
- data.tar.gz: dc94ba76391e984eec238f8c68ded2800c053b5724b10b8dd31996a9888611270eb3a2b302df53bbdce4521f47a3933eada38249f64742f11b010daf7bf7059d
6
+ metadata.gz: 6f44f05746a501d8fb5296bdc2b63c8b3f8b81bac00fa9b032d91c0683938df389f66fb3a06c8f717de461b12ec6d2b5c9ea55bb6e3450b3025045ac53023ada
7
+ data.tar.gz: b0a8c34cdeb5950b15b0baaf294708ada8de017f4308ea98d6a41e6dcabe783fe6cbd7439a48be7a61f510f9f19f7c39dd685e3dd6d34bfef31fcbb97b8835c4
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9
4
+ - 2.3
5
+ - 2.5
6
+ - 2.6
7
+ before_install: rm Gemfile.lock
8
+ script: "rake build"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vvtool (0.1.2)
4
+ vvtool (0.1.4)
5
5
  listen (~> 3.0)
6
6
  rqrcode (~> 0.10.0)
7
7
  thor (~> 0.20)
@@ -33,4 +33,4 @@ DEPENDENCIES
33
33
  vvtool!
34
34
 
35
35
  BUNDLED WITH
36
- 1.16.3
36
+ 1.16.4
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # VVTool
2
-
3
- [![Gem](https://img.shields.io/gem/v/vvtool.svg)](https://rubygems.org/gems/vvtool)
1
+ # VVTool [![Build Status](https://travis-ci.org/isaced/VVTool.svg?branch=master)](https://travis-ci.org/isaced/VVTool) [![Gem](https://img.shields.io/gem/v/vvtool.svg)](https://rubygems.org/gems/vvtool)
4
2
 
5
3
  这是一个加速开发 Virtual View 模版的小脚本,让你能脱离繁重的开发环境 Xcode 和 Android Studio,只需一个轻量级的文本编辑器如 VSCode/Atom/SublimeText 即可开始进入开发,并且提供热加载能力,大大加速提高开发调试效率。
6
4
 
data/lib/live_server.rb CHANGED
@@ -10,6 +10,9 @@ require 'net/http'
10
10
  require 'socket'
11
11
  require 'rqrcode'
12
12
 
13
+ require_relative 'utils.rb'
14
+ require_relative "version_checker.rb"
15
+
13
16
  # 路径
14
17
  PropertiesFileName = 'templatelist.properties'
15
18
  ConfigPropertiesFileName = 'config.properties'
@@ -23,12 +26,18 @@ VVConfigPropertiesFilePath = File.join(TemplatesPath, ConfigPropertiesFileName)
23
26
  PropertiesFilePath = File.join(TemplatesPath, PropertiesFileName)
24
27
  DirFilePath = File.join(TemplatesPath, '.dir')
25
28
 
29
+ # VV 编译器下载地址 URL
26
30
  VVCompilerDownloadURL = 'https://raw.githubusercontent.com/alibaba/virtualview_tools/bb727ac668856732f66c3845b27646c1b4124fc8/compiler-tools/TemplateWorkSpace/compiler.jar'
31
+ # VV 默认的 config.properties 下载地址 URL
27
32
  VVConfigPropertiesDownloadURL = 'https://raw.githubusercontent.com/alibaba/virtualview_tools/bb727ac668856732f66c3845b27646c1b4124fc8/compiler-tools/TemplateWorkSpace/config.properties'
28
33
 
29
- LocalIP = Socket::getaddrinfo(Socket.gethostname,"echo",Socket::AF_INET)[0][3]
34
+ # 获取本机 IP
35
+ LocalIP = get_first_public_ipv4()
36
+
37
+ # HTTP 服务端口号
30
38
  HTTPServerPort = 7788
31
39
 
40
+ # 编译次数计数
32
41
  $buildCount = 1
33
42
 
34
43
  module VVPrepare
@@ -130,9 +139,11 @@ module VVPrepare
130
139
  end
131
140
 
132
141
  # 生成二维码
133
- qrcode = RQRCode::QRCode.new("http://#{LocalIP}:#{HTTPServerPort}/#{templateName}/data.json")
134
- qrcodeFilePath = File.join(aTemplatePath, "#{templateName}_QR.png")
135
- qrcode.as_png(file: qrcodeFilePath)
142
+ if LocalIP
143
+ qrcode = RQRCode::QRCode.new("http://#{LocalIP}:#{HTTPServerPort}/#{templateName}/data.json")
144
+ qrcodeFilePath = File.join(aTemplatePath, "#{templateName}_QR.png")
145
+ qrcode.as_png(file: qrcodeFilePath)
146
+ end
136
147
  }
137
148
 
138
149
  # 生成模版目录结构 .dir(HTTP Server 读取)
@@ -216,7 +227,7 @@ def live_server_run
216
227
  http_server.start
217
228
  }
218
229
 
219
- puts "Start HTTP server: http://#{LocalIP}:#{HTTPServerPort}"
230
+ puts "Start HTTP server: http://#{LocalIP || '127.0.0.1'}:#{HTTPServerPort}"
220
231
 
221
232
  # File Watch
222
233
  listener = Listen.to(TemplatesPath, only: [/\.xml$/, /\.json$/]) { |modified, added, removed|
@@ -247,6 +258,9 @@ def live_server_run
247
258
  exit 130
248
259
  end
249
260
 
261
+ # 从 RubyGems 上检查新版本
262
+ check_new_version
263
+
250
264
  sleep
251
265
  end
252
266
 
data/lib/utils.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'socket'
2
+
3
+ def get_first_public_ipv4
4
+ ip_info = Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and !intf.ipv4_private?}
5
+ ip_info.ip_address unless ip_info.nil?
6
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'net/http'
4
+ require 'json'
5
+ require_relative "vvtool/version.rb"
6
+
7
+ RubyGemsLatestVersionURL = 'https://rubygems.org/api/v1/versions/vvtool/latest.json'
8
+
9
+ def get_remote_version
10
+ begin
11
+ Thread.new {
12
+ response = Net::HTTP.get(URI(RubyGemsLatestVersionURL))
13
+ response = JSON.parse(response)
14
+ yield response['version']
15
+ }
16
+ end
17
+ end
18
+
19
+ def check_new_version
20
+ get_remote_version { |remoteVersion|
21
+ currentVersion = VVTool::VERSION
22
+ if currentVersion < remoteVersion
23
+ puts "VVTool 发现新版本 v#{remoteVersion}(当前 v#{currentVersion}),可以通过命令 `sudo gem install vvtool` 升级"
24
+ end
25
+ }
26
+ end
data/lib/vvtool.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require "vvtool/version"
4
- require "live_server.rb"
5
4
  require 'Thor'
6
5
 
6
+ require_relative "live_server.rb"
7
+
7
8
  module VVTool
8
9
  class CLI < Thor
9
10
  desc "run", "启动 VirtualView 实时预览服务"
@@ -1,3 +1,3 @@
1
1
  module VVTool
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vvtool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - isaced
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-03 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
+ - ".travis.yml"
92
93
  - Gemfile
93
94
  - Gemfile.lock
94
95
  - LICENSE.txt
@@ -96,6 +97,8 @@ files:
96
97
  - Rakefile
97
98
  - bin/vvtool
98
99
  - lib/live_server.rb
100
+ - lib/utils.rb
101
+ - lib/version_checker.rb
99
102
  - lib/vvtool.rb
100
103
  - lib/vvtool/version.rb
101
104
  - vvtool.gemspec
@@ -119,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
122
  version: '0'
120
123
  requirements: []
121
124
  rubyforge_project:
122
- rubygems_version: 2.5.1
125
+ rubygems_version: 2.7.6
123
126
  signing_key:
124
127
  specification_version: 4
125
128
  summary: VVTool - VirtualView 工具集.