mac-wifi 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2bce9a95ee880536f6e3672191ed7d343b1eafcf
4
- data.tar.gz: 10aeeddeb2bc4bf946a65d9709b2306ea8567ed9
2
+ SHA256:
3
+ metadata.gz: 033044a27585d2cb3a3e4920879921e77d91b661021c054118ff273c24386df0
4
+ data.tar.gz: 23cf93fcfb0dfef2130347c84fd53f78cc84a1a4b5cd54a7e0d864704aa60027
5
5
  SHA512:
6
- metadata.gz: 04224a7842e14437d0de854e6bc9566901893c547b73e4ca581b159d92816bf789d3235919b8593fdf74b32e9cfebfe7c14f7974498a268117eafeb37a0eb785
7
- data.tar.gz: 5b8db8d42cb1b0284dc61d0557030ffa49f2bc3987f8272ccef93fa23d40be2553346635a9f996941a7fa2f2f19f351687c0fb2855203f6f2c8da5a5493c07b3
6
+ metadata.gz: ff355af46081bf8377ad2347a6052f9387fe8ae0940c25e74da67bfc654f8c1cfe866a7e19ae8d1628ab108e7250f5b7f51a8bd3222129abcf32db6de0ccdfed
7
+ data.tar.gz: f2a4e67ebba29752fa85caf06f81fdc633c54af2bde9ccea34df4e5fa13e913bf9b6dadab7f1b7b2d47d81ba65e4097e881b5b740b1008918ba417d1a6cac8a6
data/README.md CHANGED
@@ -1,20 +1,24 @@
1
1
  # mac-wifi
2
2
 
3
- The `mac-wifi` script installed by this gem (or otherwise copied) enables the query and management of wifi configuration and environment on a Mac.
4
- The code encapsulates the Mac OS specific logic in a minimal class to more easily add support for other operating systems,
3
+ To install this software, run:
4
+
5
+ `gem install mac-wifi`
6
+
7
+ or, you may need to precede that command with `sudo`:
8
+
9
+ `sudo gem install mac-wifi`
10
+
11
+ The `mac-wifi` script installed by this gem enables the query and management
12
+ of wifi configuration and environment on a Mac.
13
+ The code encapsulates the Mac OS specific logic in a minimal class
14
+ to more easily add support for other operating systems,
5
15
  but as of now, only Mac OS is supported. (Feel free to add an OS!)
6
16
 
