timez 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0d5ce4e8b42bb8424c6c3ada8f3b33ad73c6a5db
4
+ data.tar.gz: 4fc7b54496ddc7e48fd3507b5b8676694a42d3a7
5
+ SHA512:
6
+ metadata.gz: 0a57fdddae7d0c951007dc1f24310c3099522f0a78548bd97a96954a8aeb1608e7159ba88285b8cf4d7f5edc0e0a7dc0bab57c1432febc333ffa741dd1845b03
7
+ data.tar.gz: 07cc691047dada48deb00175ff8bad448b02081df71c33cdabacc3808d2c2694707dae55f3d604945c51b37b07faa5652cac26d0315b21aeb441af03df0cb433
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in timez.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Dilum Navanjana
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,57 @@
1
+ # Timez
2
+
3
+ Timez is the API implementation of timezonedb for Ruby. Can use to get World Clock from the time zone or location for the Ruby Applications by json or xml.
4
+
5
+ Timez gem use the power of [celluloid](https://github.com/celluloid/celluloid) for concurrent API requests.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'timez'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install timez
22
+
23
+ ## Usage
24
+
25
+ First of all Register on [timezonedb](http://timezonedb.com/register) to get your key to access the API.
26
+
27
+ **Get Time by time zone,**
28
+ ```ruby
29
+ time = Timez.get_time('Asia/Colombo', 'YOUR_API_KEY')
30
+ ```
31
+
32
+ Here is the time zone list, [time zone list](http://timezonedb.com/time-zones)
33
+
34
+ **Get Time by location,**
35
+ ```ruby
36
+ time = Timez::Location.get_time('LATITUDE', 'LONGITUDE', 'YOUR_API_KEY')
37
+ ```
38
+
39
+ **Get Time as XML,**
40
+ ```ruby
41
+ time = Timez::Xml.get_time('Asia/Colombo', 'YOUR_API_KEY')
42
+ ```
43
+
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/abstractive/timez/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
52
+
53
+ ---
54
+
55
+ **Developer:** @[dilumnavanjana](https://github.com/dilumnavanjana)
56
+
57
+ **Mentor:** @[digitalextremist](https://github.com/digitalextremist)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "timez"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/timez.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'timez/location'
2
+ require 'timez/xml'
3
+ require 'http'
4
+ require 'json'
5
+
6
+ $URL = "http://api.timezonedb.com"
7
+
8
+ module Timez
9
+
10
+ class << self
11
+
12
+ def get_time(time_zone, key)
13
+ response = HTTP.get($URL, :params => { :zone => time_zone, :key => key, :format => "json" }).to_s
14
+ JSON[response]
15
+ end
16
+
17
+ def get_time_utc(time_zone, key)
18
+ hash = get_time(time_zone, key)
19
+ Time.at(hash['timestamp']).utc
20
+ end
21
+
22
+ def get_time_zone(time_zone, key)
23
+ hash = get_time(time_zone, key)
24
+ Time.at(hash['timestamp'])
25
+ end
26
+
27
+ def get_time_timestamp(time_zone, key)
28
+ hash = get_time(time_zone, key)
29
+ hash['timestamp']
30
+ end
31
+
32
+ def get_time_json(time_zone, key)
33
+ get_time(time_zone, key)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ module Timez
2
+ class Location
3
+
4
+ def self.get_time(lat, lng, key)
5
+ response = HTTP.get($URL, :params => { :lat => lat, :lng => lng, :key => key, :format => "json" }).to_s
6
+ JSON[response]
7
+ end
8
+
9
+ def self.get_time_utc(lat, lng, key)
10
+ hash = get_time(lat, lng, key)
11
+ Time.at(hash['timestamp']).utc
12
+ end
13
+
14
+ def self.get_time_zone(lat, lng, key)
15
+ hash = get_time(lat, lng, key)
16
+ Time.at(hash['timestamp'])
17
+ end
18
+
19
+ def self.get_time_timestamp(lat, lng, key)
20
+ hash = get_time(lat, lng, key)
21
+ hash['timestamp']
22
+ end
23
+
24
+ def self.get_time_json(lat, lng, key)
25
+ get_time(lat, lng, key)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Timez
2
+ VERSION = "0.0.3"
3
+ end
data/lib/timez/xml.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Timez
2
+ class Xml
3
+
4
+ def self.get_time(time_zone, key)
5
+ response = HTTP.get($URL, :params => { :zone => time_zone, :key => key, :format => "xml" }).to_s
6
+ end
7
+
8
+ def self.get_time_location(lat, lng, key)
9
+ response = HTTP.get($URL, :params => { :lat => lat, :lng => lng, :key => key, :format => "xml" }).to_s
10
+ end
11
+
12
+ end
13
+ end
data/timez.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'timez/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "timez"
8
+ spec.version = Timez::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ["Dilum Navanjana"]
11
+ spec.email = ["dilumnavanjana@gmail.com"]
12
+
13
+ spec.summary = "timezonedb API implementation for RUBY"
14
+ spec.description = "Can use to get World Clock from the time zone or location for the Ruby Applications."
15
+ spec.homepage = "https://github.com/abstractive/timez"
16
+ spec.license = "MIT"
17
+
18
+ # spec.required_ruby_version = ">= 1.9.2"
19
+ # spec.required_rubygems_version = ">= 1.3.6"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timez
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Dilum Navanjana
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Can use to get World Clock from the time zone or location for the Ruby
14
+ Applications.
15
+ email:
16
+ - dilumnavanjana@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".travis.yml"
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - lib/timez.rb
31
+ - lib/timez/location.rb
32
+ - lib/timez/version.rb
33
+ - lib/timez/xml.rb
34
+ - timez.gemspec
35
+ homepage: https://github.com/abstractive/timez
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.2.2
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: timezonedb API implementation for RUBY
59
+ test_files: []