tp_common 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c48203ba4b5d1acb56633e89274ad84c00a4ddb7
4
+ data.tar.gz: 49f10ec634a4e03b28dad85a3e460286638cd399
5
+ SHA512:
6
+ metadata.gz: 4601153cef82a204b8c52036774c26eccaf466108754c30af40dff862134b1bd12fd8b598679ab658c997c867b22710a486719b0e63f9f96a073808b8b81980f
7
+ data.tar.gz: facc09b02e11bb0dfabb72f67ef79ace07a0686739f08f4fd21a44e8a3cb248f9980725ad753d6fba87e881871cbf2e77ceebe1dcb46e7b734b7d91bfb3fd39d
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ tp_common
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at thien.an.vo.nguyen@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in tp_common.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 An Vo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # TpCommon
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tp_common`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tp_common'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tp_common
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/anvox/tp_common. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the TpCommon project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/anvox/tp_common/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tp_common"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,707 @@
1
+ gmt-12: &gmt-12
2
+ GMT_M1200:
3
+ :title: ''
4
+ :name: 'Etc/GMT+12'
5
+ :dst: false
6
+
7
+ gmt-11: &gmt-11
8
+ GMT_M1100:
9
+ :title: ''
10
+ :name: 'Etc/GMT+11'
11
+ :dst: false
12
+ GMT_M1100+1:
13
+ :title: 'American Samoa'
14
+ :name: 'Etc/GMT+11'
15
+ :dst: false
16
+ GMT_M1100+2:
17
+ :title: 'International Date Line West'
18
+ :name: 'Etc/GMT+11'
19
+ :dst: false
20
+ GMT_M1100+3:
21
+ :title: 'Midway Island'
22
+ :name: 'Etc/GMT+11'
23
+ :dst: false
24
+
25
+ gmt-10: &gmt-10
26
+ GMT_M1000:
27
+ :title: ''
28
+ :name: 'Etc/GMT+10'
29
+ :dst: false
30
+ GMT_M1000+1:
31
+ :title: 'Hawaii'
32
+ :name: 'Etc/GMT+10'
33
+ :dst: false
34
+
35
+ gmt-9: &gmt-9
36
+ GMT_M0900:
37
+ :title: ''
38
+ :name: 'Etc/GMT+9'
39
+ :dst: false
40
+ GMT_M0900+1:
41
+ :title: 'Alaska'
42
+ :name: 'Etc/GMT+9'
43
+ :dst: true
44
+
45
+ gmt-8: &gmt-8
46
+ GMT_M0800:
47
+ :title: ''
48
+ :name: 'Etc/GMT+8'
49
+ :dst: false
50
+ GMT_M0800+1:
51
+ :title: 'Pacific Time (US & Canada)'
52
+ :name: 'Etc/GMT+8'
53
+ :dst: true
54
+ GMT_M0800+2:
55
+ :title: 'Tijuana'
56
+ :name: 'Etc/GMT+8'
57
+ :dst: true
58
+
59
+ gmt-7: &gmt-7
60
+ GMT_M0700:
61
+ :title: ''
62
+ :name: 'Etc/GMT+7'
63
+ :dst: false
64
+ GMT_M0700+1:
65
+ :title: 'Arizona'
66
+ :name: 'Etc/GMT+7'
67
+ :dst: false
68
+ GMT_M0700+2:
69
+ :title: 'Chihuahua'
70
+ :name: 'Etc/GMT+7'
71
+ :dst: true
72
+ GMT_M0700+3:
73
+ :title: 'Mazatlan'
74
+ :name: 'Etc/GMT+7'
75
+ :dst: true
76
+ GMT_M0700+4:
77
+ :title: 'Mountain Time (US & Canada)'
78
+ :name: 'Etc/GMT+7'
79
+ :dst: true
80
+
81
+ gmt-6: &gmt-6
82
+ GMT_M0600:
83
+ :title: ''
84
+ :name: 'Etc/GMT+6'
85
+ :dst: false
86
+ GMT_M0600+1:
87
+ :title: 'Central America'
88
+ :name: 'Etc/GMT+6'
89
+ :dst: false
90
+ GMT_M0600+2:
91
+ :title: 'Central Time (US & Canada)'
92
+ :name: 'Etc/GMT+6'
93
+ :dst: true
94
+ GMT_M0600+3:
95
+ :title: 'Guadalajara'
96
+ :name: 'Etc/GMT+6'
97
+ :dst: true
98
+ GMT_M0600+4:
99
+ :title: 'Mexico City'
100
+ :name: 'Etc/GMT+6'
101
+ :dst: true
102
+ GMT_M0600+5:
103
+ :title: 'Monterrey'
104
+ :name: 'Etc/GMT+6'
105
+ :dst: true
106
+ GMT_M0600+6:
107
+ :title: 'Saskatchewan'
108
+ :name: 'Etc/GMT+6'
109
+ :dst: false
110
+
111
+ gmt-5: &gmt-5
112
+ GMT_M0500:
113
+ :title: ''
114
+ :name: 'Etc/GMT+5'
115
+ :dst: false
116
+ GMT_M0500+1:
117
+ :title: 'Bogota'
118
+ :name: 'Etc/GMT+5'
119
+ :dst: false
120
+ GMT_M0500+2:
121
+ :title: 'Eastern Time (US & Canada)'
122
+ :name: 'Etc/GMT+5'
123
+ :dst: true
124
+ GMT_M0500+3:
125
+ :title: 'Indiana (East)'
126
+ :name: 'Etc/GMT+5'
127
+ :dst: true
128
+ GMT_M0500+4:
129
+ :title: 'Lima'
130
+ :name: 'Etc/GMT+5'
131
+ :dst: false
132
+ GMT_M0500+5:
133
+ :title: 'Quito'
134
+ :name: 'Etc/GMT+5'
135
+ :dst: false
136
+
137
+ gmt-4: &gmt-4
138
+ GMT_M0400:
139
+ :title: ''
140
+ :name: 'Etc/GMT+4'
141
+ :dst: false
142
+ GMT_M0400+1:
143
+ :title: 'Atlantic Time (Canada)'
144
+ :name: 'Etc/GMT+4'
145
+ :dst: true
146
+ GMT_M0400+2:
147
+ :title: 'Caracas'
148
+ :name: 'Etc/GMT+4'
149
+ :dst: false
150
+ GMT_M0400+3:
151
+ :title: 'Georgetown'
152
+ :name: 'Etc/GMT+4'
153
+ :dst: false
154
+ GMT_M0400+4:
155
+ :title: 'La Paz'
156
+ :name: 'Etc/GMT+4'
157
+ :dst: false
158
+ GMT_M0400+5:
159
+ :title: 'Santiago'
160
+ :name: 'Etc/GMT+4'
161
+ :dst: false
162
+
163
+ gmt-3: &gmt-3
164
+ GMT_M0300:
165
+ :title: ''
166
+ :name: 'Etc/GMT+3'
167
+ :dst: false
168
+ GMT_M0300+1:
169
+ :title: 'Brasilia'
170
+ :name: 'Etc/GMT+3'
171
+ :dst: false
172
+ GMT_M0300+2:
173
+ :title: 'Buenos Aires'
174
+ :name: 'Etc/GMT+3'
175
+ :dst: false
176
+ GMT_M0300+3:
177
+ :title: 'Greenland'
178
+ :name: 'Etc/GMT+3'
179
+ :dst: true
180
+ GMT_M0300+4:
181
+ :title: 'Montevideo'
182
+ :name: 'Etc/GMT+3'
183
+ :dst: false
184
+
185
+ gmt-2: &gmt-2
186
+ GMT_M0200:
187
+ :title: ''
188
+ :name: 'Etc/GMT+2'
189
+ :dst: false
190
+ GMT_M0200+1:
191
+ :title: 'Mid-Atlantic'
192
+ :name: 'Etc/GMT+2'
193
+ :dst: false
194
+
195
+ gmt-1: &gmt-1
196
+ GMT_M0100:
197
+ :title: ''
198
+ :name: 'Etc/GMT+1'
199
+ :dst: false
200
+ GMT_M0100+1:
201
+ :title: 'Azores'
202
+ :name: 'Etc/GMT+1'
203
+ :dst: true
204
+ GMT_M0100+2:
205
+ :title: 'Cape Verde Is.'
206
+ :name: 'Etc/GMT+1'
207
+ :dst: false
208
+
209
+ gmt-0: &gmt-0
210
+ GMT_M0000:
211
+ :title: ''
212
+ :name: 'Etc/GMT+0'
213
+ :dst: false
214
+ GMT_M0000+1:
215
+ :title: 'Casablanca'
216
+ :name: 'Etc/GMT+0'
217
+ :dst: false
218
+ GMT_M0000+2:
219
+ :title: 'Dublin'
220
+ :name: 'Etc/GMT+0'
221
+ :dst: true
222
+ GMT_M0000+3:
223
+ :title: 'Edinburgh'
224
+ :name: 'Etc/GMT+0'
225
+ :dst: true
226
+ GMT_M0000+4:
227
+ :title: 'Lisbon'
228
+ :name: 'Etc/GMT+0'
229
+ :dst: true
230
+ GMT_M0000+5:
231
+ :title: 'London'
232
+ :name: 'Etc/GMT+0'
233
+ :dst: true
234
+ GMT_M0000+6:
235
+ :title: 'Monrovia'
236
+ :name: 'Etc/GMT+0'
237
+ :dst: false
238
+ GMT_M0000+7:
239
+ :title: 'UTC'
240
+ :name: 'Etc/GMT+0'
241
+ :dst: false
242
+
243
+ gmt1: &gmt1
244
+ GMT_P0100:
245
+ :title: ''
246
+ :name: 'Etc/GMT-1'
247
+ :dst: false
248
+ GMT_P0100+1:
249
+ :title: 'Amsterdam'
250
+ :name: 'Etc/GMT-1'
251
+ :dst: true
252
+ GMT_P0100+2:
253
+ :title: 'Belgrade'
254
+ :name: 'Etc/GMT-1'
255
+ :dst: true
256
+ GMT_P0100+3:
257
+ :title: 'Berlin'
258
+ :name: 'Etc/GMT-1'
259
+ :dst: true
260
+ GMT_P0100+4:
261
+ :title: 'Bern'
262
+ :name: 'Etc/GMT-1'
263
+ :dst: true
264
+ GMT_P0100+5:
265
+ :title: 'Bratislava'
266
+ :name: 'Etc/GMT-1'
267
+ :dst: true
268
+ GMT_P0100+6:
269
+ :title: 'Brussels'
270
+ :name: 'Etc/GMT-1'
271
+ :dst: true
272
+ GMT_P0100+7:
273
+ :title: 'Budapest'
274
+ :name: 'Etc/GMT-1'
275
+ :dst: true
276
+ GMT_P0100+8:
277
+ :title: 'Copenhagen'
278
+ :name: 'Etc/GMT-1'
279
+ :dst: true
280
+ GMT_P0100+9:
281
+ :title: 'Ljubljana'
282
+ :name: 'Etc/GMT-1'
283
+ :dst: true
284
+ GMT_P0100+10:
285
+ :title: 'Madrid'
286
+ :name: 'Etc/GMT-1'
287
+ :dst: true
288
+ GMT_P0100+11:
289
+ :title: 'Paris'
290
+ :name: 'Etc/GMT-1'
291
+ :dst: true
292
+ GMT_P0100+12:
293
+ :title: 'Prague'
294
+ :name: 'Etc/GMT-1'
295
+ :dst: true
296
+ GMT_P0100+13:
297
+ :title: 'Rome'
298
+ :name: 'Etc/GMT-1'
299
+ :dst: true
300
+ GMT_P0100+14:
301
+ :title: 'Sarajevo'
302
+ :name: 'Etc/GMT-1'
303
+ :dst: true
304
+ GMT_P0100+15:
305
+ :title: 'Skopje'
306
+ :name: 'Etc/GMT-1'
307
+ :dst: true
308
+ GMT_P0100+16:
309
+ :title: 'Stockholm'
310
+ :name: 'Etc/GMT-1'
311
+ :dst: true
312
+ GMT_P0100+17:
313
+ :title: 'Vienna'
314
+ :name: 'Etc/GMT-1'
315
+ :dst: true
316
+ GMT_P0100+18:
317
+ :title: 'Warsaw'
318
+ :name: 'Etc/GMT-1'
319
+ :dst: true
320
+ GMT_P0100+19:
321
+ :title: 'West Central Africa'
322
+ :name: 'Etc/GMT-1'
323
+ :dst: false
324
+ GMT_P0100+20:
325
+ :title: 'Zagreb'
326
+ :name: 'Etc/GMT-1'
327
+ :dst: true
328
+
329
+ gmt2: &gmt2
330
+ GMT_P0200:
331
+ :title: ''
332
+ :name: 'Etc/GMT-2'
333
+ :dst: false
334
+ GMT_P0200+1:
335
+ :title: 'Athens'
336
+ :name: 'Etc/GMT-2'
337
+ :dst: true
338
+ GMT_P0200+2:
339
+ :title: 'Bucharest'
340
+ :name: 'Etc/GMT-2'
341
+ :dst: true
342
+ GMT_P0200+3:
343
+ :title: 'Cairo'
344
+ :name: 'Etc/GMT-2'
345
+ :dst: false
346
+ GMT_P0200+4:
347
+ :title: 'Harare'
348
+ :name: 'Etc/GMT-2'
349
+ :dst: false
350
+ GMT_P0200+5:
351
+ :title: 'Helsinki'
352
+ :name: 'Etc/GMT-2'
353
+ :dst: true
354
+ GMT_P0200+6:
355
+ :title: 'Jerusalem'
356
+ :name: 'Etc/GMT-2'
357
+ :dst: true
358
+ GMT_P0200+7:
359
+ :title: 'Kaliningrad'
360
+ :name: 'Etc/GMT-2'
361
+ :dst: false
362
+ GMT_P0200+8:
363
+ :title: 'Kyiv'
364
+ :name: 'Etc/GMT-2'
365
+ :dst: true
366
+ GMT_P0200+9:
367
+ :title: 'Pretoria'
368
+ :name: 'Etc/GMT-2'
369
+ :dst: false
370
+ GMT_P0200+10:
371
+ :title: 'Riga'
372
+ :name: 'Etc/GMT-2'
373
+ :dst: true
374
+ GMT_P0200+11:
375
+ :title: 'Sofia'
376
+ :name: 'Etc/GMT-2'
377
+ :dst: true
378
+ GMT_P0200+12:
379
+ :title: 'Tallinn'
380
+ :name: 'Etc/GMT-2'
381
+ :dst: true
382
+ GMT_P0200+13:
383
+ :title: 'Vilnius'
384
+ :name: 'Etc/GMT-2'
385
+ :dst: true
386
+
387
+ gmt3: &gmt3
388
+ GMT_P0300:
389
+ :title: ''
390
+ :name: 'Etc/GMT-3'
391
+ :dst: false
392
+ GMT_P0300+1:
393
+ :title: 'Baghdad'
394
+ :name: 'Etc/GMT-3'
395
+ :dst: false
396
+ GMT_P0300+2:
397
+ :title: 'Istanbul'
398
+ :name: 'Etc/GMT-3'
399
+ :dst: false
400
+ GMT_P0300+3:
401
+ :title: 'Kuwait'
402
+ :name: 'Etc/GMT-3'
403
+ :dst: false
404
+ GMT_P0300+4:
405
+ :title: 'Minsk'
406
+ :name: 'Etc/GMT-3'
407
+ :dst: false
408
+ GMT_P0300+5:
409
+ :title: 'Moscow'
410
+ :name: 'Etc/GMT-3'
411
+ :dst: false
412
+ GMT_P0300+6:
413
+ :title: 'Nairobi'
414
+ :name: 'Etc/GMT-3'
415
+ :dst: false
416
+ GMT_P0300+7:
417
+ :title: 'Riyadh'
418
+ :name: 'Etc/GMT-3'
419
+ :dst: false
420
+ GMT_P0300+8:
421
+ :title: 'St. Petersburg'
422
+ :name: 'Etc/GMT-3'
423
+ :dst: false
424
+ GMT_P0300+9:
425
+ :title: 'Volgograd'
426
+ :name: 'Etc/GMT-3'
427
+ :dst: false
428
+
429
+ gmt4: &gmt4
430
+ GMT_P0400:
431
+ :title: ''
432
+ :name: 'Etc/GMT-4'
433
+ :dst: false
434
+ GMT_P0400+1:
435
+ :title: 'Abu Dhabi'
436
+ :name: 'Etc/GMT-4'
437
+ :dst: false
438
+ GMT_P0400+2:
439
+ :title: 'Baku'
440
+ :name: 'Etc/GMT-4'
441
+ :dst: false
442
+ GMT_P0400+3:
443
+ :title: 'Muscat'
444
+ :name: 'Etc/GMT-4'
445
+ :dst: false
446
+ GMT_P0400+4:
447
+ :title: 'Samara'
448
+ :name: 'Etc/GMT-4'
449
+ :dst: false
450
+ GMT_P0400+5:
451
+ :title: 'Tbilisi'
452
+ :name: 'Etc/GMT-4'
453
+ :dst: false
454
+ GMT_P0400+6:
455
+ :title: 'Yerevan'
456
+ :name: 'Etc/GMT-4'
457
+ :dst: false
458
+
459
+ gmt5: &gmt5
460
+ GMT_P0500:
461
+ :title: ''
462
+ :name: 'Etc/GMT-5'
463
+ :dst: false
464
+ GMT_P0500+1:
465
+ :title: 'Ekaterinburg'
466
+ :name: 'Etc/GMT-5'
467
+ :dst: false
468
+ GMT_P0500+2:
469
+ :title: 'Islamabad'
470
+ :name: 'Etc/GMT-5'
471
+ :dst: false
472
+ GMT_P0500+3:
473
+ :title: 'Karachi'
474
+ :name: 'Etc/GMT-5'
475
+ :dst: false
476
+ GMT_P0500+4:
477
+ :title: 'Tashkent'
478
+ :name: 'Etc/GMT-5'
479
+ :dst: false
480
+
481
+ gmt6: &gmt6
482
+ GMT_P0600:
483
+ :title: ''
484
+ :name: 'Etc/GMT-6'
485
+ :dst: false
486
+ GMT_P0600+1:
487
+ :title: 'Almaty'
488
+ :name: 'Etc/GMT-6'
489
+ :dst: false
490
+ GMT_P0600+2:
491
+ :title: 'Astana'
492
+ :name: 'Etc/GMT-6'
493
+ :dst: false
494
+ GMT_P0600+3:
495
+ :title: 'Dhaka'
496
+ :name: 'Etc/GMT-6'
497
+ :dst: false
498
+ GMT_P0600+4:
499
+ :title: 'Urumqi'
500
+ :name: 'Etc/GMT-6'
501
+ :dst: false
502
+
503
+ gmt7: &gmt7
504
+ GMT_P0700:
505
+ :title: ''
506
+ :name: 'Etc/GMT-7'
507
+ :dst: false
508
+ GMT_P0700+1:
509
+ :title: 'Bangkok'
510
+ :name: 'Etc/GMT-7'
511
+ :dst: false
512
+ GMT_P0700+2:
513
+ :title: 'Hanoi'
514
+ :name: 'Etc/GMT-7'
515
+ :dst: false
516
+ GMT_P0700+3:
517
+ :title: 'Jakarta'
518
+ :name: 'Etc/GMT-7'
519
+ :dst: false
520
+ GMT_P0700+4:
521
+ :title: 'Krasnoyarsk'
522
+ :name: 'Etc/GMT-7'
523
+ :dst: false
524
+ GMT_P0700+5:
525
+ :title: 'Novosibirsk'
526
+ :name: 'Etc/GMT-7'
527
+ :dst: false
528
+
529
+ gmt8: &gmt8
530
+ GMT_P0800:
531
+ :title: ''
532
+ :name: 'Etc/GMT-8'
533
+ :dst: false
534
+ GMT_P0800+1:
535
+ :title: 'Beijing'
536
+ :name: 'Etc/GMT-8'
537
+ :dst: false
538
+ GMT_P0800+2:
539
+ :title: 'Chongqing'
540
+ :name: 'Etc/GMT-8'
541
+ :dst: false
542
+ GMT_P0800+3:
543
+ :title: 'Hong Kong'
544
+ :name: 'Etc/GMT-8'
545
+ :dst: false
546
+ GMT_P0800+4:
547
+ :title: 'Irkutsk'
548
+ :name: 'Etc/GMT-8'
549
+ :dst: false
550
+ GMT_P0800+5:
551
+ :title: 'Kuala Lumpur'
552
+ :name: 'Etc/GMT-8'
553
+ :dst: false
554
+ GMT_P0800+6:
555
+ :title: 'Perth'
556
+ :name: 'Etc/GMT-8'
557
+ :dst: false
558
+ GMT_P0800+7:
559
+ :title: 'Singapore'
560
+ :name: 'Etc/GMT-8'
561
+ :dst: false
562
+ GMT_P0800+8:
563
+ :title: 'Taipei'
564
+ :name: 'Etc/GMT-8'
565
+ :dst: false
566
+ GMT_P0800+9:
567
+ :title: 'Ulaanbaatar'
568
+ :name: 'Etc/GMT-8'
569
+ :dst: false
570
+
571
+ gmt9: &gmt9
572
+ GMT_P0900:
573
+ :title: ''
574
+ :name: 'Etc/GMT-9'
575
+ :dst: false
576
+ GMT_P0900+1:
577
+ :title: 'Osaka'
578
+ :name: 'Etc/GMT-9'
579
+ :dst: false
580
+ GMT_P0900+2:
581
+ :title: 'Sapporo'
582
+ :name: 'Etc/GMT-9'
583
+ :dst: false
584
+ GMT_P0900+3:
585
+ :title: 'Seoul'
586
+ :name: 'Etc/GMT-9'
587
+ :dst: false
588
+ GMT_P0900+4:
589
+ :title: 'Tokyo'
590
+ :name: 'Etc/GMT-9'
591
+ :dst: false
592
+ GMT_P0900+5:
593
+ :title: 'Yakutsk'
594
+ :name: 'Etc/GMT-9'
595
+ :dst: false
596
+
597
+ gmt10: &gmt10
598
+ GMT_P1000:
599
+ :title: ''
600
+ :name: 'Etc/GMT-10'
601
+ :dst: false
602
+ GMT_P1000+1:
603
+ :title: 'Brisbane'
604
+ :name: 'Etc/GMT-10'
605
+ :dst: false
606
+ GMT_P1000+2:
607
+ :title: 'Canberra'
608
+ :name: 'Etc/GMT-10'
609
+ :dst: false
610
+ GMT_P1000+3:
611
+ :title: 'Guam'
612
+ :name: 'Etc/GMT-10'
613
+ :dst: false
614
+ GMT_P1000+4:
615
+ :title: 'Hobart'
616
+ :name: 'Etc/GMT-10'
617
+ :dst: false
618
+ GMT_P1000+5:
619
+ :title: 'Melbourne'
620
+ :name: 'Etc/GMT-10'
621
+ :dst: false
622
+ GMT_P1000+6:
623
+ :title: 'Port Moresby'
624
+ :name: 'Etc/GMT-10'
625
+ :dst: false
626
+ GMT_P1000+7:
627
+ :title: 'Sydney'
628
+ :name: 'Etc/GMT-10'
629
+ :dst: false
630
+ GMT_P1000+8:
631
+ :title: 'Vladivostok'
632
+ :name: 'Etc/GMT-10'
633
+ :dst: false
634
+ gmt11: &gmt11
635
+ GMT_P1100:
636
+ :title: ''
637
+ :name: 'Etc/GMT-11'
638
+ :dst: false
639
+ GMT_P1100+1:
640
+ :title: 'Magadan'
641
+ :name: 'Etc/GMT-11'
642
+ :dst: false
643
+ GMT_P1100+2:
644
+ :title: 'New Caledonia'
645
+ :name: 'Etc/GMT-11'
646
+ :dst: false
647
+ GMT_P1100+3:
648
+ :title: 'Solomon Is.'
649
+ :name: 'Etc/GMT-11'
650
+ :dst: false
651
+ GMT_P1100+4:
652
+ :title: 'Srednekolymsk'
653
+ :name: 'Etc/GMT-11'
654
+ :dst: false
655
+
656
+ gmt12: &gmt12
657
+ GMT_P1200:
658
+ :title: ''
659
+ :name: 'Etc/GMT-12'
660
+ :dst: false
661
+ GMT_P1200+1:
662
+ :title: 'Auckland'
663
+ :name: 'Etc/GMT-12'
664
+ :dst: false
665
+ GMT_P1200+2:
666
+ :title: 'Fiji'
667
+ :name: 'Etc/GMT-12'
668
+ :dst: false
669
+ GMT_P1200+3:
670
+ :title: 'Kamchatka'
671
+ :name: 'Etc/GMT-12'
672
+ :dst: false
673
+ GMT_P1200+4:
674
+ :title: 'Marshall Is.'
675
+ :name: 'Etc/GMT-12'
676
+ :dst: false
677
+ GMT_P1200+5:
678
+ :title: 'Wellington'
679
+ :name: 'Etc/GMT-12'
680
+ :dst: false
681
+
682
+ all_zones: &default
683
+ <<: *gmt-12
684
+ <<: *gmt-11
685
+ <<: *gmt-10
686
+ <<: *gmt-9
687
+ <<: *gmt-8
688
+ <<: *gmt-7
689
+ <<: *gmt-6
690
+ <<: *gmt-5
691
+ <<: *gmt-4
692
+ <<: *gmt-3
693
+ <<: *gmt-2
694
+ <<: *gmt-1
695
+ <<: *gmt-0
696
+ <<: *gmt1
697
+ <<: *gmt2
698
+ <<: *gmt3
699
+ <<: *gmt4
700
+ <<: *gmt5
701
+ <<: *gmt6
702
+ <<: *gmt7
703
+ <<: *gmt8
704
+ <<: *gmt9
705
+ <<: *gmt10
706
+ <<: *gmt11
707
+ <<: *gmt12
@@ -0,0 +1,49 @@
1
+ module TpCommon
2
+ module Timezones
3
+ class Zone
4
+ SECONDS_IN_AN_HOUR = 3600
5
+ DAY_LIGHT_SAVING_ZONES = ['Etc/GMT+9', 'Etc/GMT+8', 'Etc/GMT+7', 'Etc/GMT+6', 'Etc/GMT+5'].freeze
6
+
7
+ attr_reader :key
8
+
9
+ def initialize(time, key, name, title)
10
+ @name = name
11
+ @key = key
12
+ @time = time
13
+ @title = title
14
+ end
15
+
16
+ def offset
17
+ base_offset = (time_difference_in_seconds / SECONDS_IN_AN_HOUR).abs
18
+
19
+ zone = Time.find_zone(@title)
20
+ if !zone.nil? && zone.parse(@time.to_date.to_s).dst?
21
+ base_offset = base_offset - 1
22
+ end
23
+
24
+ base_offset
25
+ end
26
+
27
+ def date
28
+ gmt_12.to_date
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :time, :name
34
+
35
+ def gmt_12
36
+ time.in_time_zone('Etc/GMT-12')
37
+ end
38
+
39
+ def organization_time
40
+ time.in_time_zone(name)
41
+ end
42
+
43
+ def time_difference_in_seconds
44
+ gmt_12.utc_offset - organization_time.utc_offset
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,72 @@
1
+ module TpCommon
2
+ module Timezones
3
+ LIST_ZONES = TpCommon.load_timezones.freeze
4
+
5
+ def self.current_date_in_time_zone(time_zone_key)
6
+ self.converted_time(Time.now, time_zone_key).strftime('%Y-%m-%d %H:%M:%S').to_date
7
+ end
8
+
9
+ def self.offset_in_words(zone_name)
10
+ offset = Time.now.in_time_zone(zone_name).utc_offset
11
+ in_words = 'GMT'
12
+
13
+ hours = offset.abs / (60 * 60)
14
+
15
+ in_words << (offset > 0 ? '+' : '-')
16
+ in_words << format('%01d', hours)
17
+ in_words
18
+ end
19
+
20
+ def self.zone_title(zone)
21
+ zone_value = LIST_ZONES[zone]
22
+ return nil unless zone_value
23
+
24
+ dst_icon = zone_value[:dst] ? '☀️' : ''
25
+
26
+ [zone_value[:title], self.offset_in_words(zone_value[:name]), dst_icon].reject{|part| part.empty? }.join(" ")
27
+ end
28
+
29
+ def self.zone_title_without_dst(zone)
30
+ zone_value = LIST_ZONES[zone]
31
+ return nil unless zone_value
32
+
33
+ [zone_value[:title], self.offset_in_words(zone_value[:name])].reject{|part| part.empty? }.join(" ")
34
+ end
35
+
36
+ def self.list_for_select
37
+ LIST_ZONES.map{ |k, v| [self.zone_title(k), k] }
38
+ end
39
+
40
+ # return hash offsets. Ex: {'GMT' => 0, ...}
41
+ def self.list_zone_offsets
42
+ Hash[LIST_ZONES.map{ |k, v| [k, Time.now.in_time_zone(v[:name]).utc_offset] }]
43
+ end
44
+
45
+ def self.local_to_utc(time, zone)
46
+ zone_value = LIST_ZONES[zone]
47
+ ActiveSupport::TimeZone.new(zone_value[:name]).local_to_utc(time)
48
+ end
49
+
50
+ def self.converted_time(time, zone)
51
+ if time
52
+ zone_value = LIST_ZONES[zone]
53
+
54
+ if zone_value
55
+ time.in_time_zone(zone_value[:name])
56
+ else
57
+ time
58
+ end
59
+ end
60
+ end
61
+
62
+ def self.zone_abbreviation(time_zone_key)
63
+ zone_value = LIST_ZONES[time_zone_key]
64
+ zone_value[:name]
65
+ end
66
+
67
+ def self.relative_time_in_time_zone(time, time_zone_key)
68
+ zone = zone_abbreviation(time_zone_key)
69
+ DateTime.parse(time.strftime("%d %b %Y %H:%M:%S #{time.in_time_zone(zone).formatted_offset}"))
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module TpCommon
2
+ VERSION = "0.1.0"
3
+ end
data/lib/tp_common.rb ADDED
@@ -0,0 +1,27 @@
1
+ require "tp_common/version"
2
+ require 'active_support/all'
3
+ require 'psych'
4
+ require 'yaml'
5
+
6
+ # require 'pry-byebug'
7
+
8
+ module TpCommon
9
+ def self.load_timezones
10
+ file_path = File.join(File.dirname(__FILE__),"config/timezones.yml")
11
+ yaml = Pathname.new(file_path)
12
+
13
+ if yaml.exist?
14
+ require "erb"
15
+ (YAML.load(ERB.new(yaml.read).result) || {})["all_zones"] || {}
16
+ else
17
+ raise "Could not load configuration. No such file - #{yaml}"
18
+ end
19
+ rescue Psych::SyntaxError => e
20
+ raise "YAML syntax error occurred while parsing #{yaml}. ",
21
+ "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. ",
22
+ "Error: #{e.message}"
23
+ end
24
+ end
25
+
26
+ require "tp_common/timezones"
27
+ require "tp_common/timezones/zone"
data/tp_common.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "tp_common/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tp_common"
8
+ spec.version = TpCommon::VERSION
9
+ spec.authors = ["An Vo"]
10
+ spec.email = ["thien.an.vo.nguyen@gmail.com"]
11
+
12
+ spec.summary = "Common libraries used for TINYpulse apps"
13
+ spec.description = "Common libraries used for TINYpulse apps. i.e. Timezone, ..."
14
+ spec.homepage = "https://github.com/anvox/tp_common"
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = 'https://rubygems.org'
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.15"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "pry-byebug", '~> 0'
35
+ spec.add_development_dependency "timecop", '~> 0'
36
+
37
+ spec.add_runtime_dependency "psych", '~> 0'
38
+ spec.add_runtime_dependency "tzinfo", '~> 1.2', '>= 1.2.0'
39
+ spec.add_runtime_dependency "activesupport", '~> 4.2', '>= 4.2.0'
40
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tp_common
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - An Vo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: psych
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: tzinfo
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.2'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 1.2.0
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '1.2'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.2.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: activesupport
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '4.2'
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 4.2.0
127
+ type: :runtime
128
+ prerelease: false
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '4.2'
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 4.2.0
137
+ description: Common libraries used for TINYpulse apps. i.e. Timezone, ...
138
+ email:
139
+ - thien.an.vo.nguyen@gmail.com
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - ".gitignore"
145
+ - ".rspec"
146
+ - ".ruby-gemset"
147
+ - ".ruby-version"
148
+ - ".travis.yml"
149
+ - CODE_OF_CONDUCT.md
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - lib/config/timezones.yml
157
+ - lib/tp_common.rb
158
+ - lib/tp_common/timezones.rb
159
+ - lib/tp_common/timezones/zone.rb
160
+ - lib/tp_common/version.rb
161
+ - tp_common.gemspec
162
+ homepage: https://github.com/anvox/tp_common
163
+ licenses:
164
+ - MIT
165
+ metadata:
166
+ allowed_push_host: https://rubygems.org
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.6.10
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Common libraries used for TINYpulse apps
187
+ test_files: []