do_oracle 0.10.7-x86-mingw32 → 0.10.8-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +4 -0
- data/ext/do_oracle/do_oracle.c +10 -111
- data/lib/do_oracle/1.8/do_oracle.so +0 -0
- data/lib/do_oracle/1.9/do_oracle.so +0 -0
- data/lib/do_oracle/version.rb +1 -1
- data/tasks/compile.rake +1 -1
- data/tasks/spec.rake +0 -1
- metadata +13 -13
data/ChangeLog.markdown
CHANGED
data/ext/do_oracle/do_oracle.c
CHANGED
@@ -34,7 +34,6 @@
|
|
34
34
|
|
35
35
|
// To store rb_intern values
|
36
36
|
static ID ID_NEW;
|
37
|
-
static ID ID_NEW_DATE;
|
38
37
|
static ID ID_LOGGER;
|
39
38
|
static ID ID_DEBUG;
|
40
39
|
static ID ID_LEVEL;
|
@@ -144,75 +143,19 @@ static char * get_uri_option(VALUE query_hash, char * key) {
|
|
144
143
|
return value;
|
145
144
|
}
|
146
145
|
|
147
|
-
/* ====== Time/Date Parsing Helper Functions ====== */
|
148
|
-
static void reduce( do_int64 *numerator, do_int64 *denominator ) {
|
149
|
-
do_int64 a, b, c;
|
150
|
-
a = *numerator;
|
151
|
-
b = *denominator;
|
152
|
-
while ( a != 0 ) {
|
153
|
-
c = a; a = b % a; b = c;
|
154
|
-
}
|
155
|
-
*numerator = *numerator / b;
|
156
|
-
*denominator = *denominator / b;
|
157
|
-
}
|
158
|
-
|
159
|
-
// Generate the date integer which Date.civil_to_jd returns
|
160
|
-
static int jd_from_date(int year, int month, int day) {
|
161
|
-
int a, b;
|
162
|
-
if ( month <= 2 ) {
|
163
|
-
year -= 1;
|
164
|
-
month += 12;
|
165
|
-
}
|
166
|
-
a = year / 100;
|
167
|
-
b = 2 - a + (a / 4);
|
168
|
-
return floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524;
|
169
|
-
}
|
170
|
-
|
171
|
-
// Creates a Rational for use as a Timezone offset to be passed to DateTime.new!
|
172
|
-
static VALUE seconds_to_offset(do_int64 num) {
|
173
|
-
do_int64 den = 86400;
|
174
|
-
reduce(&num, &den);
|
175
|
-
return rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ll2inum(num), rb_ll2inum(den));
|
176
|
-
}
|
177
|
-
|
178
|
-
static VALUE timezone_to_offset(int hour_offset, int minute_offset) {
|
179
|
-
do_int64 seconds = 0;
|
180
|
-
|
181
|
-
seconds += hour_offset * 3600;
|
182
|
-
seconds += minute_offset * 60;
|
183
|
-
|
184
|
-
return seconds_to_offset(seconds);
|
185
|
-
}
|
186
|
-
|
187
146
|
// Implementation using C functions
|
188
147
|
|
189
148
|
static VALUE parse_date(VALUE r_value) {
|
190
|
-
VALUE time_array;
|
191
149
|
int year, month, day;
|
192
|
-
int jd, ajd;
|
193
|
-
VALUE rational;
|
194
|
-
|
195
|
-
if (rb_obj_class(r_value) == rb_cTime) {
|
196
|
-
time_array = rb_funcall(r_value, ID_TO_A, 0);
|
197
|
-
year = NUM2INT(rb_ary_entry(time_array, 5));
|
198
|
-
month = NUM2INT(rb_ary_entry(time_array, 4));
|
199
|
-
day = NUM2INT(rb_ary_entry(time_array, 3));
|
200
|
-
|
201
|
-
jd = jd_from_date(year, month, day);
|
202
150
|
|
203
|
-
|
204
|
-
ajd = jd * 2 - 1;
|
205
|
-
rational = rb_funcall(rb_mKernel, ID_RATIONAL, 2, INT2NUM(ajd), INT2NUM(2));
|
206
|
-
|
207
|
-
return rb_funcall(rb_cDate, ID_NEW_DATE, 3, rational, INT2NUM(0), INT2NUM(2299161));
|
208
|
-
|
209
|
-
} else if (rb_obj_class(r_value) == rb_cDate) {
|
151
|
+
if (rb_obj_class(r_value) == rb_cDate) {
|
210
152
|
return r_value;
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
153
|
+
} else if (rb_obj_class(r_value) == rb_cTime ||
|
154
|
+
rb_obj_class(r_value) == rb_cDateTime) {
|
155
|
+
year = NUM2INT(rb_funcall(r_value, rb_intern("year"), 0));
|
156
|
+
month = NUM2INT(rb_funcall(r_value, rb_intern("month"), 0));
|
157
|
+
day = NUM2INT(rb_funcall(r_value, rb_intern("day"), 0));
|
158
|
+
return rb_funcall(rb_cDate, ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
|
216
159
|
} else {
|
217
160
|
// Something went terribly wrong
|
218
161
|
rb_raise(eDataError, "Couldn't parse date from class %s object", rb_obj_classname(r_value));
|
@@ -222,16 +165,10 @@ static VALUE parse_date(VALUE r_value) {
|
|
222
165
|
// Implementation using C functions
|
223
166
|
|
224
167
|
static VALUE parse_date_time(VALUE r_value) {
|
225
|
-
VALUE ajd, offset;
|
226
|
-
|
227
168
|
VALUE time_array;
|
228
|
-
int year, month, day, hour, min, sec
|
169
|
+
int year, month, day, hour, min, sec;
|
229
170
|
// int usec;
|
230
|
-
int jd;
|
231
|
-
do_int64 num, den;
|
232
|
-
|
233
171
|
long int gmt_offset;
|
234
|
-
int is_dst;
|
235
172
|
|
236
173
|
// time_t rawtime;
|
237
174
|
// struct tm * timeinfo;
|
@@ -249,43 +186,10 @@ static VALUE parse_date_time(VALUE r_value) {
|
|
249
186
|
min = NUM2INT(rb_ary_entry(time_array, 1));
|
250
187
|
sec = NUM2INT(rb_ary_entry(time_array, 0));
|
251
188
|
|
252
|
-
is_dst = rb_ary_entry(time_array, 8) == Qtrue ? 3600 : 0;
|
253
189
|
gmt_offset = NUM2INT(rb_funcall(r_value, ID_UTC_OFFSET, 0 ));
|
254
190
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
hour_offset = -(gmt_offset / 3600);
|
259
|
-
minute_offset = -(gmt_offset % 3600 / 60);
|
260
|
-
|
261
|
-
jd = jd_from_date(year, month, day);
|
262
|
-
|
263
|
-
// Generate ajd with fractional days for the time
|
264
|
-
// Extracted from Date#jd_to_ajd, Date#day_fraction_to_time, and Rational#+ and #-
|
265
|
-
num = (hour * 1440) + (min * 24);
|
266
|
-
|
267
|
-
// Modify the numerator so when we apply the timezone everything works out
|
268
|
-
num -= (hour_offset * 1440) + (minute_offset * 24);
|
269
|
-
|
270
|
-
den = (24 * 1440);
|
271
|
-
reduce(&num, &den);
|
272
|
-
|
273
|
-
num = (num * 86400) + (sec * den);
|
274
|
-
den = den * 86400;
|
275
|
-
reduce(&num, &den);
|
276
|
-
|
277
|
-
num = (jd * den) + num;
|
278
|
-
|
279
|
-
num = num * 2;
|
280
|
-
num = num - den;
|
281
|
-
den = den * 2;
|
282
|
-
|
283
|
-
reduce(&num, &den);
|
284
|
-
|
285
|
-
ajd = rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ull2inum(num), rb_ull2inum(den));
|
286
|
-
offset = timezone_to_offset(hour_offset, minute_offset);
|
287
|
-
|
288
|
-
return rb_funcall(rb_cDateTime, ID_NEW_DATE, 3, ajd, offset, INT2NUM(2299161));
|
191
|
+
return rb_funcall(rb_cDateTime, ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
|
192
|
+
INT2NUM(hour), INT2NUM(min), INT2NUM(sec), gmt_offset);
|
289
193
|
} else {
|
290
194
|
// Something went terribly wrong
|
291
195
|
rb_raise(eDataError, "Couldn't parse datetime from class %s object", rb_obj_classname(r_value));
|
@@ -794,11 +698,6 @@ void Init_do_oracle() {
|
|
794
698
|
rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects"));
|
795
699
|
|
796
700
|
ID_NEW = rb_intern("new");
|
797
|
-
#ifdef RUBY_LESS_THAN_186
|
798
|
-
ID_NEW_DATE = rb_intern("new0");
|
799
|
-
#else
|
800
|
-
ID_NEW_DATE = rb_intern("new!");
|
801
|
-
#endif
|
802
701
|
ID_LOGGER = rb_intern("logger");
|
803
702
|
ID_DEBUG = rb_intern("debug");
|
804
703
|
ID_LEVEL = rb_intern("level");
|
Binary file
|
Binary file
|
data/lib/do_oracle/version.rb
CHANGED
data/tasks/compile.rake
CHANGED
data/tasks/spec.rake
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do_oracle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 0.10.
|
9
|
+
- 8
|
10
|
+
version: 0.10.8
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Raimonds Simanovskis
|
@@ -18,23 +18,23 @@ cert_chain: []
|
|
18
18
|
date: 2011-03-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
22
|
none: false
|
23
23
|
requirements:
|
24
24
|
- - "="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
hash:
|
26
|
+
hash: 39
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
- 10
|
30
|
-
-
|
31
|
-
version: 0.10.
|
32
|
-
version_requirements: *id001
|
30
|
+
- 8
|
31
|
+
version: 0.10.8
|
33
32
|
name: data_objects
|
34
33
|
prerelease: false
|
35
34
|
type: :runtime
|
35
|
+
requirement: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
@@ -44,12 +44,12 @@ dependencies:
|
|
44
44
|
- 2
|
45
45
|
- 5
|
46
46
|
version: "2.5"
|
47
|
-
version_requirements: *id002
|
48
47
|
name: rspec
|
49
48
|
prerelease: false
|
50
49
|
type: :development
|
50
|
+
requirement: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
-
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ~>
|
@@ -59,10 +59,10 @@ dependencies:
|
|
59
59
|
- 0
|
60
60
|
- 7
|
61
61
|
version: "0.7"
|
62
|
-
version_requirements: *id003
|
63
62
|
name: rake-compiler
|
64
63
|
prerelease: false
|
65
64
|
type: :development
|
65
|
+
requirement: *id003
|
66
66
|
description: Implements the DataObjects API for Oracle
|
67
67
|
email: raimonds.simanovskis@gmail.com
|
68
68
|
executables: []
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements: []
|
141
141
|
|
142
142
|
rubyforge_project: dorb
|
143
|
-
rubygems_version: 1.8.
|
143
|
+
rubygems_version: 1.8.14
|
144
144
|
signing_key:
|
145
145
|
specification_version: 3
|
146
146
|
summary: DataObjects Oracle Driver
|