tzinfo 1.2.7 → 2.0.2

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.yardopts +3 -0
  5. data/CHANGES.md +489 -382
  6. data/LICENSE +12 -12
  7. data/README.md +368 -114
  8. data/lib/tzinfo.rb +59 -29
  9. data/lib/tzinfo/country.rb +141 -129
  10. data/lib/tzinfo/country_timezone.rb +70 -112
  11. data/lib/tzinfo/data_source.rb +389 -144
  12. data/lib/tzinfo/data_sources.rb +8 -0
  13. data/lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb +56 -0
  14. data/lib/tzinfo/data_sources/country_info.rb +42 -0
  15. data/lib/tzinfo/data_sources/data_timezone_info.rb +91 -0
  16. data/lib/tzinfo/data_sources/linked_timezone_info.rb +33 -0
  17. data/lib/tzinfo/data_sources/ruby_data_source.rb +145 -0
  18. data/lib/tzinfo/data_sources/timezone_info.rb +47 -0
  19. data/lib/tzinfo/data_sources/transitions_data_timezone_info.rb +214 -0
  20. data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +577 -0
  21. data/lib/tzinfo/data_sources/zoneinfo_reader.rb +288 -0
  22. data/lib/tzinfo/data_timezone.rb +33 -47
  23. data/lib/tzinfo/datetime_with_offset.rb +153 -0
  24. data/lib/tzinfo/format1.rb +10 -0
  25. data/lib/tzinfo/format1/country_definer.rb +17 -0
  26. data/lib/tzinfo/format1/country_index_definition.rb +64 -0
  27. data/lib/tzinfo/format1/timezone_definer.rb +64 -0
  28. data/lib/tzinfo/format1/timezone_definition.rb +39 -0
  29. data/lib/tzinfo/format1/timezone_index_definition.rb +77 -0
  30. data/lib/tzinfo/format2.rb +10 -0
  31. data/lib/tzinfo/format2/country_definer.rb +68 -0
  32. data/lib/tzinfo/format2/country_index_definer.rb +68 -0
  33. data/lib/tzinfo/format2/country_index_definition.rb +46 -0
  34. data/lib/tzinfo/format2/timezone_definer.rb +94 -0
  35. data/lib/tzinfo/format2/timezone_definition.rb +73 -0
  36. data/lib/tzinfo/format2/timezone_index_definer.rb +45 -0
  37. data/lib/tzinfo/format2/timezone_index_definition.rb +55 -0
  38. data/lib/tzinfo/info_timezone.rb +26 -21
  39. data/lib/tzinfo/linked_timezone.rb +33 -52
  40. data/lib/tzinfo/offset_timezone_period.rb +42 -0
  41. data/lib/tzinfo/string_deduper.rb +118 -0
  42. data/lib/tzinfo/time_with_offset.rb +128 -0
  43. data/lib/tzinfo/timestamp.rb +548 -0
  44. data/lib/tzinfo/timestamp_with_offset.rb +85 -0
  45. data/lib/tzinfo/timezone.rb +989 -502
  46. data/lib/tzinfo/timezone_offset.rb +84 -74
  47. data/lib/tzinfo/timezone_period.rb +151 -217
  48. data/lib/tzinfo/timezone_proxy.rb +70 -79
  49. data/lib/tzinfo/timezone_transition.rb +77 -109
  50. data/lib/tzinfo/transitions_timezone_period.rb +63 -0
  51. data/lib/tzinfo/untaint_ext.rb +18 -0
  52. data/lib/tzinfo/version.rb +7 -0
  53. data/lib/tzinfo/with_offset.rb +61 -0
  54. metadata +42 -98
  55. metadata.gz.sig +0 -0
  56. data/Rakefile +0 -107
  57. data/lib/tzinfo/country_index_definition.rb +0 -31
  58. data/lib/tzinfo/country_info.rb +0 -42
  59. data/lib/tzinfo/data_timezone_info.rb +0 -55
  60. data/lib/tzinfo/linked_timezone_info.rb +0 -26
  61. data/lib/tzinfo/offset_rationals.rb +0 -77
  62. data/lib/tzinfo/ruby_core_support.rb +0 -169
  63. data/lib/tzinfo/ruby_country_info.rb +0 -74
  64. data/lib/tzinfo/ruby_data_source.rb +0 -140
  65. data/lib/tzinfo/time_or_datetime.rb +0 -340
  66. data/lib/tzinfo/timezone_definition.rb +0 -36
  67. data/lib/tzinfo/timezone_index_definition.rb +0 -54
  68. data/lib/tzinfo/timezone_info.rb +0 -30
  69. data/lib/tzinfo/timezone_transition_definition.rb +0 -104
  70. data/lib/tzinfo/transition_data_timezone_info.rb +0 -274
  71. data/lib/tzinfo/zoneinfo_country_info.rb +0 -37
  72. data/lib/tzinfo/zoneinfo_data_source.rb +0 -496
  73. data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -300
  74. data/test/tc_country.rb +0 -238
  75. data/test/tc_country_index_definition.rb +0 -69
  76. data/test/tc_country_info.rb +0 -16
  77. data/test/tc_country_timezone.rb +0 -173
  78. data/test/tc_data_source.rb +0 -218
  79. data/test/tc_data_timezone.rb +0 -99
  80. data/test/tc_data_timezone_info.rb +0 -18
  81. data/test/tc_info_timezone.rb +0 -34
  82. data/test/tc_linked_timezone.rb +0 -155
  83. data/test/tc_linked_timezone_info.rb +0 -23
  84. data/test/tc_offset_rationals.rb +0 -23
  85. data/test/tc_ruby_core_support.rb +0 -168
  86. data/test/tc_ruby_country_info.rb +0 -110
  87. data/test/tc_ruby_data_source.rb +0 -167
  88. data/test/tc_time_or_datetime.rb +0 -660
  89. data/test/tc_timezone.rb +0 -1361
  90. data/test/tc_timezone_definition.rb +0 -113
  91. data/test/tc_timezone_index_definition.rb +0 -73
  92. data/test/tc_timezone_info.rb +0 -11
  93. data/test/tc_timezone_london.rb +0 -143
  94. data/test/tc_timezone_melbourne.rb +0 -142
  95. data/test/tc_timezone_new_york.rb +0 -142
  96. data/test/tc_timezone_offset.rb +0 -126
  97. data/test/tc_timezone_period.rb +0 -555
  98. data/test/tc_timezone_proxy.rb +0 -136
  99. data/test/tc_timezone_transition.rb +0 -366
  100. data/test/tc_timezone_transition_definition.rb +0 -295
  101. data/test/tc_timezone_utc.rb +0 -27
  102. data/test/tc_transition_data_timezone_info.rb +0 -433
  103. data/test/tc_zoneinfo_country_info.rb +0 -78
  104. data/test/tc_zoneinfo_data_source.rb +0 -1204
  105. data/test/tc_zoneinfo_timezone_info.rb +0 -1236
  106. data/test/test_utils.rb +0 -192
  107. data/test/ts_all.rb +0 -7
  108. data/test/ts_all_ruby.rb +0 -5
  109. data/test/ts_all_zoneinfo.rb +0 -9
  110. data/test/tzinfo-data/tzinfo/data.rb +0 -8
  111. data/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb +0 -89
  112. data/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb +0 -315
  113. data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +0 -218
  114. data/test/tzinfo-data/tzinfo/data/definitions/EST.rb +0 -19
  115. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb +0 -21
  116. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb +0 -21
  117. data/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb +0 -21
  118. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb +0 -261
  119. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb +0 -186
  120. data/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb +0 -321
  121. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb +0 -265
  122. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb +0 -220
  123. data/test/tzinfo-data/tzinfo/data/definitions/UTC.rb +0 -16
  124. data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +0 -927
  125. data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +0 -596
  126. data/test/tzinfo-data/tzinfo/data/version.rb +0 -14
  127. data/test/zoneinfo/America/Argentina/Buenos_Aires +0 -0
  128. data/test/zoneinfo/America/New_York +0 -0
  129. data/test/zoneinfo/Australia/Melbourne +0 -0
  130. data/test/zoneinfo/EST +0 -0
  131. data/test/zoneinfo/Etc/UTC +0 -0
  132. data/test/zoneinfo/Europe/Amsterdam +0 -0
  133. data/test/zoneinfo/Europe/Andorra +0 -0
  134. data/test/zoneinfo/Europe/London +0 -0
  135. data/test/zoneinfo/Europe/Paris +0 -0
  136. data/test/zoneinfo/Europe/Prague +0 -0
  137. data/test/zoneinfo/Factory +0 -0
  138. data/test/zoneinfo/iso3166.tab +0 -275
  139. data/test/zoneinfo/leapseconds +0 -61
  140. data/test/zoneinfo/posix/Europe/London +0 -0
  141. data/test/zoneinfo/posixrules +0 -0
  142. data/test/zoneinfo/right/Europe/London +0 -0
  143. data/test/zoneinfo/zone.tab +0 -439
  144. data/test/zoneinfo/zone1970.tab +0 -369
  145. data/tzinfo.gemspec +0 -21
