glib2 3.1.0 → 3.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 398786c497340ba507311f59d7abe62b6d157cf6
4
- data.tar.gz: 9dbcf93fe4255b9e3b9d87d53d75356a42b8a691
3
+ metadata.gz: eaabbfe21ac69c6585d82b569ebd6f2da7b5d3d0
4
+ data.tar.gz: 94bb5881c554caa65395f55ed06e1c1995e1b5d3
5
5
  SHA512:
6
- metadata.gz: 19a054eaeb33aa1ab949d286f22fe661f26aca95de6e7b114fbb1589e54a08d6d8238f5d488bdcf9364f1529e5edef2b3a1bbeeffe96d95b453d5a8f38a2caba
7
- data.tar.gz: 2b88e5545b2d18f4f24f628dbc782d9344d8c13685caa94c5ba6f2e13bf126ca77bd362b3ee9fdb57b5ca4525f7be2781568381e8ee9405a06e250f7aa2762b1
6
+ metadata.gz: 99c21a1c2345607bc0cf02c3573eb32c62fa6bf140e69ba3d17e6e507b6a4b0695a84870c4cccdbd750d423b60a70517ef181bf88550b5789df35f32f902da77
7
+ data.tar.gz: 14bc39e43f8ca0079af6732cc041f1d7616704ef614d4660aa639539343fa6cd166d69d4eb8506c20347c944e9b61648a3fa7e972e2df6e7c6d02690cba8a92f
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2011-2015 Ruby-GNOME2 Project Team
3
+ # Copyright (C) 2011-2017 Ruby-GNOME2 Project Team
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -73,7 +73,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
73
73
  :name => "pcre",
74
74
  :download_base_url => "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre",
75
75
  :label => "PCRE",
