kuro-rs 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 0.0.5 2011-10-31
2
+
3
+ * yield given block
4
+
1
5
  === 0.0.4 2011-10-31
2
6
 
3
7
  * fix broken data when write
@@ -6,6 +6,10 @@
6
6
 
7
7
  control KURO-RS (http://www.kuroutoshikou.com/modules/display/?iid=928) and PC-OP-RS1 (http://buffalo.jp/products/catalog/item/p/pc-op-rs1/)
8
8
 
9
+ == INSTALL:
10
+
11
+ * gem install kuro-rs
12
+
9
13
  == SYNOPSIS:
10
14
 
11
15
  require 'rubygems'
@@ -24,6 +28,14 @@ control KURO-RS (http://www.kuroutoshikou.com/modules/display/?iid=928) and PC-O
24
28
  # close
25
29
  kr.close
26
30
 
31
+ # block
32
+ KuroRs.open('/dev/tty.usbserial-0012a3b4'){|k|
33
+ k.verbose = true
34
+ puts k.read
35
+ ## => hex dump (ffffffff0300f0e0018083...)
36
+ }
37
+
38
+
27
39
 
28
40
  == TOOLS:
29
41
 
@@ -51,10 +63,6 @@ http interface
51
63
 
52
64
  * KURO-RS or PC-OP-RS1
53
65
 
54
- == INSTALL:
55
-
56
- * gem install kuro-rs
57
-
58
66
  == LICENSE:
59
67
 
60
68
  (The MIT License)
@@ -11,12 +11,7 @@ end
11
11
 
12
12
  device_name = ARGV.shift
13
13
 
14
- begin
15
- kr = KuroRs.open device_name
16
- rescue KuroRs::Error, StandardError => e
17
- STDERR.puts e
18
- exit 1
19
- end
20
-
21
- kr.verbose = true
22
- puts kr.read ## => hex dump
14
+ KuroRs.open(device_name){|k|
15
+ k.verbose = true
16
+ puts k.read ## => hex dump
17
+ }
@@ -10,5 +10,5 @@ Dir.glob(File.dirname(__FILE__)+'/kuro-rs/*.rb').each do |f|
10
10
  end
11
11
 
12
12
  module KuroRs
13
- VERSION = '0.0.4'
13
+ VERSION = '0.0.5'
14
14
  end
@@ -1,6 +1,15 @@
1
1
  module KuroRs
2
2
  def KuroRs.open(device_name)
3
- KuroRs.new(device_name)
3
+ kr = KuroRs.new(device_name)
4
+ if block_given?
5
+ begin
6
+ yield kr
7
+ ensure
8
+ kr.close
9
+ end
10
+ return nil
11
+ end
12
+ return kr
4
13
  end
5
14
 
6
15
  class Error < Exception
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuro-rs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sho Hashimoto