@@ -0,0 +1,7 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module TZInfo
5
+ # The TZInfo version number.
6
+ VERSION = '2.0.2'
7
+ end
@@ -0,0 +1,61 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module TZInfo
5
+ # The {WithOffset} module is included in {TimeWithOffset},
6
+ # {DateTimeWithOffset} and {TimestampWithOffset}. It provides an override for
7
+ # the {strftime} method that handles expanding the `%Z` directive according to
8
+ # the {TimezoneOffset#abbreviation abbreviation} of the {TimezoneOffset}
9
+ # associated with a local time.
10
+ module WithOffset
11
+ # Overrides the `Time`, `DateTime` or {Timestamp} version of `strftime`,
12
+ # replacing `%Z` with the {TimezoneOffset#abbreviation abbreviation} of the
13
+ # associated {TimezoneOffset}. If there is no associated offset, `%Z` is
14
+ # expanded by the base class instead.
15
+ #
16
+ # All the format directives handled by the base class are supported.
17
+ #
18
+ # @param format [String] the format string.
19
+ # @return [String] the formatted time.
20
+ # @raise [ArgumentError] if `format` is `nil`.
21
+ def strftime(format)
22
+ raise ArgumentError, 'format must be specified' unless format
23
+
24
+ if_timezone_offset do |o|
25
+ abbreviation = nil
26
+
27
+ format = format.gsub(/%(%*)Z/) do
28
+ if $1.length.odd?
29
+ # Return %%Z so the real strftime treats it as a literal %Z too.
30
+ "#$1%Z"
31
+ else
32
+ "#$1#{abbreviation ||= o.abbreviation.gsub(/%/, '%%')}"
33
+ end
34
+ end
35
+ end
36
+
37
+ super
38
+ end
39
+
40
+ protected
41
+
42
+ # Performs a calculation if there is an associated {TimezoneOffset}.
43
+ #
44
+ # @param result [Object] a result value that can be manipulated by the block
45
+ # if there is an associated {TimezoneOffset}.
46
+ # @yield [period, result] if there is an associated {TimezoneOffset}, the
47
+ # block is yielded to in order to calculate the method result.
48
+ # @yieldparam period [TimezoneOffset] the associated {TimezoneOffset}.
49
+ # @yieldparam result [Object] the `result` parameter.
50
+ # @yieldreturn [Object] the result of the calculation performed if there is
51
+ # an associated {TimezoneOffset}.
52
+ # @return [Object] the result of the block if there is an associated
53
+ # {TimezoneOffset}, otherwise the `result` parameter.
54
+ #
55
+ # @private
56
+ def if_timezone_offset(result = nil) #:nodoc:
57
+ to = timezone_offset
58
+ to ? yield(to, result) : result
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Ross
@@ -32,21 +32,21 @@ cert_chain:
32
32
  date: 2020-04-02 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
