ffi-gphoto2 0.5.0 → 0.5.1
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/.rspec +0 -1
- data/README.md +68 -56
- data/examples/list_config.rb +1 -4
- data/ffi-gphoto2.gemspec +1 -1
- data/lib/gphoto2/camera/configuration.rb +17 -0
- data/lib/gphoto2/camera/event.rb +1 -1
- data/lib/gphoto2/camera.rb +2 -1
- data/lib/gphoto2/camera_widgets/camera_widget.rb +0 -2
- data/lib/gphoto2/camera_widgets/menu_camera_widget.rb +1 -1
- data/lib/gphoto2/version.rb +1 -1
- data/lib/gphoto2.rb +1 -1
- data/spec/gphoto2/camera_widgets/date_camera_widget_spec.rb +1 -1
- data/spec/gphoto2/camera_widgets/radio_camera_widget_spec.rb +1 -1
- data/spec/gphoto2/camera_widgets/range_camera_widget_spec.rb +1 -1
- data/spec/gphoto2/camera_widgets/text_camera_widget_spec.rb +1 -1
- data/spec/gphoto2/camera_widgets/toggle_camera_widget_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -0
- data/spec/support/shared_examples/camera_widget_examples.rb +3 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83f9c14b8b7006440420e875c32d4a93b809ce28
|
4
|
+
data.tar.gz: 9e3ccef87bc4565c88c4750e64d09ccde23f3330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d90104862dfccd44685aefa3870d83cde93e23a0aab57df6a7eb5a7feb2d9e712ca8c3125260b36f18b090df6ea8fce60726e913b667617f551180058c12397
|
7
|
+
data.tar.gz: f8536cef9cf2d3d7c9cfedb71fa0e7079280a7a7a0e7f579e1b886c4cba8e37e9316504e2298f1aabc0358638a3cd7f0ef5d20e5c87eee95ea4e15d82acef454
|
data/.rspec
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
**ffi-gphoto2** provides an FFI for common functions in [libgphoto2][1].
|
4
4
|
It also includes a facade to interact with the library in a more
|
5
|
-
|
5
|
+
idiomatic Ruby way.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -17,82 +17,94 @@ canonical Ruby way.
|
|
17
17
|
|
18
18
|
## Usage
|
19
19
|
|
20
|
-
|
20
|
+
```ruby
|
21
|
+
require 'gphoto2'
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
# list available cameras
|
24
|
+
cameras = GPhoto2::Camera.all
|
25
|
+
# => [#<GPhoto2::Camera>, ...]
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
# list found cameras by model and port path
|
28
|
+
cameras.map { |c| [c.model, c.port] }
|
29
|
+
# => [['Nikon DSC D5100 (PTP mode)', 'usb:250,006'], ...]
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
# use the first camera
|
32
|
+
camera = cameras.first
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
# ...or more conveniently
|
35
|
+
camera = GPhoto2::Camera.first
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
# ...or even search by model name
|
38
|
+
camera = GPhoto2::Camera.where(model: /nikon/i).first
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
# check camera abilities (see `FFI::GPhoto2::CameraOperation.symbols`)
|
41
|
+
camera.can? :capture_image
|
42
|
+
# => true
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
# list camera configuration names
|
45
|
+
camera.config.keys
|
46
|
+
# => ['autofocusdrive', 'manualfocusdrive', 'controlmode', ...]
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
# read the current configuration value of an option
|
49
|
+
camera['expprogram'].value
|
50
|
+
# => "M"
|
51
|
+
camera['whitebalance'].value
|
52
|
+
# => "Automatic"
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
# list valid choices of a configuration option
|
55
|
+
camera['whitebalance'].choices
|
56
|
+
# => ["Automatic", "Daylight", "Fluorescent", "Tungsten", ...]
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
# check if the configuration has changed
|
59
|
+
camera.dirty?
|
60
|
+
# => false
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
# change camera configuration
|
63
|
+
camera['iso'] = 800
|
64
|
+
camera['f-number'] = 'f/4.5'
|
65
|
+
camera['shutterspeed2'] = '1/30'
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
# check if the configuration has changed
|
68
|
+
camera.dirty?
|
69
|
+
# => true
|
67
70
|
|
68
|
-
|
69
|
-
|
71
|
+
# apply the new configuration to the device
|
72
|
+
camera.save
|
70
73
|
|
71
|
-
|
72
|
-
|
74
|
+
# alternatively, update the camera configuration in one go
|
75
|
+
camera.update(iso: 200, shutterspeed2: '1/60', 'f-number' => 'f/1.8')
|
73
76
|
|
74
|
-
|
75
|
-
|
77
|
+
# take a photo
|
78
|
+
file = camera.capture
|
76
79
|
|
77
|
-
|
78
|
-
|
80
|
+
# ...and save it to the current working directory
|
81
|
+
file.save
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
folder.files.map(&:name)
|
83
|
-
=> ["DSC_0001.JPG", "DSC_0002.JPG", ...]
|
83
|
+
# ...or to a specific pathname
|
84
|
+
file.save('/tmp/out.jpg')
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
file.save
|
86
|
+
# traverse the camera filesystem
|
87
|
+
folder = camera/'store_00010001/DCIM/100D5100'
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
# list files
|
90
|
+
files = folder.files
|
91
|
+
folder.files.map(&:name)
|
92
|
+
# => ["DSC_0001.JPG", "DSC_0002.JPG", ...]
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
+
# copy a file from the camera
|
95
|
+
file = files.first
|
96
|
+
file.save
|
94
97
|
|
95
|
-
|
98
|
+
# ...and then delete it from the camera
|
99
|
+
file.delete
|
100
|
+
|
101
|
+
# close the camera
|
102
|
+
camera.finalize
|
103
|
+
```
|
104
|
+
|
105
|
+
More examples can be found in [`examples/`][2]. YARD documentation can be
|
106
|
+
generated using the `rake yard` task or [browsed online][3].
|
96
107
|
|
97
108
|
[1]: http://www.gphoto.org/
|
98
109
|
[2]: https://github.com/zaeleus/ffi-gphoto2/tree/master/examples
|
110
|
+
[3]: http://www.rubydoc.info/gems/ffi-gphoto2/frames
|
data/examples/list_config.rb
CHANGED
@@ -15,9 +15,6 @@ def visit(widget, level = 0)
|
|
15
15
|
indent << ' '
|
16
16
|
|
17
17
|
puts "#{indent}type: #{widget.type}"
|
18
|
-
|
19
|
-
return if widget.type == :menu
|
20
|
-
|
21
18
|
puts "#{indent}value: #{widget.value}"
|
22
19
|
|
23
20
|
case widget.type
|
@@ -25,7 +22,7 @@ def visit(widget, level = 0)
|
|
25
22
|
range = widget.range
|
26
23
|
step = (range.size > 1) ? range[1] - range[0] : 1.0
|
27
24
|
puts "#{indent}options: #{range.first}..#{range.last}:step(#{step})"
|
28
|
-
when :radio
|
25
|
+
when :radio, :menu
|
29
26
|
puts "#{indent}options: #{widget.choices.inspect}"
|
30
27
|
end
|
31
28
|
end
|
data/ffi-gphoto2.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
26
|
spec.add_development_dependency 'rake'
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.2.0'
|
28
28
|
spec.add_development_dependency 'yard', '~> 0.8.7'
|
29
29
|
|
30
30
|
spec.add_dependency 'ffi', '~> 1.9.0'
|
@@ -29,6 +29,16 @@ module GPhoto2
|
|
29
29
|
#
|
30
30
|
# All unsaved changes will be lost.
|
31
31
|
#
|
32
|
+
# @example
|
33
|
+
# camera['iso']
|
34
|
+
# # => 800
|
35
|
+
#
|
36
|
+
# camera['iso'] = 200
|
37
|
+
# camera.reload
|
38
|
+
#
|
39
|
+
# camera['iso']
|
40
|
+
# # => 800
|
41
|
+
#
|
32
42
|
# @return [void]
|
33
43
|
def reload
|
34
44
|
@window.finalize if @window
|
@@ -67,6 +77,13 @@ module GPhoto2
|
|
67
77
|
|
68
78
|
# Updates the configuration on the camera.
|
69
79
|
#
|
80
|
+
# @example
|
81
|
+
# camera['iso'] = 800
|
82
|
+
# camera.save
|
83
|
+
# # => true
|
84
|
+
# camera.save
|
85
|
+
# # => false (nothing to update)
|
86
|
+
#
|
70
87
|
# @return [Boolean] whether setting the configuration was attempted
|
71
88
|
def save
|
72
89
|
return false unless dirty?
|
data/lib/gphoto2/camera/event.rb
CHANGED
data/lib/gphoto2/camera.rb
CHANGED
@@ -56,7 +56,7 @@ module GPhoto2
|
|
56
56
|
raise RuntimeError, 'no devices detected' if entries.empty?
|
57
57
|
camera = entries.first
|
58
58
|
autorelease(camera, &blk)
|
59
|
-
|
59
|
+
end
|
60
60
|
|
61
61
|
# @example
|
62
62
|
# model = 'Nikon DSC D5100 (PTP mode)'
|
@@ -139,6 +139,7 @@ module GPhoto2
|
|
139
139
|
# camera.can? :capture_image
|
140
140
|
# # => true
|
141
141
|
#
|
142
|
+
# @see FFI::GPhoto2::CameraOperation
|
142
143
|
# @param [CameraOperation] operation
|
143
144
|
# @return [Boolean]
|
144
145
|
def can?(operation)
|
data/lib/gphoto2/version.rb
CHANGED
data/lib/gphoto2.rb
CHANGED
@@ -8,9 +8,9 @@ require 'ffi/gphoto2_port'
|
|
8
8
|
require 'gphoto2/struct'
|
9
9
|
|
10
10
|
require 'gphoto2/camera_widgets/camera_widget'
|
11
|
+
require 'gphoto2/camera_widgets/radio_camera_widget'
|
11
12
|
require 'gphoto2/camera_widgets/date_camera_widget'
|
12
13
|
require 'gphoto2/camera_widgets/menu_camera_widget'
|
13
|
-
require 'gphoto2/camera_widgets/radio_camera_widget'
|
14
14
|
require 'gphoto2/camera_widgets/range_camera_widget'
|
15
15
|
require 'gphoto2/camera_widgets/section_camera_widget'
|
16
16
|
require 'gphoto2/camera_widgets/text_camera_widget'
|
data/spec/spec_helper.rb
CHANGED
@@ -3,3 +3,13 @@ require 'gphoto2'
|
|
3
3
|
|
4
4
|
__dir__ ||= File.dirname(__FILE__)
|
5
5
|
Dir[File.join(__dir__, 'support/**/*.rb')].each { |f| require f }
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.expect_with :rspec do |expectations|
|
9
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
10
|
+
end
|
11
|
+
|
12
|
+
config.mock_with :rspec do |mocks|
|
13
|
+
mocks.verify_partial_doubles = true
|
14
|
+
end
|
15
|
+
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.5.
|
4
|
+
version: 0.5.1
|
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: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.2.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.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
requirements:
|
196
196
|
- libgphoto2 >= 2.5.0
|
197
197
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.4.6
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: A Ruby FFI for common functions in libgphoto2
|