ruby_wifi_scanner 0.1.4 → 0.1.5

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
2
  SHA256:
3
- metadata.gz: 11203ff609e63334559ff5c04eed2c29a2b85caa70e4630f09a03b88772e0cad
4
- data.tar.gz: a4320ffcacef6deeae4e6a500275d3fc3bb9e6c2a43cbe9700244cf4fe48607f
3
+ metadata.gz: 90daf1cf8fb63b5af08330c4685e5031792f730246a1579c4ca8f153ef48a5ec
4
+ data.tar.gz: 1dd0e27fe74cbe7a0e9ebb7ea7c94815ec79220569a442d350f0e7783c7f1285
5
5
  SHA512:
6
- metadata.gz: 5e80e9d9a207913568e254101a0214a29de4bd5da638081b8a186f990ba049ba4a1a74a3e900e836999444a974ff5c3dda226acb1235aaf0f8ce2076eb8aacd6
7
- data.tar.gz: 221981969a0c834a91f68d577deab8f6020d32189d2f553ecb14e4225c907d3b2b9d196493ded53e29a825b3d707ab8fca96ade4e748fa6235bf8b2a1cb4e763
6
+ metadata.gz: f0f46982d73459444588fb3eb40633f4b1efbac1d6bc93a92585825abe40679823546c185218dd7e43d59fd0662acdf540ad1964b707aa22feca99e2c510092a
7
+ data.tar.gz: 7b3b431f2a1cd63377d7b392ea99518f31e00e01ade356609b8215fc7cbbeaeb07c14edddff93dc79168524026771848d5c9a93cbbf009288593f42f310045c4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_wifi_scanner (0.1.4)
4
+ ruby_wifi_scanner (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruby_wifi_scanner"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,19 +1,27 @@
1
1
  module RubyWifiScanner
2
2
  class LinuxScanner < Scanner
3
-
4
3
  protected
5
4
 
6
5
  def parse
7
- res = raw_scan.split "\n"
8
- res[1..-1].map do |row|
9
- m = row.strip.match(/(?<level>-?[\d.]{4,6})\s+(?<rssi>[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2})\s*(?<ssid>\w+)?/i)
10
- WifiInfo.new(m[:ssid], m[:rssi], m[:level]) if m
6
+ scan = raw_scan.scan(/
7
+ ^BSS\s([a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2})
8
+ .+?
9
+ signal:\s([\d.-]+?)\sdBm$
10
+ .+?
11
+ SSID:\s(\w+?)$
12
+ /mx)
13
+
14
+ scan.map do |rssi,level,ssid|
15
+ WifiInfo.new(ssid, rssi, level)
11
16
  end
12
17
  end
13
18
 
14
19
  def raw_scan
15
- @raw_scan ||=
16
- %x{sudo iw dev $DEVICE scan | awk -f wlan_scan.awk | sort}
20
+ return @raw_scan if @raw_scan
21
+
22
+ device = ENV["DEVICE"] || 'wlan0'
23
+
24
+ @raw_scan = %x{sudo iw dev #{device} scan}
17
25
  end
18
26
  end
19
27
  end
@@ -1,3 +1,3 @@
1
1
  module RubyWifiScanner
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wifi_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uri Gorelik
@@ -82,6 +82,8 @@ files:
82
82
  - LICENSE.txt
83
83
  - README.md
84
84
  - Rakefile
85
+ - bin/console
86
+ - bin/setup
85
87
  - exe/rws
86
88
  - lib/ruby_wifi_scanner.rb
87
89
  - lib/ruby_wifi_scanner/linux_scanner.rb