76
- :version => "8.38",
76
+ :version => "8.40",
77
77
  :windows => {
78
78
  :configure_args => [
79
79
  "--enable-unicode-properties",
@@ -1187,4 +1187,6 @@ union GDoubleIEEE754;
1187
1187
  Init_glib_variant();
1188
1188
  Init_glib_regex();
1189
1189
  Init_glib_matchinfo();
1190
+ Init_glib_date_time();
1191
+ Init_glib_time_zone();
1190
1192
  }
@@ -36,7 +36,7 @@ extern "C" {
36
36
 
37
37
  #define RBGLIB_MAJOR_VERSION 3
38
38
  #define RBGLIB_MINOR_VERSION 1
39
- #define RBGLIB_MICRO_VERSION 0
39
+ #define RBGLIB_MICRO_VERSION 1
40
40
 
41
41
  #ifndef RB_ZALLOC
42
42
  # ifdef ZALLOC
@@ -62,4 +62,7 @@
62
62
  #define RVAL2GREGEXMATCHOPTIONSFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_REGEX_MATCH_FLAGS))
63
63
  #define RVAL2GREGEXCOMPILEOPTIONSFLAGS(o) (RVAL2GFLAGS(o, G_TYPE_REGEX_COMPILE_FLAGS))
64
64
  #define GMATCHINFO2RVAL(o) (BOXED2RVAL(o, G_TYPE_MATCH_INFO))
65
+ #define GDATETIME2RVAL(o) (BOXED2RVAL(o, G_TYPE_DATE_TIME))
66
+ #define GTIMEZONE2RVAL(o) (BOXED2RVAL(o, G_TYPE_TIME_ZONE))
67
+ #define RVAL2GTIMEZONE(o) ((GTimeZone*)RVAL2BOXED(o, G_TYPE_TIME_ZONE))
65
68
  #endif /* __GLIB2CONVERSIONS_H__ */
@@ -0,0 +1,250 @@
1
+ /*
2
+ * Copyright (C) 2016 Ruby-GNOME2 Project Team
3
+ *
4
+ * This library is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * This library is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with this library; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17
+ * MA 02110-1301 USA
18
+ */
19
+
20
+ #include "rbgprivate.h"
21
+
22
+ #define RG_TARGET_NAMESPACE cDateTime
23
+ #define _SELF(s) ((GDateTime*)RVAL2BOXED(s, G_TYPE_DATE_TIME))
24
+
25
+ static gboolean
26
+ is_local_timezone(VALUE rb_timezone)
27
+ {
28
+ ID id_equal;
29
+ ID id_local;
30
+
31
+ if (NIL_P(rb_timezone)) {
32
+ return TRUE;
33
+ }
34
+
35
+ CONST_ID(id_equal, "==");
36
+ CONST_ID(id_local, "local");
37
+ return RVAL2CBOOL(rb_funcall(rb_timezone, id_equal, 1, ID2SYM(id_local)));
38
+ }
39
+
40
+ static gboolean
41
+ is_utc_timezone(VALUE rb_timezone)
42
+ {
43
+ ID id_equal;
44
+ ID id_utc;
45
+
46
+ CONST_ID(id_equal, "==");
47
+ CONST_ID(id_utc, "utc");
48
+ return RVAL2CBOOL(rb_funcall(rb_timezone, id_equal, 1, ID2SYM(id_utc)));
49
+ }
50
+
51
+ static gboolean
52
+ is_timezone(VALUE rb_timezone)
53
+ {
54
+ VALUE rb_cTimeZone;
55
+
56
+ rb_cTimeZone = rb_const_get(mGLib, rb_intern("TimeZone"));
57
+ return RVAL2CBOOL(rb_obj_is_kind_of(rb_timezone, rb_cTimeZone));
58
+ }
59
+
60
+ static VALUE
61
+ rg_s_now(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
62
+ {
63
+ GDateTime *date = NULL;
64
+ VALUE rb_timezone;
65
+
66
+ rb_scan_args(argc, argv, "01", &rb_timezone);
67
+
68
+ if (is_local_timezone(rb_timezone)) {
69
+ date = g_date_time_new_now_local();
70
+ } else if (is_utc_timezone(rb_timezone)) {
71
+ date = g_date_time_new_now_utc();
72
+ } else if (is_timezone(rb_timezone)) {
73
+ date = g_date_time_new_now(RVAL2GTIMEZONE(rb_timezone));
74
+ } else {
75
+ rb_raise(rb_eArgError,
76
+ "timezone must be nil, :local, :utc or GLib::TimeZone: "
77
+ "%+" PRIsVALUE,
78
+ rb_timezone);
79
+ }
80
+
81
+ return GDATETIME2RVAL(date);
82
+ }
83
+
84
+ static VALUE
85
+ rg_initialize(int argc, VALUE *argv, VALUE self)
86
+ {
87
+ /*
88
+ * Not implemented:
89
+ * GDateTime * g_date_time_new_from_timeval_local ()
90
+ * GDateTime * g_date_time_new_from_timeval_utc ()
91
+ * https://developer.gnome.org/glib/stable/glib-Date-and-Time-Functions.html#GTimeVal
92
+ * */
93
+ VALUE rb_options;
94
+ VALUE rb_unix;
95
+ VALUE rb_timezone;
96
+ VALUE rb_year;
97
+ VALUE rb_month;
98
+ VALUE rb_day;
99
+ VALUE rb_hour;
100
+ VALUE rb_minute;
101
+ VALUE rb_second;
102
+ GDateTime *datetime = NULL;
103
+
104
+ rb_scan_args(argc, argv, "1", &rb_options);
105
+ rbg_scan_options(rb_options,
106
+ "unix", &rb_unix,
107
+ "timezone", &rb_timezone,
108
+ "year", &rb_year,
109
+ "month", &rb_month,
110
+ "day", &rb_day,
111
+ "hour", &rb_hour,
112
+ "minute", &rb_minute,
113
+ "second", &rb_second,
114
+ NULL);
115
+
116
+ if (!NIL_P(rb_unix)) {
117
+ gint64 unix_time;
118
+
119
+ unix_time = rbglib_num_to_int64(rb_unix);
120
+ if (is_local_timezone(rb_timezone)) {
121
+ datetime = g_date_time_new_from_unix_local(unix_time);
122
+ } else if (is_utc_timezone(rb_timezone)) {
123
+ datetime = g_date_time_new_from_unix_utc(unix_time);
124
+ } else {
125
+ rb_raise(rb_eArgError,
126
+ ":timezone must be nil, :local or :utc: %+" PRIsVALUE,
127
+ rb_timezone);
128
+ }
129
+ } else if (!NIL_P(rb_year) &&
130
+ !NIL_P(rb_month) &&
131
+ !NIL_P(rb_hour) &&
132
+ !NIL_P(rb_minute) &&
133
+ !NIL_P(rb_second)) {
134
+ gint year = 0;
135
+ gint month = 0;
136
+ gint day = 0;
137
+ gint hour = 0;
138
+ gint minute = 0;
139
+ gdouble second = 0.0;
140
+
141
+ year = NUM2INT(rb_year);
142
+ month = NUM2INT(rb_month);
143
+ day = NUM2INT(rb_day);
144
+ hour = NUM2INT(rb_hour);
145
+ minute = NUM2INT(rb_minute);
146
+ second = NUM2DBL(rb_second);
147
+ if (is_local_timezone(rb_timezone)) {
148
+ datetime = g_date_time_new_local(year,
149
+ month,
150
+ day,
151
+ hour,
152
+ minute,
153
+ second);
154
+ } else if (is_utc_timezone(rb_timezone)) {
155
+ datetime = g_date_time_new_utc(year,
156
+ month,
157
+ day,
158
+ hour,
159
+ minute,
160
+ second);
161
+ } else if (is_timezone(rb_timezone)) {
162
+ GTimeZone *timezone = NULL;
163
+
164
+ timezone = RVAL2GTIMEZONE(rb_timezone);
165
+ datetime = g_date_time_new(timezone,
166
+ year,
167
+ month,
168
+ day,
169
+ hour,
170
+ minute,
171
+ second);
172
+ } else {
173
+ rb_raise(rb_eArgError,
174
+ ":timezone must be nil, :local, :utc or GLib::TimeZone: "
175
+ "%+" PRIsVALUE,
176
+ rb_timezone);
177
+ }
178
+ } else {
179
+ rb_raise(rb_eArgError,
180
+ ":unix or (:year, :month, :day, :hour, :minute and :second) "
181
+ "must be specified: %+" PRIsVALUE,
182
+ rb_options);
183
+ }
184
+
185
+ G_INITIALIZE(self, datetime);
186
+
187
+ return Qnil;
188
+ }
189
+
190
+ static VALUE
191
+ rg_year(VALUE self)
192
+ {
193
+ return INT2NUM(g_date_time_get_year(_SELF(self)));
194
+ }
195
+
196
+ static VALUE
197
+ rg_month(VALUE self)
198
+ {
199
+ return INT2NUM(g_date_time_get_month(_SELF(self)));
200
+ }
201
+
202
+ static VALUE
203
+ rg_day_of_month(VALUE self)
204
+ {
205
+ return INT2NUM(g_date_time_get_day_of_month(_SELF(self)));
206
+ }
207
+
208
+ static VALUE
209
+ rg_hour(VALUE self)
210
+ {
211
+ return INT2NUM(g_date_time_get_hour(_SELF(self)));
212
+ }
213
+
214
+ static VALUE
215
+ rg_minute(VALUE self)
216
+ {
217
+ return INT2NUM(g_date_time_get_minute(_SELF(self)));
218
+ }
219
+
220
+ static VALUE
221
+ rg_second(VALUE self)
222
+ {
223
+ return DBL2NUM(g_date_time_get_second(_SELF(self)));
224
+ }
225
+
226
+ static VALUE
227
+ rg_format(VALUE self, VALUE rb_format)
228
+ {
229
+ const gchar *format = RVAL2CSTR(rb_format);
230
+ return CSTR2RVAL(g_date_time_format(_SELF(self), format));
231
+ }
232
+
233
+ void
234
+ Init_glib_date_time(void)
235
+ {
236
+ VALUE RG_TARGET_NAMESPACE;
237
+
238
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_DATE_TIME, "DateTime", mGLib);
239
+
240
+ RG_DEF_SMETHOD(now, -1);
241
+
242
+ RG_DEF_METHOD(initialize, -1);
243
+ RG_DEF_METHOD(year, 0);
244
+ RG_DEF_METHOD(month, 0);
245
+ RG_DEF_METHOD(day_of_month, 0);
246
+ RG_DEF_METHOD(hour, 0);
247
+ RG_DEF_METHOD(minute, 0);
248
+ RG_DEF_METHOD(second, 0);
249
+ RG_DEF_METHOD(format, 1);
250
+ }
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Copyright (C) 2016 Ruby-GNOME2 Project Team
3
+ *
4
+ * This library is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * This library is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with this library; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17
+ * MA 02110-1301 USA
18
+ */
19
+
20
+ #include "rbgprivate.h"
21
+
22
+ #define RG_TARGET_NAMESPACE cTimeZone
23
+ #define _SELF(s) ((GTimeZone*)RVAL2BOXED(s, G_TYPE_TIME_ZONE))
24
+
25
+ static VALUE
26
+ rg_initialize(gint argc, VALUE *argv, VALUE self)
27
+ {
28
+ VALUE rb_identifier = Qnil;
29
+ const gchar *identifier = NULL;
30
+ GTimeZone *time_zone = NULL;
31
+
32
+ rb_scan_args(argc, argv, "01", &rb_identifier);
33
+
34
+ if (!NIL_P(rb_identifier))
35
+ identifier = RVAL2CSTR(rb_identifier);
36
+
37
+ time_zone = g_time_zone_new(identifier);
38
+ G_INITIALIZE(self, time_zone);
39
+ return Qnil;
40
+ }
41
+
42
+ static VALUE
43
+ rg_s_local(G_GNUC_UNUSED VALUE self)
44
+ {
45
+ GTimeZone *time_zone = NULL;
46
+ time_zone = g_time_zone_new_local();
47
+ return GTIMEZONE2RVAL(time_zone);
48
+ }
49
+
50
+ static VALUE
51
+ rg_s_utc(G_GNUC_UNUSED VALUE self)
52
+ {
53
+ GTimeZone *time_zone = NULL;
54
+ time_zone = g_time_zone_new_utc();
55
+ return GTIMEZONE2RVAL(time_zone);
56
+ }
57
+
58
+ static VALUE
59
+ rg_abbreviation(VALUE self, VALUE rb_interval)
60
+ {
61
+ gint interval = NUM2INT(rb_interval);
62
+ return CSTR2RVAL(g_time_zone_get_abbreviation(_SELF(self), interval));
63
+ }
64
+
65
+ static VALUE
66
+ rg_offset(VALUE self, VALUE rb_interval)
67
+ {
68
+ gint interval = NUM2INT(rb_interval);
69
+ return INT2NUM(g_time_zone_get_offset(_SELF(self), interval));
70
+ }
71
+
72
+ void
73
+ Init_glib_time_zone(void)
74
+ {
75
+ VALUE RG_TARGET_NAMESPACE;
76
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIME_ZONE, "TimeZone", mGLib);
77
+ RG_DEF_METHOD(initialize, -1);
78
+ RG_DEF_SMETHOD(local, 0);
79
+ RG_DEF_SMETHOD(utc, 0);
80
+ RG_DEF_METHOD(abbreviation, 1);
81
+ RG_DEF_METHOD(offset, 1);
82
+ }
@@ -150,6 +150,8 @@ G_GNUC_INTERNAL void Init_glib_variant_type(void);
150
150
  G_GNUC_INTERNAL void Init_glib_variant(void);
151
151
  G_GNUC_INTERNAL void Init_glib_regex(void);
152
152
  G_GNUC_INTERNAL void Init_glib_matchinfo(void);
153
+ G_GNUC_INTERNAL void Init_glib_date_time(void);
154
+ G_GNUC_INTERNAL void Init_glib_time_zone(void);
153
155
 
154
156
  G_GNUC_INTERNAL void Init_gobject_convert(void);
155
157
  G_GNUC_INTERNAL void Init_gobject_gtype(void);
@@ -187,7 +187,7 @@ module GLib
187
187
 
188
188
  module Log
189
189
  DOMAIN = "Ruby/GLib"
190
- LEVELS = {
190
+ LEVELS = {
191
191
  LEVEL_ERROR => "ERROR",
192
192
  LEVEL_CRITICAL => "CRITICAL",
193
193
  LEVEL_WARNING => "WARNING",
@@ -207,15 +207,23 @@ module GLib
207
207
  log(DOMAIN, LEVEL_CRITICAL, caller(1)[0] << ": " << str)
208
208
  end
209
209
  def warning(str)
210
- log(DOMAIN, LEVEL_WARNING, caller(1)[0] << ": " << str)
210
+ log(DOMAIN, LEVEL_WARNING, caller(1)[0] << ": " << str)
211
211
  end
212
-
212
+
213
213
  def set_log_domain(domain)
214
- level = GLib::Log::LEVEL_MASK
214
+ level =
215
+ FLAG_RECURSION |
216
+ FLAG_FATAL |
217
+ LEVEL_ERROR |
218
+ LEVEL_CRITICAL |
219
+ LEVEL_WARNING
220
+ if $VERBOSE or $DEBUG
221
+ level |=
222
+ LEVEL_MESSAGE |
223
+ LEVEL_INFO
224
+ end
215
225
  if $DEBUG
216
- level = 255
217
- elsif $VERBOSE
218
- level = 127
226
+ level |= LEVEL_DEBUG
219
227
  end
220
228
  GLib::Log.set_handler(domain, level)
221
229
  end
@@ -44,15 +44,15 @@ module GNOME2
44
44
  end
45
45
 
46
46
  def compression_method
47
- super || "gz"
47
+ resolve_value(super) || "gz"
48
48
  end
49
49
 
50
50
  def base_name
51
- super || "#{name}-#{version}"
51
+ resolve_value(super) || "#{name}-#{version}"
52
52
  end
53
53
 
54
54
  def archive_base_name
55
- super || "#{base_name}.tar.#{compression_method}"
55
+ resolve_value(super) || "#{base_name}.tar.#{compression_method}"
56
56
  end
57
57
 
58
58
  def archive_url
@@ -60,7 +60,7 @@ module GNOME2
60
60
  end
61
61
 
62
62
  def download_base_url
63
- super || download_site_base_url
63
+ resolve_value(super) || download_site_base_url
64
64
  end
65
65
 
66
66
  def patches
@@ -76,7 +76,7 @@ module GNOME2
76
76
  end
77
77
 
78
78
  def base_dir_in_package
79
- super || "."
79
+ resolve_value(super) || "."
80
80
  end
81
81
 
82
82
  def windows
@@ -109,12 +109,22 @@ module GNOME2
109
109
  latest_version_freedesktop_gstreamer
110
110
  when :webkitgtk
111
111
  latest_version_webkitgtk
112
+ when :icu
113
+ latest_version_icu
112
114
  else
113
115
  nil
114
116
  end
115
117
  end
116
118
 
117
119
  private
120
+ def resolve_value(value)
121
+ if value.respond_to?(:call)
122
+ value.call(self)
123
+ else
124
+ value
125
+ end
126
+ end
127
+
118
128
  def download_site_base_url
119
129
  case download_site
120
130
  when :gnome
@@ -131,6 +141,8 @@ module GNOME2
131
141
  base_url = "http://ftp.gnu.org/pub/gnu/#{name}"
132
142
  when :webkitgtk
133
143
  base_url = webkitgtk_base_url
144
+ when :icu
145
+ base_url = "#{icu_base_url}/#{version}"
134
146
  else
135
147
  base_url = nil
136
148
  end
@@ -153,6 +165,10 @@ module GNOME2
153
165
  "https://webkitgtk.org/releases"
154
166
  end
155
167
 
168
+ def icu_base_url
169
+ "http://download.icu-project.org/files/icu4c"
170
+ end
171
+
156
172
  def sort_versions(versions)
157
173
  versions.sort_by do |version|
158
174
  version.split(".").collect(&:to_i)
@@ -247,6 +263,20 @@ module GNOME2
247
263
  sort_versions(versions).last
248
264
  end
249
265
 
266
+ def latest_version_icu
267
+ base_url = icu_base_url
268
+ versions = []
269
+ open(base_url) do |index|
270
+ index.read.scan(/<a (.+?)>/) do |content,|
271
+ case content
272
+ when /href="(\d+(?:\.\d+)+)\/"/x
273
+ versions << $1
274
+ end
275
+ end
276
+ end
277
+ sort_versions(versions).last
278
+ end
279
+
250
280
  class WindowsConfiguration < Struct.new(:build,
251
281
  :include_paths,
252
282
  :library_paths,
@@ -51,6 +51,7 @@ module GNOME2
51
51
  end
52
52
  end
53
53
 
54
+ private
54
55
  def define_download_tasks
55
56
  namespace :download do
56
57
  @package.external_packages.each do |package|
@@ -68,15 +69,34 @@ module GNOME2
68
69
  file tar_full_path.to_s => directory_path.to_s do
69
70
  archive_url = package.archive_url
70
71
  rake_output_message "Downloading... #{archive_url}"
71
- open(archive_url) do |downloaded_tar|
72
- tar_full_path.open("wb") do |tar_file|
73
- tar_file.print(downloaded_tar.read)
74
- end
75
- end
72
+ download(archive_url, tar_full_path)
76
73
  end
77
74
  end
78
75
  end
79
76
  end
77
+
78
+ def download(url, output_path)
79
+ OpenURI.singleton_class.class_eval do
80
+ alias_method :redirectable_original?, :redirectable?
81
+ def redirectable?(uri1, uri2)
82
+ redirectable_original?(uri1, uri2) or
83
+ (uri1.scheme.downcase == "http" and
84
+ uri2.scheme.downcase == "https")
85
+ end
86
+ end
87
+ begin
88
+ open(url) do |input|
89
+ output_path.open("wb") do |output_file|
90
+ output_file.print(input.read)
91
+ end
92
+ end
93
+ ensure
94
+ OpenURI.singleton_class.class_eval do
95
+ alias_method :redirectable?, :redirectable_original?
96
+ remove_method :redirectable_original?
97
+ end
98
+ end
99
+ end
80
100
  end
81
101
  end
82
102
  end
@@ -140,12 +140,7 @@ end
140
140
 
141
141
  def find_gem_spec(package)
142
142
  begin
143
- require 'rubygems'
144
- if Gem::Specification.respond_to?(:find_by_name)
145
- Gem::Specification.find_by_name(package)
146
- else
147
- Gem.source_index.find_name(package).last
148
- end
143
+ Gem::Specification.find_by_name(package)
149
144
  rescue LoadError
150
145
  nil
151
146
  end
@@ -0,0 +1,112 @@
1
+ # Copyright (C) 2016 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestDateTime < Test::Unit::TestCase
18
+ def test_now_local
19
+ now = GLib::DateTime.now(:local)
20
+ format = "%Y-%m-%d-%H-%M"
21
+ assert_equal(Time.now.strftime(format), now.format(format))
22
+ end
23
+
24
+ sub_test_case "new" do
25
+
26
+ test "unix: :local" do
27
+ time = Time.now
28
+ format = "%Y-%m-%d-%H-%M"
29
+ datetime = GLib::DateTime.new(:unix => time.to_i,
30
+ :timezone => :local)
31
+ assert_equal(time.strftime(format), datetime.format(format))
32
+ end
33
+
34
+ test "unix: :utc" do
35
+ time = Time.now.utc
36
+ format = "%Y-%m-%d-%H-%M"
37
+ datetime = GLib::DateTime.new(:unix => time.to_i,
38
+ :timezone => :utc)
39
+ assert_equal(time.strftime(format), datetime.format(format))
40
+ end
41
+
42
+ test "timezone: :local" do
43
+ time = Time.now
44
+ datetime = GLib::DateTime.new(:timezone => :local,
45
+ :year => time.year,
46
+ :month => time.month,
47
+ :day => time.day,
48
+ :hour => time.hour,
49
+ :minute => time.min,
50
+ :second => time.sec)
51
+ assert_equal(time.year, datetime.year)
52
+ assert_equal(time.month, datetime.month)
53
+ assert_equal(time.day, datetime.day_of_month)
54
+ assert_equal(time.hour, datetime.hour)
55
+ assert_equal(time.min, datetime.minute)
56
+ assert_equal(time.sec, datetime.second)
57
+ end
58
+
59
+ test "timezone: :utc" do
60
+ time = Time.now.utc
61
+ datetime = GLib::DateTime.new(:timezone => :utc,
62
+ :year => time.year,
63
+ :month => time.month,
64
+ :day => time.day,
65
+ :hour => time.hour,
66
+ :minute => time.min,
67
+ :second => time.sec)
68
+ assert_equal(time.year, datetime.year)
69
+ assert_equal(time.month, datetime.month)
70
+ assert_equal(time.day, datetime.day_of_month)
71
+ assert_equal(time.hour, datetime.hour)
72
+ assert_equal(time.min, datetime.minute)
73
+ assert_equal(time.sec, datetime.second)
74
+ end
75
+
76
+ test "timezone: local time zone" do
77
+ time = Time.now
78
+ tz = GLib::TimeZone.local
79
+ datetime = GLib::DateTime.new(:timezone => tz,
80
+ :year => time.year,
81
+ :month => time.month,
82
+ :day => time.day,
83
+ :hour => time.hour,
84
+ :minute => time.min,
85
+ :second => time.sec)
86
+ assert_equal(time.year, datetime.year)
87
+ assert_equal(time.month, datetime.month)
88
+ assert_equal(time.day, datetime.day_of_month)
89
+ assert_equal(time.hour, datetime.hour)
90
+ assert_equal(time.min, datetime.minute)
91
+ assert_equal(time.sec, datetime.second)
92
+ end
93
+
94
+ test "timezone: UTC time zone" do
95
+ time = Time.now.utc
96
+ tz = GLib::TimeZone.utc
97
+ datetime = GLib::DateTime.new(:timezone => tz,
98
+ :year => time.year,
99
+ :month => time.month,
100
+ :day => time.day,
101
+ :hour => time.hour,
102
+ :minute => time.min,
103
+ :second => time.sec)
104
+ assert_equal(time.year, datetime.year)
105
+ assert_equal(time.month, datetime.month)
106
+ assert_equal(time.day, datetime.day_of_month)
107
+ assert_equal(time.hour, datetime.hour)
108
+ assert_equal(time.min, datetime.minute)
109
+ assert_equal(time.sec, datetime.second)
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,31 @@
1
+ # Copyright (C) 2016 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestTimeZone < Test::Unit::TestCase
18
+ sub_test_case "new" do
19
+ test "local" do
20
+ local_1 = GLib::TimeZone.local
21
+ local_2 = GLib::TimeZone.new
22
+ assert_equal(local_1.abbreviation(0), local_2.abbreviation(0))
23
+ end
24
+
25
+ test "UTC" do
26
+ utc_1 = GLib::TimeZone.utc
27
+ utc_2 = GLib::TimeZone.new("UTC")
28
+ assert_equal(utc_1.offset(0), utc_2.offset(0))
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME2 Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-13 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
@@ -59,6 +59,7 @@ files:
59
59
  - ext/glib2/rbglib2conversions.h
60
60
  - ext/glib2/rbglib_bookmarkfile.c
61
61
  - ext/glib2/rbglib_convert.c
62
+ - ext/glib2/rbglib_datetime.c
62
63
  - ext/glib2/rbglib_error.c
63
64
  - ext/glib2/rbglib_fileutils.c
64
65
  - ext/glib2/rbglib_gettext.c
@@ -82,6 +83,7 @@ files:
82
83
  - ext/glib2/rbglib_spawnerror.c
83
84
  - ext/glib2/rbglib_threads.c
84
85
  - ext/glib2/rbglib_timer.c
86
+ - ext/glib2/rbglib_timezone.c
85
87
  - ext/glib2/rbglib_ucs4.c
86
88
  - ext/glib2/rbglib_unichar.c
87
89
  - ext/glib2/rbglib_unicode.c
@@ -152,8 +154,10 @@ files:
152
154
  - test/glib-test-utils.rb
153
155
  - test/run-test.rb
154
156
  - test/test-binding.rb
157
+ - test/test-date-time.rb
155
158
  - test/test-match-info.rb
156
159
  - test/test-regex.rb
160
+ - test/test-time-zone.rb
157
161
  - test/test-variant-type.rb
158
162
  - test/test-version.rb
159
163
  - test/test_enum.rb
@@ -192,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
196
  version: '0'
193
197
  requirements: []
194
198
  rubyforge_project:
195
- rubygems_version: 2.5.1
199
+ rubygems_version: 2.5.2
196
200
  signing_key:
197
201
  specification_version: 4
198
202
  summary: Ruby/GLib2 is a Ruby binding of GLib-2.x.