7
- It can be run in single-command or interactive mode. Interactive mode uses the [pry](https://github.com/pry/pry) gem,
17
+ It can be run in single-command or interactive mode.
18
+ Interactive mode uses the [pry](https://github.com/pry/pry) gem,
8
19
  providing an interface familiar to Rubyists and other
9
20
  [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) users.
10
21
 
11
- It is not necessary to download this repo or even install this gem; the `bin/mac-wifi`
12
- script file is all you need to run the application. There are many ways to install it
13
- in this way; one way is by changing into the directory
14
- where you would like to save the script, and running:
15
-
16
- `curl -o mac-wifi https://raw.githubusercontent.com/keithrbennett/macwifi/master/exe/mac-wifi && chmod +x mac-wifi`
17
-
18
22
 
19
23
  ### Usage
20
24
 
@@ -24,7 +28,7 @@ output at the time of this writing:
24
28
  ```
25
29
  $ mac-wifi h
26
30
 
27
- Command Line Switches: [mac-wifi version 2.0.0]
31
+ Command Line Switches: [mac-wifi version 2.1.0]
28
32
 
29
33
  -o[i,j,p,y] - outputs data in inspect, JSON, puts, or YAML format when not in shell mode
30
34
  -s - run in shell mode
@@ -47,17 +51,17 @@ pa[ssword] network-name - password for preferred network-name
47
51
  pr[ef_nets] - preferred (not necessarily available) networks
48
52
  q[uit] - exits this program (interactive shell mode only) (see also 'x')
49
53
  r[m_pref_nets] network-name - removes network-name from the preferred networks list
50
- (can provide multiple names separated by spaces)
54
+ (can provide multiple names separated by spaces)
51
55
  s[hell] - opens an interactive pry shell (command line only)
52
56
  t[ill] - returns when the desired Internet connection state is true. Options:
53
- 1) 'on'/:on, 'off'/:off, 'conn'/:conn, or 'disc'/:disc
54
- 2) wait interval, in seconds (optional, defaults to 0.5 seconds)
57
+ 1) 'on'/:on, 'off'/:off, 'conn'/:conn, or 'disc'/:disc
58
+ 2) wait interval, in seconds (optional, defaults to 0.5 seconds)
55
59
  w[ifion] - is the wifi on?
56
60
  x[it] - exits this program (interactive shell mode only) (see also 'q')
57
61
 
58
62
  When in interactive shell mode:
59
- * use quotes for string parameters such as method names.
60
- * for pry commands, use prefix `%`.
63
+ * use quotes for string parameters such as method names.
64
+ * for pry commands, use prefix `%`.
61
65
  ```
62
66
 
63
67
  Internally, it uses several Mac command line utilities. This is not ideal,
@@ -79,16 +83,17 @@ You may need to precede this command with `sudo `, especially if you are using t
79
83
  version of Ruby that comes packaged with MacOS.
80
84
 
81
85
 
82
- ### JSON and YAML Output
86
+ ### JSON, YAML, and Other Output Formats
83
87
 
84
- You can specify that output in _noninteractive_ mode be in JSON or YAML formats
85
- by specifying `-j` or `-y` on the command line, respectively.
88
+ You can specify that output in _noninteractive_ mode be in a certain format.
89
+ Currently, JSON, YAML, inspect, and puts formats are supported.
90
+ See the help for which command line switches to use.
86
91
 
87
92
 
88
93
  ### Seeing the Underlying OS Commands and Output
89
94
 
90
95
  If you would like to see the Mac OS commands and their output,
91
- you can do so by specifying "-v" on the command line.
96
+ you can do so by specifying "-v" (for _verbose) on the command line.
92
97
 
93
98
  You may notice that some commands are executed more than once. This is to simplify the application logic
94
99
  and eliminate the need for the complexity of balancing the speed that a cache offers and the risk
@@ -120,15 +125,16 @@ mac-wifi till conn && \
120
125
  say -v Kyoko "Connected to my network."
121
126
  ```
122
127
 
123
- (The `say` command supports all kinds of accents that are fun to play around with.
128
+ (The Mac OS `say` command supports all kinds of accents that are fun to play around with.
124
129
  You can get a list of all of them by running `say -v "?"`)
125
130
 
131
+
126
132
  ### Using the Shell
127
133
 
128
- **If the program immediately exits when you try to run the shell, try upgrading `pry` and `pry-byebug`.
129
- This can be done by running `gem install pry; gem install pry-byebug`.**
134
+ _If the program immediately exits when you try to run the shell, try upgrading `pry` and `pry-byebug`.
135
+ This can be done by running `gem install pry; gem install pry-byebug`._
130
136
 
131
- The shell, invoked with the `s` command on the command line, provides an interactive
137
+ The shell, invoked with the `-s` switch on the command line, provides an interactive
132
138
  session. It can be useful when:
133
139
 
134
140
  * you want to issue multiple commands
@@ -136,7 +142,7 @@ session. It can be useful when:
136
142
  * you want the data in a format not provided by this application
137
143
  * you want to incorporate these commands into other Ruby code interactively
138
144
  * you want to combine the results of commands with other OS commands
139
- (you can shell out to run other command line programs by preceding the command with a period (`.`).
145
+ (you can shell out to run other command line programs by preceding the command with a period (`.`)) .
140
146
 
141
147
 
142
148
  ### Using Variables in the Shell
@@ -185,20 +191,20 @@ the result may be mysterious. For example, if I were write the wifi information
185
191
  to a file, this would work:
186
192
 
187
193
  ```
188
- [1] pry(#<MacWifiView>)> File.write('x.txt', info)
194
+ [1] pry(#<MacWifiView>)> File.write('x', info)
189
195
  => 431
190
196
  ```
191
197
 
192
- However, if I forget to quote the filename:
198
+ However, if I forget to quote the filename, the program exits:
193
199
 
194
200
  ```
195
- [2] pry(#<MacWifiView>)> File.write(x.txt, info)
201
+ [2] pry(#<MacWifiView>)> File.write(x, info)
196
202
  ➜ mac-wifi git:(master) ✗ 
197
203
  ```
198
204
 
199
- What happened? `x.txt` was assumed by Ruby to be a method name.
200
- `method_missing` was called, and since `x.txt` starts with `x`,
201
- the exit method was called, exiting the program.
205
+ What happened? `x` was assumed by Ruby to be a method name.
206
+ `method_missing` was called, and since `x` is the exit
207
+ command, the program exited.
202
208
 
203
209
  Bottom line is, be careful to quote your strings, and you're probably better off using
204
210
  constants or instance variables if you want to create variables in your shell.
@@ -223,8 +229,10 @@ mac-wifi t on && say "Internet connected" # Play audible message when Internet b
223
229
  #### Interactive Shell Commands
224
230
 
225
231
  When in shell mode, commands generally return the target object (e.g. the array of
226
- available networks) rather than outputting a nicely formatted string. This may result
227
- in the shell outputting that returned value in an ugly way.
232
+ available networks) rather than outputting a nicely formatted string.
233
+ This is intentional, so that you can compose expressions and in general
234
+ have maximum flexibility. The result may be that `pry` displays
235
+ that returned value in an ugly way.
228
236
 
229
237
  If you don't need the return value but just want to display the value nicely,
230
238
  you can use the `fancy_puts` method to output it nicely. An alias `fp` has been
@@ -239,17 +247,34 @@ provided for your convenience. You're welcome! For example:
239
247
  ]
240
248
  ```
241
249
 
242
- If you want to surpress output altogether (e.g. if you are using the value in an
243
- expression and don't need to print it out, you can simply append `;nil` to the expression
244
- and that will be value output to the console. For example:
250
+ For best display results, be sure `awesome_print` is `gem install`ed.
251
+ The program will silently use a not-as-nice formatter without it.
252
+ (This silence is intentional, so that users who don't want to install
253
+ `awesome-print` will not be bothered.)
254
+
255
+ If you want to suppress output altogether (e.g. if you are using the value in an
256
+ expression and don't need to see it displayed,
257
+ you can simply append `;nil` to the expression
258
+ and `nil` will be value output to the console. For example:
245
259
 
246
260
  ```
247
261
  [10] pry(#<MacWifi::CommandLineInterface>)> available_networks = avail_nets; nil
248
262
  => nil
249
- [11] pry(#<MacWifi::CommandLineInterface>)> avail_nets.size
250
- => 32
251
263
  ```
252
264
 
265
+ #### Using the Models Without the Command Line Interface
266
+
267
+ The code has been structured so that you can call the models
268
+ from your own Ruby code, bypassing the command line interface.
269
+ Here is an example of how to do that:
270
+
271
+ ```ruby
272
+ require 'mac-wifi'
273
+ model = MacWifi::MacOsModel.new
274
+ puts model.available_network_names.to_yaml # etc...
275
+ ```
276
+
277
+
253
278
  **More Examples**
254
279
 
255
280
  (For brevity, semicolons are used here to put multiple commands on one line,
@@ -296,27 +321,9 @@ Connected!
296
321
  ```
297
322
 
298
323
 
299
- ### Distribution, or Why All The Code is in One Humongous File
300
-
301
- This code would be neater and easier to read if each class were in a file of its own.
302
- The reason everything is in one file is to simplify distribution for some users.
303
- Although installation as a gem is simple, being able to download a single file may work better when:
324
+ ### Dependent Gems
304
325
 
305
- * the user wants to install the script once, rather than once per Ruby version and/or gemset.
306
- * the user needs or wants to specify the exact location of the script (e.g. `~/bin`),
307
- and/or does not want it buried in the gem directory tree (e.g. `/Users/kbennett/.rvm/gems/ruby-2.4.0/bin/mac-wifi`).
308
- * the user is not familiar with Ruby and does not want to use the `gem` command
309
- * the user is concerned about security and would prefer to install a single file to a known location
310
- rather than run the gem installation
311
- * installing gems is controlled by the user's organization, and getting authorization is not practical
312
- * installing gems requires root access, and the user does not have root access
313
-
314
- That said, installation as a gem is highly recommended, since:
315
-
316
- * this will greatly simplify acquiring future fixes and enhancements
317
- * if the user wants to use the shell mode, they will need to `gem install pry` anyway
318
-
319
- Currently, the only gems used by the program are:
326
+ Currently, the only gems used directly by the program are:
320
327
 
321
328
  * `pry`, to provide the interactive shell
322
329
  * `awesome_print` (optional), to more nicely format output in non-interactive mode
@@ -324,6 +331,7 @@ Currently, the only gems used by the program are:
324
331
  So the user can avoid installing gems altogether as long as they don't need to use the interactive shell,
325
332
  and as long as they are comfortable with the less pretty output.
326
333
 
334
+
327
335
  ### Password Lookup Oddity
328
336
 
329
337
  You may find it odd (I did, anyway) that even if you issue the password command
@@ -352,4 +360,4 @@ MIT License (see LICENSE.txt)
352
360
 
353
361
  I am available for consulting, development, tutoring, training, troubleshooting, etc.
354
362
 
355
- You can contact me via GMail, Twitter, and Github as _keithrbennett_.
363
+ You can contact me via GMail, Twitter, Github, and LinkedIn, as _keithrbennett_.
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v2.1.0
2
+
3
+ * Support for the single script file install has been dropped. It was requiring too much complexity,
4
+ and was problematic with Ruby implementations lacking GEM_HOME / GEM_PATH environment variables.
5
+ * Code was broken out of the single script file into class files, plus a `version.rb`
6
+ and `mac-wifi.rb` file.
7
+
8
+
1
9
  ## v2.0.0
2
10
 
3
11
  * Support output formats in batch mode: JSON, YAML, puts, and inspect modes.