prayer_time 1.0.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: dedd11e26c84a7532fd75617e3df7856a3ee16e8
4
+ data.tar.gz: 1d789cb68fa7a90f78e72419fb668375d8b9ddb1
5
+ SHA512:
6
+ metadata.gz: 28144455f2a6a0059ddf1af035d9b1c059316e25db394b622308bda7a07cc28d105dc3ac919270015e2e41398114a7156af3b4064e6dc6d657deba25db26f722
7
+ data.tar.gz: a7272509b3dfda4f99e280625b612e319076091ba745d40f802040044b84b28c318c8b9049810e14f2e720947e91936b20b056b7afef6c9643b60334272a4a58
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prayer_time.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 ecmel
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,91 @@
1
+ # PrayerTime
2
+
3
+ This gem obtains to praying times from [Presidency of Religious Affairs](http://www.diyanet.gov.tr/)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'prayer_time'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install prayer_time
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ PrayerTime.cities("TURKIYE")
25
+ # => [{"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"ADANA", "Value"=>"500"},
26
+ # {"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"ADIYAMAN", "Value"=>"501"},
27
+ # ...
28
+
29
+ PrayerTime.towns("TURKIYE", "SAMSUN")
30
+ # =>[{"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"19 MAYIS", "Value"=>"9809"},
31
+ # {"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"ALAÇAM", "Value"=>"9810"},
32
+ # ...
33
+
34
+ PrayerTime.times("TURKIYE", "SAMSUN", "19 MAYIS")
35
+ # => {"Imsak"=>"03:26",
36
+ # "Gunes"=>"05:17",
37
+ # "Ogle"=>"12:49",
38
+ # "Ikindi"=>"16:44",
39
+ # "Aksam"=>"20:09",
40
+ # "Yatsi"=>"21:51",
41
+ # "NextImsak"=>"03:26",
42
+ # "MoonSrc"=>"d7.gif",
43
+ # "HicriTarih"=>"21 Şevval 1437",
44
+ # "MiladiTarih"=>"25.07.2016",
45
+ # "RumiTarih"=>nil,
46
+ # "Enlem"=>0,
47
+ # "Boylam"=>0,
48
+ # "KibleAcisi"=>"169",
49
+ # "UlkeAdi"=>"TÜRKİYE",
50
+ # "SehirAdi"=>"SAMSUN",
51
+ # "KibleSaati"=>"12:26",
52
+ # "GunesBatis"=>"20:01",
53
+ # "GunesDogus"=>"05:24",
54
+ # "ItemId"=>9809,
55
+ # "HolyDaysItem"=>nil}
56
+ ```
57
+ If the country hasn't any town, something like this:
58
+ ```ruby
59
+ PrayerTime.cities("BOSNA HERSEK")
60
+ # =>{"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"SARAYBOSNA(sarajevo)", "Value"=>"12029"},
61
+ # {"Disabled"=>false, "Group"=>nil, "Selected"=>false, "Text"=>"SREBRENICA", "Value"=>"12003"},
62
+ # ...
63
+
64
+ PrayerTime.towns("BOSNA HERSEK", "SREBRENICA")
65
+ # => [ ] // hasn't any town
66
+
67
+ PrayerTime.times("BOSNA HERSEK", "SREBRENICA" , "")
68
+ # => {"Imsak"=>"03:11",
69
+ # "Gunes"=>"05:18",
70
+ # "Ogle"=>"12:56",
71
+ # "Ikindi"=>"16:56",
72
+ # "Aksam"=>"20:22",
73
+ # "Yatsi"=>"22:15",
74
+ # "NextImsak"=>"03:11",
75
+ # ...
76
+ ```
77
+
78
+ ## Contributing
79
+
80
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ecmelkytz/convert_temperature.
81
+
82
+ 1. Fork it
83
+ 2. Create your feature branch (git checkout -b my-new-feature)
84
+ 3. Commit your changes (git commit -a -m 'Add some feature')
85
+ 4. Push to the branch (git push origin my-new-feature)
86
+ 5. Create a new Pull Request
87
+
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "prayer_time"
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,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,17 @@
1
+ require "prayer_time/version"
2
+ require "prayer_time/request"
3
+
4
+ module PrayerTime
5
+
6
+ def self.cities(country)
7
+ Request.new.get_cities(country)
8
+ end
9
+
10
+ def self.towns(country, city)
11
+ Request.new.get_towns(country, city)
12
+ end
13
+
14
+ def self.times(country, city, town)
15
+ Request.new.pray_times(country, city, town)
16
+ end
17
+ end
@@ -0,0 +1,68 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module PrayerTime
5
+ # Country names and numbers from Presidency of Religious Affairs
6
+ $countries = {"2" => "TURKIYE","33" => "ABD","166" => "AFGANISTAN","13" => "ALMANYA","17" => "ANDORRA","140" => "ANGOLA","125" => "ANGUILLA","90" => "ANTIGUA VE BARBUDA","199" => "ARJANTIN","25" => "ARNAVUTLUK","153" => "ARUBA","59" => "AVUSTRALYA","35" => "AVUSTURYA","5" => "AZERBAYCAN","54" => "BAHAMALAR","132" => "BAHREYN","177" => "BANGLADES","188" => "BARBADOS","208" => "BELARUS","11" => "BELCIKA","182" => "BELIZE","181" => "BENIN","51" => "BERMUDA","93" => "BIRLESIK ARAP EMIRLIGI","83" => "BOLIVYA","9" => "BOSNA HERSEK","167" => "BOTSVANA","146" => "BREZILYA","97" => "BRUNEI","44" => "BULGARISTAN","91" => "BURKINA FASO","154" => "BURMA (MYANMAR)","65" => "BURUNDI","155" => "BUTAN","156" => "CAD","43" => "CECENISTAN","16" => "CEK CUMHURIYETI","86" => "CEZAYIR","160" => "CIBUTI","61" => "CIN","26" => "DANIMARKA","180" => "DEMOKRATIK KONGO CUMHURIYETI","176" => "DOGU TIMOR","123" => "DOMINIK","72" => "DOMINIK CUMHURIYETI","139" => "EKVATOR","63" => "EKVATOR GINESI","165" => "EL SALVADOR","117" => "ENDONEZYA","175" => "ERITRE","104" => "ERMENISTAN","6" => "ESTONYA","95" => "ETYOPYA","145" => "FAS","197" => "FIJI","120" => "FILDISI SAHILI","126" => "FILIPINLER","204" => "FILISTIN","41" => "FINLANDIYA","21" => "FRANSA","79" => "GABON","109" => "GAMBIYA","143" => "GANA","111" => "GINE","58" => "GRANADA","48" => "GRONLAND","171" => "GUADELOPE","169" => "GUAM ADASI","99" => "GUATEMALA","67" => "GUNEY AFRIKA","128" => "GUNEY KORE","62" => "GURCISTAN","82" => "GUYANA","70" => "HAITI","187" => "HINDISTAN","30" => "HIRVATISTAN","4" => "HOLLANDA","66" => "HOLLANDA ANTILLERI","105" => "HONDURAS","113" => "HONG KONG","15" => "INGILTERE","124" => "IRAK","202" => "IRAN","32" => "IRLANDA","23" => "ISPANYA","205" => "ISRAIL","12" => "ISVEC","49" => "ISVICRE","8" => "ITALYA","122" => "IZLANDA","119" => "JAMAIKA","116" => "JAPONYA","161" => "KAMBOCYA","184" => "KAMERUN","52" => "KANADA","34" => "KARADAG","94" => "KATAR","92" => "KAZAKISTAN","114" => "KENYA","168" => "KIRGIZISTAN","57" => "KOLOMBIYA","88" => "KOMORLAR","18" => "KOSOVA","162" => "KOSTARIKA","209" => "KUBA","206" => "KUDUS","133" => "KUVEYT","1" => "KUZEY KIBRIS","142" => "KUZEY KORE","134" => "LAOS","174" => "LESOTO","20" => "LETONYA","73" => "LIBERYA","203" => "LIBYA","38" => "LIECHTENSTEIN","47" => "LITVANYA","42" => "LUBNAN","31" => "LUKSEMBURG","7" => "MACARISTAN","98" => "MADAGASKAR","100" => "MAKAO","28" => "MAKEDONYA","55" => "MALAVI","103" => "MALDIVLER","107" => "MALEZYA","152" => "MALI","24" => "MALTA","87" => "MARTINIK","164" => "MAURITIUS ADASI","157" => "MAYOTTE","53" => "MEKSIKA","85" => "MIKRONEZYA","189" => "MISIR","60" => "MOGOLISTAN","46" => "MOLDAVYA","3" => "MONAKO","147" => "MONTSERRAT (U.K.)","106" => "MORITANYA","151" => "MOZAMBIK","196" => "NAMBIYA","76" => "NEPAL","84" => "NIJER","127" => "NIJERYA","141" => "NIKARAGUA","178" => "NIUE","36" => "NORVEC","80" => "ORTA AFRIKA CUMHURIYETI","131" => "OZBEKISTAN","77" => "PAKISTAN","149" => "PALAU","89" => "PANAMA","185" => "PAPUA YENI GINE","194" => "PARAGUAY","69" => "PERU","183" => "PITCAIRN ADASI","39" => "POLONYA","45" => "PORTEKIZ","68" => "PORTO RIKO","112" => "REUNION","37" => "ROMANYA","81" => "RUANDA","207" => "RUSYA","198" => "SAMOA","102" => "SENEGAL","138" => "SEYSEL ADALARI","200" => "SILI","179" => "SINGAPUR","27" => "SIRBISTAN","14" => "SLOVAKYA","19" => "SLOVENYA","150" => "SOMALI","74" => "SRI LANKA","129" => "SUDAN","172" => "SURINAM","191" => "SURIYE","64" => "SUUDI ARABISTAN","163" => "SVALBARD","170" => "SVAZILAND","101" => "TACIKISTAN","110" => "TANZANYA","137" => "TAYLAND","108" => "TAYVAN","71" => "TOGO","130" => "TONGA","96" => "TRINIDAT VE TOBAGO","118" => "TUNUS","159" => "TURKMENISTAN","75" => "UGANDA","40" => "UKRAYNA","29" => "UKRAYNA","173" => "UMMAN","192" => "URDUN","201" => "URUGUAY","56" => "VANUATU","10" => "VATIKAN","186" => "VENEZUELA","135" => "VIETNAM","148" => "YEMEN","115" => "YENI KALEDONYA","193" => "YENI ZELLANDA","144" => "YESIL BURUN","22" => "YUNANISTAN","158" => "ZAMBIYA","136" => "ZIMBABVE"}
7
+
8
+ class Request
9
+ def initialize
10
+ @cities_url = "http://www.diyanet.gov.tr/PrayerTime/FillState?countryCode="
11
+ @towns_url = "http://www.diyanet.gov.tr/PrayerTime/FillCity?itemId="
12
+ @time_url = "http://www.diyanet.gov.tr/PrayerTime/PrayerTimesSet"
13
+ end
14
+
15
+ def get_cities(country)
16
+ begin
17
+ if $countries.key(country)
18
+ response = RestClient.get(@cities_url + $countries.key(country))
19
+ JSON.parse(response)
20
+ else
21
+ return nil
22
+ end
23
+ rescue RestClient::ExceptionWithResponse => err
24
+ err.response
25
+ end
26
+ end
27
+
28
+ def get_towns(country, city)
29
+ begin
30
+ if get_cities(country)
31
+ if get_cities(country).select{|c| c if c["Text"] == city} != []
32
+ city_id = get_cities(country).select{|c| c if c["Text"] == city}.first["Value"]
33
+ response = RestClient.get(@towns_url + city_id)
34
+ JSON.parse(response)
35
+ else
36
+ return nil
37
+ end
38
+ else
39
+ return nil
40
+ end
41
+ rescue RestClient::ExceptionWithResponse => err
42
+ err.response
43
+ end
44
+ end
45
+
46
+ def pray_times(country, city, town)
47
+ begin
48
+ if !get_towns(country, city).nil?
49
+ city_id = get_cities(country).select{|c| c if c["Text"] == city}.first["Value"]
50
+ if get_towns(country, city).select{|t| t if t["Text"] == town} != []
51
+ town_id = get_towns(country, city).select{|t| t if t["Text"] == town}.first["Value"]
52
+ response = RestClient.post(@time_url, :countryName => $countries.key(country), :stateName => city_id, :name => town_id)
53
+ JSON.parse(response)
54
+ elsif get_towns(country, city).select{|t| t if t["Text"] == town} == []
55
+ response = RestClient.post(@time_url, :countryName => $countries.key(country), :name => city_id)
56
+ JSON.parse(response)
57
+ else
58
+ return nil
59
+ end
60
+ else
61
+ return nil
62
+ end
63
+ rescue RestClient::ExceptionWithResponse => err
64
+ err.response
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ module PrayerTime
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prayer_time/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prayer_time"
8
+ spec.version = PrayerTime::VERSION
9
+ spec.authors = ["Ecmel Kaytazoğlu"]
10
+ spec.email = ["ecmel.kytz@gmail.com"]
11
+
12
+ spec.summary = "This gem obtains to praying times from Presidency of Religious Affairs"
13
+ spec.description = "This gem obtains to praying times from Presidency of Religious Affairs"
14
+ spec.homepage = "https://github.com/ecmelkytz/prayer-times"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_runtime_dependency "rest-client"
25
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prayer_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ecmel Kaytazoğlu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-25 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem obtains to praying times from Presidency of Religious Affairs
56
+ email:
57
+ - ecmel.kytz@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - lib/prayer_time.rb
70
+ - lib/prayer_time/request.rb
71
+ - lib/prayer_time/version.rb
72
+ - prayer_time.gemspec
73
+ homepage: https://github.com/ecmelkytz/prayer-times
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: This gem obtains to praying times from Presidency of Religious Affairs
97
+ test_files: []