- name: thread_safe
35
+ name: concurrent-ruby
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: '1.0'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
48
- description: TZInfo provides daylight savings aware transformations between times
49
- in different time zones.
47
+ version: '1.0'
48
+ description: TZInfo provides access to time zone data and allows times to be converted
49
+ using time zone rules.
50
50
  email: phil.ross@gmail.com
51
51
  executables: []
52
52
  extensions: []
@@ -59,108 +59,52 @@ files:
59
59
  - CHANGES.md
60
60
  - LICENSE
61
61
  - README.md
62
- - Rakefile
63
62
  - lib/tzinfo.rb
64
63
  - lib/tzinfo/country.rb
65
- - lib/tzinfo/country_index_definition.rb
66
- - lib/tzinfo/country_info.rb
67
64
  - lib/tzinfo/country_timezone.rb
68
65
  - lib/tzinfo/data_source.rb
66
+ - lib/tzinfo/data_sources.rb
67
+ - lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb
68
+ - lib/tzinfo/data_sources/country_info.rb
69
+ - lib/tzinfo/data_sources/data_timezone_info.rb
70
+ - lib/tzinfo/data_sources/linked_timezone_info.rb
71
+ - lib/tzinfo/data_sources/ruby_data_source.rb
72
+ - lib/tzinfo/data_sources/timezone_info.rb
73
+ - lib/tzinfo/data_sources/transitions_data_timezone_info.rb
74
+ - lib/tzinfo/data_sources/zoneinfo_data_source.rb
75
+ - lib/tzinfo/data_sources/zoneinfo_reader.rb
69
76
  - lib/tzinfo/data_timezone.rb
