ant-wireless 0.1.0.pre.20210715102740 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,141 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'spec_helper'
5
+
6
+ require 'ant/bitvector'
7
+
8
+
9
+ RSpec.describe( Ant::BitVector ) do
10
+
11
+ context 'when first instantiated' do
12
+
13
+ it "is empty when created without arguments" do
14
+ v = described_class.new
15
+ expect( v.to_i ).to eq( 0 )
16
+ expect( v.size ).to eq( 1 )
17
+ end
18
+
19
+
20
+ it "accepts a decimal argument" do
21
+ v = described_class.new( 242 )
22
+ expect( v.to_hex ).to eq( '0x00f2' )
23
+ end
24
+
25
+
26
+ it "accepts a hexadecimal argument" do
27
+ v = described_class.new( 0x00f2 )
28
+ expect( v.to_i ).to eq( 242 )
29
+ end
30
+
31
+
32
+ it "accepts a bit string argument" do
33
+ v = described_class.new( 0b11110010 )
34
+ expect( v.to_i ).to eq( 242 )
35
+ end
36
+
37
+
38
+ it "accepts a different BitVector argument" do
39
+ v = described_class.new( described_class.new( 242 ) )
40
+ expect( v.to_i ).to eq( 242 )
41
+ end
42
+
43
+
44
+ it "accepts a string argument" do
45
+ v = described_class.new( "242" )
46
+ expect( v.to_i ).to eq( 242 )
47
+ end
48
+
49
+
50
+ it "rejects objects that don't have a 'to_i' method" do
51
+ expect {
52
+ described_class.new( Class )
53
+ }.to raise_error( ArgumentError, /don't know what to do/i )
54
+ end
55
+
56
+ end
57
+
58
+
59
+ context 'after modified with a value' do
60
+
61
+ let( :bv ) { described_class.new( 242 ) }
62
+
63
+
64
+ it "can be converted into various formats" do
65
+ expect( bv.to_int ).to eq( 242 )
66
+ expect( bv.to_hex ).to eq( '0x00f2' )
67
+ expect( bv.to_bin ).to eq( '0b11110010' )
68
+ end
69
+
70
+
71
+ it "knows the size of its own bit string" do
72
+ expect( bv.size ).to eq( 8 )
73
+ bv.toggle( 9 )
74
+ expect( bv.size ).to eq( 10 )
75
+ end
76
+
77
+
78
+ it "can switch specific bits on and off" do
79
+ expect( bv.on?( 12 ) ).to be_falsey
80
+
81
+ bv.on( 12 )
82
+ expect( bv[12] ).to be_truthy
83
+
84
+ bv.off( 12 )
85
+ expect( bv.off?( 12 ) ).to be_truthy
86
+
87
+ bv[12] = true
88
+ expect( bv.on?( 12 ) ).to be_truthy
89
+ end
90
+
91
+
92
+ it "can set bits in a range" do
93
+ expect( bv[ 8] ).to be_falsey
94
+ expect( bv[ 9] ).to be_falsey
95
+ expect( bv[10] ).to be_falsey
96
+ expect( bv[11] ).to be_falsey
97
+ expect( bv[12] ).to be_falsey
98
+
99
+ bv[8..12] = true
100
+
101
+ expect( bv[ 8] ).to be_truthy
102
+ expect( bv[ 9] ).to be_truthy
103
+ expect( bv[10] ).to be_truthy
104
+ expect( bv[11] ).to be_truthy
105
+ expect( bv[12] ).to be_truthy
106
+ end
107
+
108
+
109
+ it "delegates math operations to the underlying integer" do
110
+ bv2 = described_class.new( 4112 )
111
+
112
+ bv3 = bv + bv2
113
+ expect( bv3.to_int ).to eq( 4354 )
114
+
115
+ bv3 = bv | bv2
116
+ expect( bv3.to_int ).to eq( 4338 )
117
+
118
+ bv3 = bv & bv2
119
+ expect( bv3.to_int ).to eq( 16 )
120
+
121
+ expect( bv3 ).to be_a( described_class )
122
+ end
123
+
124
+
125
+ it "can compare different bitvector objects" do
126
+ bv1 = described_class.new( bv )
127
+ bv2 = described_class.new( 4112 )
128
+ expect( bv ).to eq( bv1 )
129
+ expect( bv ).to be < bv2
130
+ end
131
+
132
+
133
+ it "is enumerable" do
134
+ bits = bv.to_a
135
+ expect( bits ).to eq( [0, 1, 0, 0, 1, 1, 1, 1] )
136
+ end
137
+
138
+ end
139
+
140
+ end
141
+
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,8 @@ RSpec.configure do |config|
20
20
  Ant.init
21
21
  Ant.close
22
22
  rescue => err
23
+ $stderr.puts "%p while initializing hardware: %s; disabling hardware specs" %
24
+ [ err.class, err.message ]
23
25
  config.filter_run_excluding( :hardware )
24
26
  end
25
27
 
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,15 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ant-wireless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.20210715102740
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
8
8
  - Mahlon E. Smith
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain: []
12
- date: 2021-07-15 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIID+DCCAmCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
15
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMDEyMjQyMDU1MjlaFw0yMTEyMjQyMDU1
16
+ MjlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
17
+ hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
18
+ L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
19
+ M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
20
+ 5PU2AEbf04GGSrmqADGWXeaslaoRdb1fu/0M5qfPTRn5V39sWD9umuDAF9qqil/x
21
+ Sl6phTvgBrG8GExHbNZpLARd3xrBYLEFsX7RvBn2UPfgsrtvpdXjsHGfpT3IPN+B
22
+ vQ66lts4alKC69TE5cuKasWBm+16A4aEe3XdZBRNmtOu/g81gvwA7fkJHKllJuaI
23
+ dXzdHqq+zbGZVSQ7pRYHYomD0IiDe1DbIouFnPWmagaBnGHwXkDT2bKKP+s2v21m
24
+ ozilJg4aar2okb/RA6VS87o+d7g6LpDDMMQjH4G9OPnJENLdhu8KnPw/ivSVvQw7
25
+ N2I4L/ZOIe2DIVuYH7aLHfjZDQv/mNgpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
26
+ VR0PBAQDAgSwMB0GA1UdDgQWBBRyjf55EbrHagiRLqt5YAd3yb8k4DANBgkqhkiG
27
+ 9w0BAQsFAAOCAYEAMYegZanJi8zq7QKPT7wqXefX4C88I5JWeBHR3PvvWK0CwyMV
28
+ peyiu5I13w/lYX+HUZjE4qsSpJMJFXWl4WZCOo+AMprOcf0PxfuJpxCej5D4tavf
29
+ vRfhahSw7XJrcZih/3J+/UgoH7R05MJ+8LTcy3HGrB3a0vTafjm8OY7Xpa0LJDoN
30
+ JDqxK321VIHyTibbKeA1hWSE6ljlQDvFbTqiCj3Ulp1jTv3TOlvRl8fqcfhxUJI0
31
+ +5Q82jJODjEN+GaWs0V+NlrbU94cXwS2PH5dXogftB5YYA5Ex8A0ikZ73xns4Hdo
32
+ XxdLdd92F5ovxA23j/rKe/IDwqr6FpDkU3nPXH/Qp0TVGv9zZnVJc/Z6ChkuWj8z
33
+ pW7JAyyiiHZgKKDReDrA2LA7Zs3o/7KA6UtUH0FHf8LYhcK+pfHk6RtjRe65ffw+
34
+ MCh97sQ/Z/MOusb5+QddBmB+k8EicXyGNl4b5L4XpL7fIQu+Y96TB3JEJlShxFD9
35
+ k9FjI4d9EP54gS/4
36
+ -----END CERTIFICATE-----
37
+ date: 2021-09-30 00:00:00.000000000 Z
13
38
  dependencies:
14
39
  - !ruby/object:Gem::Dependency
15
40
  name: rake-compiler
@@ -39,6 +64,20 @@ dependencies:
39
64
  - - "~>"
40
65
  - !ruby/object:Gem::Version
41
66
  version: '0.10'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rdoc-generator-fivefish
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.4'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '0.4'
42
81
  description: A binding for the ANT ultra-low power wireless protocol via the Garmin
43
82
  USB ANT Stick. ANT can be used to send information wirelessly from one device to
44
83
  another device, in a robust and flexible manner.
@@ -65,7 +104,9 @@ files:
65
104
  - ext/ant_ext/message.c
66
105
  - ext/ant_ext/types.h
67
106
  - ext/ant_ext/version.h
107
+ - lib/ant-wireless.rb
68
108
  - lib/ant.rb
109
+ - lib/ant/bitvector.rb
69
110
  - lib/ant/channel.rb
70
111
  - lib/ant/channel/event_callbacks.rb
71
112
  - lib/ant/message.rb
@@ -73,16 +114,17 @@ files:
73
114
  - lib/ant/response_callbacks.rb
74
115
  - lib/ant/wireless.rb
75
116
  - spec/ant_spec.rb
117
+ - spec/bitvector_spec.rb
76
118
  - spec/spec_helper.rb
77
119
  homepage: https://sr.ht/~ged/ruby-ant-wireless/
78
120
  licenses:
79
121
  - BSD-3-Clause
80
122
  metadata:
81
- bug_tracker_uri: https://todo.sr.ht/~ged/ruby-ant-wireless
82
- changelog_uri: https://deveiate.org/code/ant-wireless/History_md.html
83
- documentation_uri: https://deveiate.org/code/ant-wireless
84
123
  homepage_uri: https://sr.ht/~ged/ruby-ant-wireless/
124
+ documentation_uri: https://deveiate.org/code/ant-wireless
125
+ changelog_uri: https://deveiate.org/code/ant-wireless/History_md.html
85
126
  source_uri: https://hg.sr.ht/~ged/ruby-ant-wireless
127
+ bug_tracker_uri: https://todo.sr.ht/~ged/ruby-ant-wireless
86
128
  post_install_message:
87
129
  rdoc_options: []
88
130
  require_paths:
@@ -94,9 +136,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
136
  version: '0'
95
137
  required_rubygems_version: !ruby/object:Gem::Requirement
96
138
  requirements:
97
- - - ">"
139
+ - - ">="
98
140
  - !ruby/object:Gem::Version
99
- version: 1.3.1
141
+ version: '0'
100
142
  requirements: []
101
143
  rubygems_version: 3.1.6
102
144
  signing_key:
metadata.gz.sig ADDED
Binary file