wpa_cli_web 0.0.8 → 0.0.9
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.
- data/Rakefile +7 -0
- data/lib/wpa_cli_web/access_point_list.rb +23 -6
- data/test/wpa_cli_web/access_point_list_test.rb +28 -0
- data/wpa_cli_web.gemspec +2 -1
- metadata +20 -2
    
        data/Rakefile
    CHANGED
    
    
| @@ -7,12 +7,29 @@ class AccessPointList | |
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              def access_points
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                  flatten.
         | 
| 10 | 
            +
                  strongest_unique_ssids_sorted_alphabetically
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              def strongest_unique_ssids_sorted_alphabetically
         | 
| 14 | 
            +
                strongest_unique_ssids.
         | 
| 16 15 | 
             
                  sort_by { |network| network.ssid }
         | 
| 17 16 | 
             
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def strongest_unique_ssids
         | 
| 19 | 
            +
                network_groups.
         | 
| 20 | 
            +
                  map {|network_group| network_group.sort_by { |network| network.signal_level}.reverse.take(1)}.
         | 
| 21 | 
            +
                  flatten
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def network_groups
         | 
| 25 | 
            +
                access_points_grouped_by_ssid.map {|ssid, network_group| network_group}
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def access_points_grouped_by_ssid
         | 
| 29 | 
            +
                access_points_with_an_ssid.group_by {|network| network.ssid}
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              def access_points_with_an_ssid
         | 
| 33 | 
            +
                @access_points.reject { |network| network.ssid.nil? }
         | 
| 34 | 
            +
              end
         | 
| 18 35 | 
             
            end
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require 'minitest/autorun'
         | 
| 2 | 
            +
            require 'wpa_cli_ruby'
         | 
| 3 | 
            +
            require 'mocha'
         | 
| 4 | 
            +
            require_relative '../../lib/wpa_cli_web/access_point_list.rb'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            describe AccessPointList do
         | 
| 7 | 
            +
              before do
         | 
| 8 | 
            +
                mock_wrapper = stub()
         | 
| 9 | 
            +
                mock_wrapper.expects(:scan).returns("Selected interface 'wlan0'\nOK\n")
         | 
| 10 | 
            +
                response = <<-eos
         | 
| 11 | 
            +
            Selected interface 'wlan0'
         | 
| 12 | 
            +
            bssid / frequency / signal level / flags / ssid
         | 
| 13 | 
            +
            12:34:56:78:aa:bb	2437	-47	[WPA-EAP-TKIP][WPA2-EAP-CCMP][ESS]	z_ssid
         | 
| 14 | 
            +
            12:34:56:78:bb:cc	2412	-57	[WPA2-PSK-CCMP][ESS]	a_ssid
         | 
| 15 | 
            +
            43:34:56:78:bb:cc	2412	-87	[WPA-EAP-TKIP][WPA2-EAP-CCMP][ESS]	z_ssid
         | 
| 16 | 
            +
            eos
         | 
| 17 | 
            +
                mock_wrapper.expects(:scan_results).returns(response)
         | 
| 18 | 
            +
                @access_point_list = AccessPointList.new(WpaCliRuby::WpaCli.new(mock_wrapper))
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              describe "access_points" do
         | 
| 22 | 
            +
                it "returns a list of unique, strongest access points sorted alphabetically" do
         | 
| 23 | 
            +
                  assert_equal 2, @access_point_list.access_points.size
         | 
| 24 | 
            +
                  assert_equal "a_ssid", @access_point_list.access_points[0].ssid
         | 
| 25 | 
            +
                  assert_equal "z_ssid", @access_point_list.access_points[1].ssid
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
    
        data/wpa_cli_web.gemspec
    CHANGED
    
    | @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
| 4 4 |  | 
| 5 5 | 
             
            Gem::Specification.new do |spec|
         | 
| 6 6 | 
             
              spec.name          = "wpa_cli_web"
         | 
| 7 | 
            -
              spec.version       = "0.0. | 
| 7 | 
            +
              spec.version       = "0.0.9"
         | 
| 8 8 | 
             
              spec.authors       = ["Chris Lowis", "Andrew Nicolaou"]
         | 
| 9 9 | 
             
              spec.email         = ["chris.lowis@gmail.com"]
         | 
| 10 10 | 
             
              spec.description   = %q{Web interface for configuring wifi using wpa_cli}
         | 
| @@ -24,4 +24,5 @@ Gem::Specification.new do |spec| | |
| 24 24 |  | 
| 25 25 | 
             
              spec.add_development_dependency "bundler", "~> 1.3"
         | 
| 26 26 | 
             
              spec.add_development_dependency "rake"
         | 
| 27 | 
            +
              spec.add_development_dependency "mocha"
         | 
| 27 28 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: wpa_cli_web
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.9
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -92,6 +92,22 @@ dependencies: | |
| 92 92 | 
             
                - - ! '>='
         | 
| 93 93 | 
             
                  - !ruby/object:Gem::Version
         | 
| 94 94 | 
             
                    version: '0'
         | 
| 95 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 96 | 
            +
              name: mocha
         | 
| 97 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 98 | 
            +
                none: false
         | 
| 99 | 
            +
                requirements:
         | 
| 100 | 
            +
                - - ! '>='
         | 
| 101 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            +
                    version: '0'
         | 
| 103 | 
            +
              type: :development
         | 
| 104 | 
            +
              prerelease: false
         | 
| 105 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 106 | 
            +
                none: false
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ! '>='
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 95 111 | 
             
            description: Web interface for configuring wifi using wpa_cli
         | 
| 96 112 | 
             
            email:
         | 
| 97 113 | 
             
            - chris.lowis@gmail.com
         | 
| @@ -219,6 +235,7 @@ files: | |
| 219 235 | 
             
            - lib/wpa_cli_web/views/networks_edit.erb
         | 
| 220 236 | 
             
            - lib/wpa_cli_web/views/restart.erb
         | 
| 221 237 | 
             
            - lib/wpa_cli_web/views/restarting.erb
         | 
| 238 | 
            +
            - test/wpa_cli_web/access_point_list_test.rb
         | 
| 222 239 | 
             
            - wpa_cli_web.gemspec
         | 
| 223 240 | 
             
            homepage: ''
         | 
| 224 241 | 
             
            licenses:
         | 
| @@ -245,5 +262,6 @@ rubygems_version: 1.8.23 | |
| 245 262 | 
             
            signing_key: 
         | 
| 246 263 | 
             
            specification_version: 3
         | 
| 247 264 | 
             
            summary: Web interface for configuring wifi using wpa_cli
         | 
| 248 | 
            -
            test_files: | 
| 265 | 
            +
            test_files:
         | 
| 266 | 
            +
            - test/wpa_cli_web/access_point_list_test.rb
         | 
| 249 267 | 
             
            has_rdoc: 
         |