whee 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/whee.rb +39 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae47499005066bd2f7972e45d154d2cc7aee5825f7d642577a5b4632064aba6e
4
- data.tar.gz: '08dcfa8319fe3e17b3cc8474a72ed83f11d6cb98276350fe3ac3691954ebb9a3'
3
+ metadata.gz: 31d6c5100e2dcd46a7afcafc93f89c54431fd52b823b5b22a9ba7d095758c97d
4
+ data.tar.gz: 4aef7eb4bdb25cccafc333453ecf21863466e659096c627ab40f8e14b4b30237
5
5
  SHA512:
6
- metadata.gz: 89ebc82e7fb75d08d7708a457c29eda5c71df00b50f97ad7a0d87c72fe38ff08acecc88788f73b7600539ecf16aa226c1b6fdf8877a512a3b829c2ec9bbe4541
7
- data.tar.gz: ef5679070676f46b80322ff90cfc664d06fca61d6a0b102f97e47691cae5e7bf0865c06b6782bf2c576c21cb3134c98043f0ef7baf57c069b8db65b0d64a600e
6
+ metadata.gz: 5ceb0010433f37a430e941479d23c2b570647aa55264af7bf4e6b6fe253a6b32a69ed50478d227e757388154efa0109a5f23dac4ad8a1d79803ede9ca4cf7705
7
+ data.tar.gz: e6858ec92921d0a36e7e78628b8b8a282a84374ee8654de1805fe4f5db69ad97a520e64eaf8bd1a3845c623852f56f6869c800288b61b8e958cd6b09726c71ad
data/lib/whee.rb CHANGED
@@ -25,10 +25,47 @@ class Main
25
25
  end.parse!(into: @@options)
26
26
  end
27
27
 
28
+ # checks whether current directory is a wpilib project
29
+ def wpilib_proj?
30
+ File.exist?(".\\.wpilib\\wpilib_preferences.json")
31
+ end
32
+
33
+ # sets default options based on ./.wpilib/wpilib_preferences.json
34
+ def wpilib_pref
35
+ require 'json'
36
+
37
+ # no error checking because this method is only called after `wpilib_proj?`
38
+ preferences = JSON.parse(File.read(".\\.wpilib\\wpilib_preferences.json"))
39
+
40
+ @@options[:year] = preferences["projectYear"]
41
+ @@options[:team] = preferences["teamNumber"]
42
+ end
43
+
44
+ # refresh list of networks available
45
+ def netsh_refresh
46
+ # disconnect from current to force refresh
47
+ %x(netsh wlan disconnect)
48
+
49
+ # sleep until refresh
50
+ sleep 3
51
+ end
52
+
28
53
  def run
54
+ # ensure wpilib project
55
+ if !wpilib_proj?
56
+ puts "File '.\\.wpilib\\wpilib_preferences.json' not found."
57
+ exit(1)
58
+ else
59
+ # set options from wpilib proj
60
+ wpilib_pref
61
+ end
62
+
29
63
  # run command line options parser
30
64
  parse_options
31
65
 
66
+ # refresh list of networks
67
+ netsh_refresh
68
+
32
69
  # output of netsh
33
70
  networks = %x(netsh wlan show networks).lines.filter do |line|
34
71
  # check if line is a network ssid
@@ -60,7 +97,7 @@ class Main
60
97
  # exit if no robot network to connect to
61
98
  if networks.empty?
62
99
  puts "No robot network found to connect to."
63
- exit(2)
100
+ exit(1)
64
101
  end
65
102
 
66
103
  # index of desired network
@@ -103,7 +140,7 @@ class Main
103
140
  end
104
141
 
105
142
  # year for jdk location
106
- year = (@@options[:year].nil?) ? Time.now.year.to_s : @@options[:year]
143
+ year = @@options[:year] || Time.now.year.to_s
107
144
  dir = "C:\\Users\\Public\\wpilib\\#{year}\\jdk"
108
145
 
109
146
  # check if jdk exists
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ell Torek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-25 00:00:00.000000000 Z
11
+ date: 2022-05-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  whee is a command-line program to accelerate the GradleRIO deploy process used in the