sonycam 1.3.1 → 1.3.2

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
  SHA1:
3
- metadata.gz: 2ce94eb6c341f619ef65191b765a3a79bd86a241
4
- data.tar.gz: ded56c7cc81ef457d55c4ba62a4dacc7f5065206
3
+ metadata.gz: 7d111ba16847fff6b8e6dae447b02ae9a9ec0fff
4
+ data.tar.gz: 89ff24db3ea892420a1bc52ae995b006b3e4fc3f
5
5
  SHA512:
6
- metadata.gz: c0b1038851747875aa94fca082ec67701781a3921c70062bc5d1a267ffa3f410175352a1cae734f97c554051d5130eddd0a7ad6ff19062e0c0818f7f5831b712
7
- data.tar.gz: 654765f80967c3c7bf0fdba9c0e0072f215675de383f13114c08a492698b5c74e26f9d75bd502d72583b7aeb5b4727f64eb5b6580e96b3fe49418a3323f58e77
6
+ metadata.gz: 30f57b2cde854524aadd0db65ea03219a02a72f996882ac85f9eaa79a43a285e3515fef22d9e6d026707e5613102c95ac34b8fd69662b5d7b409d89440d9be79
7
+ data.tar.gz: bb3c910f893622909a3c30ed83ff27b447563bdeefbedb5ef3a25839f32bfdeec0be8438a7328ca1536517873638df96caa35b34f785cea255ffe8e4a0b566c1
@@ -14,7 +14,7 @@ module Sonycam
14
14
  ret = JSON.parse(@http.request_post(@uri.path, json).body)
15
15
  if ret['error']
16
16
  error_code, error_message = ret['error']
17
- raise Sonycam::Error.new_from_code(error_code), error_message
17
+ raise Sonycam::Error.make(error_code), error_message
18
18
  else
19
19
  ret['result']
20
20
  end
@@ -21,12 +21,12 @@ module Sonycam
21
21
  # Hush, it's a secret, don't tell anyone.
22
22
  if @camera_name == 'DSC-RX100M2'
23
23
  url = @api_url_hash[type].sub('sony', 'camera')
24
- puts "DSC-RX100M2 detected, API URL \"#{url}\" was used insteadly."
24
+ puts "DSC-RX100M2 detected, API URL \"#{url}\" is used insteadly."
25
25
  return url
26
26
  end
27
27
 
28
28
  if action_list_url = @api_url_hash[type] then "#{action_list_url}/#{type}"
29
- else raise "Can't not find service type \"#{type}\"."
29
+ else raise "Can not find service type \"#{type}\"."
30
30
  end
31
31
  end
32
32
  end
@@ -34,7 +34,7 @@ module Sonycam
34
34
  const_set error_name, Class.new(StandardError)
35
35
  end
36
36
 
37
- def self.new_from_code code
37
+ def self.make code
38
38
  const_get(MAPPING[code])
39
39
  end
40
40
  end
@@ -13,17 +13,17 @@ module Sonycam
13
13
  buf = ''.force_encoding('BINARY')
14
14
  commen_header = nil
15
15
  payload_header = nil
16
- response.read_body do |chunk|
16
+ response.read_body do |chunk|
17
17
  buf += chunk
18
18
  until buf.empty?
19
19
  case state
20
20
  when :commen_header # 8 bytes
21
21
  break if buf.size < 8
22
- commen_header = buf.slice!(0, 8).unpack('H2CnN')
22
+ commen_header = buf.slice!(0, 8).unpack('aanN')
23
23
  state = :payload_header
24
24
  when :payload_header # 128 bytes
25
25
  break if buf.size < 128
26
- payload_header = buf.slice!(0, 128).unpack('H8H6CH8CH*')
26
+ payload_header = buf.slice!(0, 128).unpack('a4H6Ca4aa*')
27
27
  state = :payload_data
28
28
  when :payload_data
29
29
  jpeg_data_size = payload_header[1].to_i(16)
@@ -34,7 +34,6 @@ module Sonycam
34
34
  state = :commen_header
35
35
  yield Packet.new(commen_header, payload_header, jpeg_data, padding_data)
36
36
  end # case state
37
- # gets
38
37
  end # until buf.empty?
39
38
  end # response.read_body do |chunk|
40
39
  end # http.request request do |response|
@@ -3,26 +3,26 @@ module Sonycam
3
3
  def initialize commen_header, payload_header, jpeg_data, padding_data
4
4
  @packet = {
5
5
  commen_header: {
6
- start_byte: commen_header[0], # hex, fixed "FF"
7
- payload_type: commen_header[1], # int
8
- sequence_number: commen_header[2], # int
9
- time_stamp: commen_header[3] # int
6
+ start_byte: commen_header[0], # hex, fixed "FF"
7
+ payload_type: commen_header[1], # int
8
+ sequence_number: commen_header[2], # int
9
+ time_stamp: commen_header[3] # int
10
10
  },
11
11
  payload_header: {
12
- star_code: payload_header[0], # hex, fixed "24356879"
13
- jpeg_data_size: payload_header[1].to_i(16), # int
14
- padding_size: payload_header[2], # int
15
- reserved: payload_header[3], # hex
16
- flag: payload_header[4], # int, fixed "00"
12
+ star_code: payload_header[0], # hex, fixed "24356879"
13
+ jpeg_data_size: payload_header[1].hex, # int
14
+ padding_size: payload_header[2], # int
15
+ reserved: payload_header[3], # hex
16
+ flag: payload_header[4], # int, fixed "00"
17
17
  reserved_2: payload_header[5]
18
-
19
18
  },
20
19
  payload_data: {
21
20
  jpeg_data: jpeg_data,
22
21
  padding_data: padding_data
23
- },
22
+ }
24
23
  }
25
24
  end
25
+
26
26
  def [] key
27
27
  @packet[key]
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module Sonycam
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sonycam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Jian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor