gphoto4ruby 0.4.2 → 0.4.3

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.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.4.3
2
+
3
+ * Added folder method to CameraEvent
4
+ * File and folder methods now correctly deal with FOLDER_ADDED and FILE_ADDED events
5
+
1
6
  == 0.4.2
2
7
 
3
8
  Pulled changes from Tallak Tveide
data/ext/gphoto2camera.c CHANGED
@@ -1359,6 +1359,7 @@ VALUE camera_create_folder(VALUE self, VALUE folder) {
1359
1359
  * evt.type == GPhoto2::CameraEvent::EVENT_TYPE_FILE_ADDED
1360
1360
  * #=> true
1361
1361
  * evt.file #=> "DSC_0384.JPG"
1362
+ * evt.folder #=> "/store_00010001/DCIM/100NCD80"
1362
1363
  *
1363
1364
  * # do nothing
1364
1365
  * c.wait(1).type #=> "timeout"
@@ -74,7 +74,7 @@ VALUE camera_event_type(VALUE self) {
74
74
  * file => string or nil
75
75
  *
76
76
  * Returns file name of manually captured image. Only applies to
77
- * EVENT_TYPE_FILE_ADDED event.
77
+ * EVENT_TYPE_FILE_ADDED or EVENT_TYPE_FOLDER_ADDED event.
78
78
  *
79
79
  * Examples:
80
80
  *
@@ -94,10 +94,44 @@ VALUE camera_event_file(VALUE self) {
94
94
 
95
95
  Data_Get_Struct(self, GPhoto2CameraEvent, ce);
96
96
 
97
- if (ce->type == GP_EVENT_FILE_ADDED) {
97
+ if ((ce->type == GP_EVENT_FILE_ADDED) ||
98
+ (ce->type == GP_EVENT_FOLDER_ADDED)) {
98
99
  return rb_str_new2(ce->path->name);
99
100
  } else {
100
101
  return Qnil;
101
102
  }
102
103
  }
103
104
 
105
+ /*
106
+ * call-seq:
107
+ * folder => string or nil
108
+ *
109
+ * Returns file name of manually captured image. Only applies to
110
+ * EVENT_TYPE_FILE_ADDED or EVENT_TYPE_FOLDER_ADDED event.
111
+ *
112
+ * Examples:
113
+ *
114
+ * c = GPhoto2::Camera.new
115
+ * # capture the image manually
116
+ * evt = c.wait
117
+ * evt.type #=> "file added"
118
+ * evt.type == GPhoto2::CameraEvent::EVENT_TYPE_FOLDER_ADDED
119
+ * #=> true
120
+ * evt.file #=> "101NCD80"
121
+ * evt.folder #=> "/store_00010001/DCIM"
122
+ *
123
+ * In example above is default behaviour for that type of event when it occurs
124
+ */
125
+ VALUE camera_event_folder(VALUE self) {
126
+ GPhoto2CameraEvent *ce;
127
+
128
+ Data_Get_Struct(self, GPhoto2CameraEvent, ce);
129
+
130
+ if ((ce->type == GP_EVENT_FILE_ADDED) ||
131
+ (ce->type == GP_EVENT_FOLDER_ADDED)) {
132
+ return rb_str_new2(ce->path->folder);
133
+ } else {
134
+ return Qnil;
135
+ }
136
+ }
137
+
@@ -20,7 +20,7 @@
20
20
  *
21
21
  */
22
22
 
23
- #include <gphoto2/gphoto2.h>
23
+ #include <gphoto2/gphoto2.h>
24
24
  #include <ruby.h>
25
25
 
26
26
  #ifndef _INC_CAMERA_EVENT
@@ -43,5 +43,6 @@ void camera_event_free(GPhoto2CameraEvent *ce);
43
43
 
44
44
  VALUE camera_event_type(VALUE self);
45
45
  VALUE camera_event_file(VALUE self);
46
+ VALUE camera_event_folder(VALUE self);
46
47
 
47
48
  #endif /* _INC_CAMERA_EVENT */
data/ext/gphoto4ruby.c CHANGED
@@ -104,6 +104,7 @@ void Init_gphoto4ruby() {
104
104
 
105
105
  rb_define_method(rb_cGPhoto2CameraEvent, "type", camera_event_type, 0); /* in gphoto2camera_event.c */
106
106
  rb_define_method(rb_cGPhoto2CameraEvent, "file", camera_event_file, 0); /* in gphoto2camera_event.c */
107
+ rb_define_method(rb_cGPhoto2CameraEvent, "folder", camera_event_folder, 0); /* in gphoto2camera_event.c */
107
108
 
108
109
  rb_define_method(rb_cGPhoto2Camera, "model_name", camera_model_name, 0); /* in gphoto2camera.c */
109
110
  rb_define_method(rb_cGPhoto2Camera, "has_image_capture?", camera_has_image_capture, 0); /* in gphoto2camera.c */
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 2
9
- version: 0.4.2
8
+ - 3
9
+ version: 0.4.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - neq4 company
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-02-28 00:00:00 +03:00
18
+ date: 2010-05-14 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21