70
- - lib/tzinfo/data_timezone_info.rb
77
+ - lib/tzinfo/datetime_with_offset.rb
78
+ - lib/tzinfo/format1.rb
79
+ - lib/tzinfo/format1/country_definer.rb
80
+ - lib/tzinfo/format1/country_index_definition.rb
81
+ - lib/tzinfo/format1/timezone_definer.rb
82
+ - lib/tzinfo/format1/timezone_definition.rb
83
+ - lib/tzinfo/format1/timezone_index_definition.rb
84
+ - lib/tzinfo/format2.rb
85
+ - lib/tzinfo/format2/country_definer.rb
86
+ - lib/tzinfo/format2/country_index_definer.rb
87
+ - lib/tzinfo/format2/country_index_definition.rb
88
+ - lib/tzinfo/format2/timezone_definer.rb
89
+ - lib/tzinfo/format2/timezone_definition.rb
90
+ - lib/tzinfo/format2/timezone_index_definer.rb
91
+ - lib/tzinfo/format2/timezone_index_definition.rb
71
92
  - lib/tzinfo/info_timezone.rb
72
93
  - lib/tzinfo/linked_timezone.rb
73
- - lib/tzinfo/linked_timezone_info.rb
74
- - lib/tzinfo/offset_rationals.rb
75
- - lib/tzinfo/ruby_core_support.rb
76
- - lib/tzinfo/ruby_country_info.rb
77
- - lib/tzinfo/ruby_data_source.rb
78
- - lib/tzinfo/time_or_datetime.rb
94
+ - lib/tzinfo/offset_timezone_period.rb
95
+ - lib/tzinfo/string_deduper.rb
96
+ - lib/tzinfo/time_with_offset.rb
97
+ - lib/tzinfo/timestamp.rb
98
+ - lib/tzinfo/timestamp_with_offset.rb
79
99
  - lib/tzinfo/timezone.rb
