ligo 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.1.2 / 2013-11-14
2
+
3
+ * Add Windows support
4
+ * Improve the accessory_mode? method for devices which expose the Google vendorId even when not in accessory mode
5
+
1
6
  ### 0.1.1 / 2013-04-13
2
7
 
3
8
  * Fix a major issue due to bad refactoring (get_device should return to device)
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  <!--- coding: utf-8; fill-column: 80 --->
2
- # ligō
2
+ # ![ligō](https://github.com/nibua-r/ligo-logos/raw/master/logo/ligo.png)
3
3
 
4
+ [![Dependency Status](https://gemnasium.com/nibua-r/ligo.png)](https://gemnasium.com/nibua-r/ligo)
4
5
  [![Code Climate](https://codeclimate.com/github/nibua-r/ligo.png)](https://codeclimate.com/github/nibua-r/ligo)
5
6
 
6
7
  * [Homepage](https://github.com/nibua-r/ligo#readme)
@@ -65,7 +66,7 @@ ligō will be nothing without the
65
66
 
66
67
  At the time of writing, ligō focuses on the GNU/Linux operating system and
67
68
  YARV/MRI ruby. ligō has been developed and tested on Debian GNU/Linux with ruby
68
- 1.9.3p327.
69
+ 1.9.3p327 and 1.9.3p429.
69
70
 
70
71
  ligō is useless without Android-side application. A
71
72
  [sample LigoTextDemo Android application](https://github.com/nibua-r/LigoTextDemo)
@@ -87,11 +88,11 @@ Or, you can install it from the github repository:
87
88
  ## Pending tasks
88
89
 
89
90
  * Write the specs and automate testing!
90
- * <s>Provide an Android demo application</s> → See
91
+ * ~~Provide an Android demo application~~ → See
91
92
  [sample LigoTextDemo Android application](https://github.com/nibua-r/LigoTextDemo),
92
93
  more to come soon…
93
94
  * Improve the documentation → in progress, a first pass has been made…
94
- * <s>Release and push the gem to rubygems.org</s>
95
+ * ~~Release and push the gem to rubygems.org~~
95
96
  * Finalize and publish a [celluloid](https://github.com/celluloid/celluloid)-based write-back usage
96
97
  sample (already working with the
97
98
  [sample LigoTextDemo Android application](https://github.com/nibua-r/LigoTextDemo) and the
data/Rakefile CHANGED
@@ -4,17 +4,19 @@ require 'rubygems'
4
4
  require 'rake'
5
5
 
6
6
  begin
7
- gem 'rubygems-tasks', '~> 0.2'
7
+ gem 'rubygems-tasks', '~> 0.2.4'
8
8
  require 'rubygems/tasks'
9
9
 
10
- Gem::Tasks.new
10
+ Gem::Tasks.new do |tasks|
11
+ tasks.console.command = 'pry'
12
+ end
11
13
  rescue LoadError => e
12
14
  warn e.message
13
15
  warn "Run `gem install rubygems-tasks` to install Gem::Tasks."
14
16
  end
15
17
 
16
18
  begin
17
- gem 'rspec', '~> 2.4'
19
+ gem 'rspec', '~> 2.13'
18
20
  require 'rspec/core/rake_task'
19
21
 
20
22
  RSpec::Core::RakeTask.new
@@ -28,7 +30,7 @@ task :test => :spec
28
30
  task :default => :spec
29
31
 
30
32
  begin
31
- gem 'yard', '~> 0.8'
33
+ gem 'yard', '~> 0.8.5.2'
32
34
  require 'yard'
33
35
 
34
36
  YARD::Rake::YardocTask.new
@@ -40,7 +42,7 @@ end
40
42
  task :doc => :yard
41
43
 
42
44
  begin
43
- gem 'yardstick', '~> 0.8.0'
45
+ gem 'yardstick', '~> 0.9.5'
44
46
 
45
47
  require 'yardstick/rake/measurement'
46
48
 
data/bin/ligo-sample CHANGED
@@ -12,7 +12,15 @@ id = {
12
12
  serial: '3678000012345678'
13
13
  }
14
14
 
15
- Ligo::Logging.configure_logger_output('/tmp/ligo-sample.log')
15
+ log_file = 'ligo-sample.log'
16
+ log_file_path = case Ligo.os
17
+ when :windows
18
+ ENV['TEMP']
19
+ else # :unix, :linux and :macosx
20
+ '/tmp'
21
+ end
22
+
23
+ Ligo::Logging.configure_logger_output("#{log_file_path}/#{log_file}")
16
24
  ctx = Ligo::Context.new
17
25
  acc = Ligo::Accessory.new(id)
18
26
  dev = ctx.devices.first
data/lib/ligo.rb CHANGED
@@ -34,4 +34,25 @@ module Ligo
34
34
  require 'ligo/accessory'
35
35
  require 'ligo/context'
36
36
  require 'ligo/device'
37
+
38
+ # Return the OS identifier
39
+ # @return [Symbol] one of :windows, :macosx, :linux or :unix.
40
+ # @raise [StandardError] if the OS is unknown.
41
+ def self.os
42
+ @os ||= (
43
+ host_os = RbConfig::CONFIG['host_os']
44
+ case host_os
45
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
46
+ :windows
47
+ when /darwin|mac os/
48
+ :macosx
49
+ when /linux/
50
+ :linux
51
+ when /solaris|bsd/
52
+ :unix
53
+ else
54
+ raise StandardError, "unknown os: #{host_os.inspect}"
55
+ end
56
+ )
57
+ end
37
58
  end
data/lib/ligo/device.rb CHANGED
@@ -182,7 +182,7 @@ module Ligo
182
182
  logger.debug 'start_accessory_mode'
183
183
  sn = self.serial_number
184
184
 
185
- self.open_interface(0) do |handle|
185
+ self.open do |handle|
186
186
  @handle = handle
187
187
  send_accessory_id
188
188
  send_start
@@ -220,7 +220,7 @@ module Ligo
220
220
  # @return [true, false] true if the {Device} is in accessory mode, false
221
221
  # otherwise.
222
222
  def accessory_mode?
223
- self.idVendor == GOOGLE_VID
223
+ (self.idVendor == GOOGLE_VID) && (GOOGLE_PIDS.include? self.idProduct)
224
224
  end
225
225
 
226
226
  # Check if the current {Device} supports AOAP
@@ -228,8 +228,13 @@ module Ligo
228
228
  # otherwise.
229
229
  def aoap?
230
230
  @aoap_version = self.get_protocol
231
- logger.info "#{self.inspect} supports AOAP version #{@aoap_version}."
232
- @aoap_version >= 1
231
+ aoap_supported = (@aoap_version >= 1)
232
+ if aoap_supported
233
+ logger.info "#{self.inspect} supports AOA Protocol version #{@aoap_version}."
234
+ else
235
+ logger.info "#{self.inspect} doesn't support AOA Protocol."
236
+ end
237
+ aoap_supported
233
238
  end
234
239
 
235
240
  # Check if the current {Device} is in UMS mode
@@ -266,6 +271,8 @@ module Ligo
266
271
  end
267
272
 
268
273
  (res.size == 2 && version >= 1 ) ? version : 0
274
+ rescue LIBUSB::ERROR_NOT_SUPPORTED, LIBUSB::ERROR_PIPE
275
+ 0
269
276
  end
270
277
 
271
278
  # Sends identifying string information to the device
data/lib/ligo/version.rb CHANGED
@@ -17,5 +17,5 @@
17
17
 
18
18
  module Ligo
19
19
  # ligō version
20
- VERSION = "0.1.1"
20
+ VERSION = "0.1.2"
21
21
  end
data/ligo.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.add_development_dependency 'rspec', '~> 2.13'
25
25
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2.4'
26
- gem.add_development_dependency 'yard', '~> 0.8.5.2'
26
+ gem.add_development_dependency 'yard', '~> 0.8.7.2'
27
27
  gem.add_development_dependency 'yardstick', '~> 0.9.5'
28
28
  gem.add_development_dependency 'pry', '~> 0.9.12'
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ligo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-13 00:00:00.000000000 Z
12
+ date: 2013-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: libusb
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 0.8.5.2
69
+ version: 0.8.7.2
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 0.8.5.2
77
+ version: 0.8.7.2
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: yardstick
80
80
  requirement: !ruby/object:Gem::Requirement