ffi-gphoto2 0.5.1 → 0.6.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/CHANGELOG.md +20 -0
- data/README.md +19 -10
- data/examples/autofocus.rb +21 -0
- data/examples/capture.rb +8 -0
- data/examples/continuous_burst.rb +27 -0
- data/examples/list_config.rb +1 -0
- data/examples/list_files.rb +52 -0
- data/ffi-gphoto2.gemspec +3 -3
- data/lib/ffi/gphoto2.rb +10 -1
- data/lib/ffi/gphoto2/camera_abilities_list.rb +1 -1
- data/lib/ffi/gphoto2/camera_file_info.rb +10 -0
- data/lib/ffi/gphoto2/camera_file_info_audio.rb +11 -0
- data/lib/ffi/gphoto2/camera_file_info_fields.rb +14 -0
- data/lib/ffi/gphoto2/camera_file_info_file.rb +15 -0
- data/lib/ffi/gphoto2/camera_file_info_preview.rb +13 -0
- data/lib/ffi/gphoto2/camera_file_permissions.rb +9 -0
- data/lib/ffi/gphoto2/camera_file_status.rb +7 -0
- data/lib/ffi/gphoto2/camera_list.rb +1 -1
- data/lib/ffi/gphoto2/camera_widget.rb +1 -1
- data/lib/ffi/gphoto2_port/gp_port_info_list.rb +1 -1
- data/lib/gphoto2.rb +23 -2
- data/lib/gphoto2/camera.rb +9 -1
- data/lib/gphoto2/camera/capture.rb +22 -0
- data/lib/gphoto2/camera/configuration.rb +1 -0
- data/lib/gphoto2/camera/event.rb +3 -6
- data/lib/gphoto2/camera_abilities.rb +9 -0
- data/lib/gphoto2/camera_file.rb +25 -7
- data/lib/gphoto2/camera_file_info/camera_file_info.rb +52 -0
- data/lib/gphoto2/camera_file_info/file_camera_file_info.rb +30 -0
- data/lib/gphoto2/camera_widgets/camera_widget.rb +2 -6
- data/lib/gphoto2/camera_widgets/radio_camera_widget.rb +0 -4
- data/lib/gphoto2/camera_widgets/text_camera_widget.rb +1 -3
- data/lib/gphoto2/entry.rb +0 -4
- data/lib/gphoto2/port_info.rb +0 -4
- data/lib/gphoto2/version.rb +1 -1
- data/spec/gphoto2/camera_abilities_spec.rb +23 -0
- data/spec/gphoto2/camera_file_info/file_camera_file_info_spec.rb +56 -0
- data/spec/gphoto2/camera_file_spec.rb +17 -0
- data/spec/gphoto2/camera_spec.rb +11 -5
- data/spec/gphoto2_spec.rb +18 -0
- data/spec/support/shared_examples/camera/capture_examples.rb +13 -0
- data/spec/support/shared_examples/camera/configuration_examples.rb +26 -18
- data/spec/support/shared_examples/camera_file_info_examples.rb +42 -0
- metadata +29 -8
@@ -75,5 +75,22 @@ module GPhoto2
|
|
75
75
|
expect(file.size).to eq(data_and_size.last)
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
describe '#info' do
|
80
|
+
context 'the file is a preview' do
|
81
|
+
it 'returns nil' do
|
82
|
+
file = CameraFile.new(camera)
|
83
|
+
expect(file.info).to be(nil)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'the file is a file' do
|
88
|
+
it 'it returns an instance of FileCameraFileInfo' do
|
89
|
+
file = CameraFile.new(camera, folder, name)
|
90
|
+
allow(file).to receive(:get_info).and_return(FileCameraFileInfo.new(nil))
|
91
|
+
expect(file.info).to be_kind_of(FileCameraFileInfo)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
78
95
|
end
|
79
96
|
end
|
data/spec/gphoto2/camera_spec.rb
CHANGED
@@ -126,18 +126,24 @@ module GPhoto2
|
|
126
126
|
let(:operations) { FFI::GPhoto2::CameraOperation[:capture_image] }
|
127
127
|
|
128
128
|
before do
|
129
|
-
allow(camera).to receive_message_chain(:abilities, :
|
129
|
+
allow(camera).to receive_message_chain(:abilities, :operations).and_return(operations)
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'when the camera has the ability to perform an operation' do
|
133
|
+
it 'returns true' do
|
134
|
+
expect(camera.can?(:capture_image)).to be(true)
|
135
|
+
end
|
130
136
|
end
|
131
137
|
|
132
138
|
context 'when the camera does not have the ability perform an operation' do
|
133
|
-
it '
|
139
|
+
it 'returns false' do
|
134
140
|
expect(camera.can?(:capture_audio)).to be(false)
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
138
|
-
context '
|
139
|
-
it 'returns
|
140
|
-
expect(camera.can?(:
|
144
|
+
context 'an invalid operation is given' do
|
145
|
+
it 'returns false' do
|
146
|
+
expect(camera.can?(:dance)).to be(false)
|
141
147
|
end
|
142
148
|
end
|
143
149
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GPhoto2 do
|
4
|
+
describe '.check!' do
|
5
|
+
context 'the return code is not GP_OK' do
|
6
|
+
it 'raises GPhoto2::Error with a message and error code' do
|
7
|
+
code = -1
|
8
|
+
message = "Unspecified error (#{code})"
|
9
|
+
|
10
|
+
expect { GPhoto2.check!(code) }.to raise_error do |e|
|
11
|
+
expect(e).to be_kind_of(GPhoto2::Error)
|
12
|
+
expect(e.message).to eq(message)
|
13
|
+
expect(e.code).to eq(code)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -19,6 +19,19 @@ module GPhoto2
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe '#trigger' do
|
23
|
+
let(:camera) { Camera.new(model, port) }
|
24
|
+
|
25
|
+
before do
|
26
|
+
allow(camera).to receive(:trigger_capture)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'saves the camera configuration' do
|
30
|
+
expect(camera).to receive(:save)
|
31
|
+
camera.trigger
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
describe '#preview' do
|
23
36
|
let(:camera) { Camera.new(model, port) }
|
24
37
|
let(:file) { double('camera_file') }
|
@@ -65,29 +65,37 @@ module GPhoto2
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#[]=' do
|
68
|
-
let(:
|
69
|
-
window = double('camera_widget')
|
70
|
-
expect(window).to receive(:value=).with(400)
|
71
|
-
window
|
72
|
-
end
|
68
|
+
let(:camera) { Camera.new(model, port) }
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
allow(camera).to receive(:[]).and_return(window)
|
77
|
-
camera
|
78
|
-
end
|
70
|
+
context 'when the specified key is valid' do
|
71
|
+
let(:window) { double('camera_widget', :value= => 400) }
|
79
72
|
|
80
|
-
|
81
|
-
|
82
|
-
|
73
|
+
before do
|
74
|
+
allow(camera).to receive(:[]).and_return(window)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "sets a widget's value" do
|
78
|
+
camera['iso'] = 400
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'marks the camera as dirty' do
|
82
|
+
camera['iso'] = 400
|
83
|
+
expect(camera).to be_dirty
|
84
|
+
end
|
83
85
|
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
it 'returns the passed value' do
|
87
|
+
expect(camera['iso'] = 400).to eq(400)
|
88
|
+
end
|
87
89
|
end
|
88
90
|
|
89
|
-
|
90
|
-
|
91
|
+
context 'when the specified key is invalid' do
|
92
|
+
before do
|
93
|
+
allow(camera).to receive(:[]).and_return(nil)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'raises an ArgumentError' do
|
97
|
+
expect { camera['flavor'] = 'strawberry' }.to raise_error(ArgumentError)
|
98
|
+
end
|
91
99
|
end
|
92
100
|
end
|
93
101
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
shared_examples_for GPhoto2::CameraFileInfo do
|
2
|
+
let(:camera_file_info) do
|
3
|
+
OpenStruct.new(
|
4
|
+
fields: 0xff,
|
5
|
+
status: :not_downloaded,
|
6
|
+
size: 7355608,
|
7
|
+
type: 'image/jpeg'
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:info) { described_class.new(camera_file_info) }
|
12
|
+
|
13
|
+
describe '#fields' do
|
14
|
+
it 'returns a bit field of set fields' do
|
15
|
+
expect(info.fields).to eq(0xff)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#has_field?' do
|
20
|
+
it 'returns whether a field is set' do
|
21
|
+
expect(info.has_field?(:size)).to be(true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#status' do
|
26
|
+
it 'returns the file status' do
|
27
|
+
expect(info.status).to eq(:not_downloaded)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#size' do
|
32
|
+
it 'returns the filesize' do
|
33
|
+
expect(info.size).to eq(7355608)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#type' do
|
38
|
+
it 'returns the file type' do
|
39
|
+
expect(info.type).to eq('image/jpeg')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-gphoto2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Macias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.5.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
54
|
+
version: 3.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.9.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.9.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ffi
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,19 +82,25 @@ dependencies:
|
|
82
82
|
version: 1.9.0
|
83
83
|
description:
|
84
84
|
email:
|
85
|
-
-
|
85
|
+
- zaeleus@gmail.com
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
92
94
|
- Gemfile
|
93
95
|
- LICENSE.txt
|
94
96
|
- README.md
|
95
97
|
- Rakefile
|
98
|
+
- examples/autofocus.rb
|
99
|
+
- examples/capture.rb
|
100
|
+
- examples/continuous_burst.rb
|
96
101
|
- examples/intervalometer.rb
|
97
102
|
- examples/list_config.rb
|
103
|
+
- examples/list_files.rb
|
98
104
|
- examples/live_view.rb
|
99
105
|
- examples/record_movie.rb
|
100
106
|
- ffi-gphoto2.gemspec
|
@@ -107,8 +113,15 @@ files:
|
|
107
113
|
- lib/ffi/gphoto2/camera_event_type.rb
|
108
114
|
- lib/ffi/gphoto2/camera_file.rb
|
109
115
|
- lib/ffi/gphoto2/camera_file_access_type.rb
|
116
|
+
- lib/ffi/gphoto2/camera_file_info.rb
|
117
|
+
- lib/ffi/gphoto2/camera_file_info_audio.rb
|
118
|
+
- lib/ffi/gphoto2/camera_file_info_fields.rb
|
119
|
+
- lib/ffi/gphoto2/camera_file_info_file.rb
|
120
|
+
- lib/ffi/gphoto2/camera_file_info_preview.rb
|
110
121
|
- lib/ffi/gphoto2/camera_file_operation.rb
|
111
122
|
- lib/ffi/gphoto2/camera_file_path.rb
|
123
|
+
- lib/ffi/gphoto2/camera_file_permissions.rb
|
124
|
+
- lib/ffi/gphoto2/camera_file_status.rb
|
112
125
|
- lib/ffi/gphoto2/camera_file_type.rb
|
113
126
|
- lib/ffi/gphoto2/camera_folder_operation.rb
|
114
127
|
- lib/ffi/gphoto2/camera_list.rb
|
@@ -133,6 +146,8 @@ files:
|
|
133
146
|
- lib/gphoto2/camera_abilities_list.rb
|
134
147
|
- lib/gphoto2/camera_event.rb
|
135
148
|
- lib/gphoto2/camera_file.rb
|
149
|
+
- lib/gphoto2/camera_file_info/camera_file_info.rb
|
150
|
+
- lib/gphoto2/camera_file_info/file_camera_file_info.rb
|
136
151
|
- lib/gphoto2/camera_file_path.rb
|
137
152
|
- lib/gphoto2/camera_folder.rb
|
138
153
|
- lib/gphoto2/camera_list.rb
|
@@ -154,6 +169,7 @@ files:
|
|
154
169
|
- lib/gphoto2/version.rb
|
155
170
|
- spec/gphoto2/camera_abilities_list_spec.rb
|
156
171
|
- spec/gphoto2/camera_abilities_spec.rb
|
172
|
+
- spec/gphoto2/camera_file_info/file_camera_file_info_spec.rb
|
157
173
|
- spec/gphoto2/camera_file_path_spec.rb
|
158
174
|
- spec/gphoto2/camera_file_spec.rb
|
159
175
|
- spec/gphoto2/camera_folder_spec.rb
|
@@ -168,11 +184,13 @@ files:
|
|
168
184
|
- spec/gphoto2/entry_spec.rb
|
169
185
|
- spec/gphoto2/port_info_list_spec.rb
|
170
186
|
- spec/gphoto2/port_info_spec.rb
|
187
|
+
- spec/gphoto2_spec.rb
|
171
188
|
- spec/spec_helper.rb
|
172
189
|
- spec/support/shared_examples/camera/capture_examples.rb
|
173
190
|
- spec/support/shared_examples/camera/configuration_examples.rb
|
174
191
|
- spec/support/shared_examples/camera/event_examples.rb
|
175
192
|
- spec/support/shared_examples/camera/filesystem_examples.rb
|
193
|
+
- spec/support/shared_examples/camera_file_info_examples.rb
|
176
194
|
- spec/support/shared_examples/camera_widget_examples.rb
|
177
195
|
homepage: https://github.com/zaeleus/ffi-gphoto2
|
178
196
|
licenses:
|
@@ -195,13 +213,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
213
|
requirements:
|
196
214
|
- libgphoto2 >= 2.5.0
|
197
215
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.4
|
216
|
+
rubygems_version: 2.6.4
|
199
217
|
signing_key:
|
200
218
|
specification_version: 4
|
201
219
|
summary: A Ruby FFI for common functions in libgphoto2
|
202
220
|
test_files:
|
203
221
|
- spec/gphoto2/camera_abilities_list_spec.rb
|
204
222
|
- spec/gphoto2/camera_abilities_spec.rb
|
223
|
+
- spec/gphoto2/camera_file_info/file_camera_file_info_spec.rb
|
205
224
|
- spec/gphoto2/camera_file_path_spec.rb
|
206
225
|
- spec/gphoto2/camera_file_spec.rb
|
207
226
|
- spec/gphoto2/camera_folder_spec.rb
|
@@ -216,10 +235,12 @@ test_files:
|
|
216
235
|
- spec/gphoto2/entry_spec.rb
|
217
236
|
- spec/gphoto2/port_info_list_spec.rb
|
218
237
|
- spec/gphoto2/port_info_spec.rb
|
238
|
+
- spec/gphoto2_spec.rb
|
219
239
|
- spec/spec_helper.rb
|
220
240
|
- spec/support/shared_examples/camera/capture_examples.rb
|
221
241
|
- spec/support/shared_examples/camera/configuration_examples.rb
|
222
242
|
- spec/support/shared_examples/camera/event_examples.rb
|
223
243
|
- spec/support/shared_examples/camera/filesystem_examples.rb
|
244
|
+
- spec/support/shared_examples/camera_file_info_examples.rb
|
224
245
|
- spec/support/shared_examples/camera_widget_examples.rb
|
225
246
|
has_rdoc:
|