80
- - lib/tzinfo/timezone_definition.rb
81
- - lib/tzinfo/timezone_index_definition.rb
82
- - lib/tzinfo/timezone_info.rb
83
100
  - lib/tzinfo/timezone_offset.rb
84
101
  - lib/tzinfo/timezone_period.rb
85
102
  - lib/tzinfo/timezone_proxy.rb
86
103
  - lib/tzinfo/timezone_transition.rb
87
- - lib/tzinfo/timezone_transition_definition.rb
88
- - lib/tzinfo/transition_data_timezone_info.rb
89
- - lib/tzinfo/zoneinfo_country_info.rb
90
- - lib/tzinfo/zoneinfo_data_source.rb
91
- - lib/tzinfo/zoneinfo_timezone_info.rb
92
- - test/tc_country.rb
93
- - test/tc_country_index_definition.rb
94
- - test/tc_country_info.rb
95
- - test/tc_country_timezone.rb
96
- - test/tc_data_source.rb
97
- - test/tc_data_timezone.rb
98
- - test/tc_data_timezone_info.rb
99
- - test/tc_info_timezone.rb
100
- - test/tc_linked_timezone.rb
101
- - test/tc_linked_timezone_info.rb
102
- - test/tc_offset_rationals.rb
103
- - test/tc_ruby_core_support.rb
104
- - test/tc_ruby_country_info.rb
105
- - test/tc_ruby_data_source.rb
106
- - test/tc_time_or_datetime.rb
107
- - test/tc_timezone.rb
108
- - test/tc_timezone_definition.rb
109
- - test/tc_timezone_index_definition.rb
110
- - test/tc_timezone_info.rb
111
- - test/tc_timezone_london.rb
112
- - test/tc_timezone_melbourne.rb
113
- - test/tc_timezone_new_york.rb
114
- - test/tc_timezone_offset.rb
115
- - test/tc_timezone_period.rb
116
- - test/tc_timezone_proxy.rb
117
- - test/tc_timezone_transition.rb
118
- - test/tc_timezone_transition_definition.rb
119
- - test/tc_timezone_utc.rb
120
- - test/tc_transition_data_timezone_info.rb
121
- - test/tc_zoneinfo_country_info.rb
122
- - test/tc_zoneinfo_data_source.rb
123
- - test/tc_zoneinfo_timezone_info.rb
124
- - test/test_utils.rb
125
- - test/ts_all.rb
126
- - test/ts_all_ruby.rb
127
- - test/ts_all_zoneinfo.rb
128
- - test/tzinfo-data/tzinfo/data.rb
129
- - test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb
130
- - test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb
131
- - test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb
132
- - test/tzinfo-data/tzinfo/data/definitions/EST.rb
133
- - test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb
134
- - test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb
135
- - test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb
136
- - test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb
137
- - test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb
138
- - test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb
139
- - test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb
140
- - test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb
141
- - test/tzinfo-data/tzinfo/data/definitions/UTC.rb
142
- - test/tzinfo-data/tzinfo/data/indexes/countries.rb
143
- - test/tzinfo-data/tzinfo/data/indexes/timezones.rb
144
- - test/tzinfo-data/tzinfo/data/version.rb
145
- - test/zoneinfo/America/Argentina/Buenos_Aires
146
- - test/zoneinfo/America/New_York
147
- - test/zoneinfo/Australia/Melbourne
148
- - test/zoneinfo/EST
149
- - test/zoneinfo/Etc/UTC
150
- - test/zoneinfo/Europe/Amsterdam
151
- - test/zoneinfo/Europe/Andorra
152
- - test/zoneinfo/Europe/London
153
- - test/zoneinfo/Europe/Paris
154
- - test/zoneinfo/Europe/Prague
155
- - test/zoneinfo/Factory
156
- - test/zoneinfo/iso3166.tab
157
- - test/zoneinfo/leapseconds
158
- - test/zoneinfo/posix/Europe/London
159
- - test/zoneinfo/posixrules
160
- - test/zoneinfo/right/Europe/London
161
- - test/zoneinfo/zone.tab
162
- - test/zoneinfo/zone1970.tab
163
- - tzinfo.gemspec
104
+ - lib/tzinfo/transitions_timezone_period.rb
105
+ - lib/tzinfo/untaint_ext.rb
106
+ - lib/tzinfo/version.rb
107
+ - lib/tzinfo/with_offset.rb
164
108
  homepage: https://tzinfo.github.io
165
109
  licenses:
166
110
  - MIT
@@ -177,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
121
  requirements:
178
122
  - - ">="
179
123
  - !ruby/object:Gem::Version
180
- version: 1.8.7
124
+ version: 1.9.3
181
125
  required_rubygems_version: !ruby/object:Gem::Requirement
182
126
  requirements:
183
127
  - - ">="
@@ -187,5 +131,5 @@ requirements: []
187
131
  rubygems_version: 3.1.2
188
132
  signing_key:
189
133
  specification_version: 4
190
- summary: Daylight savings aware timezone library
134
+ summary: Time Zone Library
191
135
  test_files: []
metadata.gz.sig CHANGED
Binary file
data/Rakefile DELETED
@@ -1,107 +0,0 @@
1
- require 'rubygems'
2
- require 'rubygems/package_task'
3
- require 'fileutils'
4
- require 'rake/testtask'
5
-
6
- # Ignore errors loading rdoc/task (the rdoc tasks will be excluded if
7
- # rdoc is unavailable).
8
- begin
9
- require 'rdoc/task'
10
- rescue LoadError, RuntimeError
11
- end
12
-
13
- BASE_DIR = File.expand_path(File.dirname(__FILE__))
14
-
15
- task :default => [:test]
16
-
17
- spec = eval(File.read('tzinfo.gemspec'))
18
-
19
- class TZInfoPackageTask < Gem::PackageTask
20
- alias_method :orig_sh, :sh
21
- private :orig_sh
22
-
23
- def sh(*cmd, &block)
24
- if cmd[0] == '__tar_with_owner__' && cmd[1] =~ /\A-?[zjcvf]+\z/
25
- opts = cmd[1]
26
- cmd = ['tar', 'c', '--owner', '0', '--group', '0', "#{opts.start_with?('-') ? '' : '-'}#{opts.gsub('c', '')}"] + cmd.drop(2)
27
- elsif cmd.first =~ /\A__tar_with_owner__ -?([zjcvf]+)(.*)\z/
28
- opts = $1
29
- args = $2
30
- cmd[0] = "tar c --owner 0 --group 0 -#{opts.gsub('c', '')}#{args}"
31
- end
32
-
33
- orig_sh(*cmd, &block)
34
- end
35
- end
36
-
37
- def add_signing_key(spec)
38
- # Attempt to find the private key and add options to sign the gem if found.
39
- private_key_path = File.expand_path(File.join(BASE_DIR, '..', 'key', 'gem-private_key.pem'))
40
-
41
- if File.exist?(private_key_path)
42
- spec = spec.clone
43
- spec.signing_key = private_key_path
44
- spec.cert_chain = [File.join(BASE_DIR, 'gem-public_cert.pem')]
45
- else
46
- puts 'WARNING: Private key not found. Not signing gem file.'
47
- end
48
-
49
- spec
50
- end
51
-
52
- package_task = TZInfoPackageTask.new(add_signing_key(spec)) do |pkg|
53
- pkg.need_zip = true
54
- pkg.need_tar_gz = true
55
- pkg.tar_command = '__tar_with_owner__'
56
- end
57
-
58
- # Skip the rdoc task if RDoc::Task is unavailable
59
- if defined?(RDoc) && defined?(RDoc::Task)
60
- RDoc::Task.new do |rdoc|
61
- rdoc.rdoc_dir = 'doc'
62
- rdoc.options.concat spec.rdoc_options
63
- rdoc.rdoc_files.include(spec.extra_rdoc_files)
64
- rdoc.rdoc_files.include('lib')
65
- end
66
- end
67
-
68
- Rake::Task[package_task.package_dir_path].enhance do
69
- recurse_chmod(package_task.package_dir_path)
70
- end
71
-
72
- Rake::Task[:package].enhance do
73
- FileUtils.rm_rf(package_task.package_dir_path)
74
- end
75
-
76
- def recurse_chmod(dir)
77
- File.chmod(0755, dir)
78
-
79
- Dir.entries(dir).each do |entry|
80
- if entry != '.' && entry != '..'
81
- path = File.join(dir, entry)
82
- if File.directory?(path)
83
- recurse_chmod(path)
84
- else
85
- File.chmod(0644, path)
86
- end
87
- end
88
- end
89
- end
90
-
91
- desc 'Run tests using RubyDataSource, then ZoneinfoDataSource'
92
- task :test => [:test_ruby, :test_zoneinfo] do
93
- end
94
-
95
- def setup_tests(test_task, type)
96
- test_task.libs = [File.join(BASE_DIR, 'lib')]
97
- test_task.pattern = File.join(BASE_DIR, 'test', "ts_all_#{type}.rb")
98
- test_task.warning = true
99
- end
100
-
101
- Rake::TestTask.new(:test_ruby) do |t|
102
- setup_tests(t, :ruby)
103
- end
104
-
105
- Rake::TestTask.new(:test_zoneinfo) do |t|
106
- setup_tests(t, :zoneinfo)
107
- end
@@ -1,31 +0,0 @@
1
- module TZInfo
2
- # The country index file includes CountryIndexDefinition which provides
3
- # a country method used to define each country in the index.
4
- #
5
- # @private
6
- module CountryIndexDefinition #:nodoc:
7
- def self.append_features(base)
8
- super
9
- base.extend(ClassMethods)
10
- base.instance_eval { @countries = {} }
11
- end
12
-
13
- # Class methods for inclusion.
14
- #
15
- # @private
16
- module ClassMethods #:nodoc:
17
- # Defines a country with an ISO 3166 country code, name and block. The
18
- # block will be evaluated to obtain all the timezones for the country.
19
- # Calls Country.country_defined with the definition of each country.
20
- def country(code, name, &block)
21
- @countries[code] = RubyCountryInfo.new(code, name, &block)
22
- end
23
-
24
- # Returns a frozen hash of all the countries that have been defined in
25
- # the index.
26
- def countries
27
- @countries.freeze
28
- end
29
- end
30
- end
31
- end
@@ -1,42 +0,0 @@
1
- module TZInfo
2
- # Represents a country and references to its timezones as returned by a
3
- # DataSource.
4
- class CountryInfo
5
- # The ISO 3166 country code.
6
- attr_reader :code
7
-
8
- # The name of the country.
9
- attr_reader :name
10
-
11
- # Constructs a new CountryInfo with an ISO 3166 country code and name
12
- def initialize(code, name)
13
- @code = code
14
- @name = name
15
- end
16
-
17
- # Returns internal object state as a programmer-readable string.
18
- def inspect
19
- "#<#{self.class}: #@code>"
20
- end
21
-
22
- # Returns a frozen array of all the zone identifiers for the country.
23
- # The identifiers are ordered by importance according to the DataSource.
24
- def zone_identifiers
25
- raise_not_implemented('zone_identifiers')
26
- end
27
-
28
- # Returns a frozen array of all the timezones for the for the country as
29
- # CountryTimezone instances.
30
- #
31
- # The timezones are ordered by importance according to the DataSource.
32
- def zones
33
- raise_not_implemented('zones')
34
- end
35
-
36
- private
37
-
38
- def raise_not_implemented(method_name)
39
- raise NotImplementedError, "Subclasses must override #{method_name}"
40
- end
41
- end
42
- end