alquran 0.0.0 → 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 +4 -4
- data/lib/alquran/ayah.rb +4 -4
- data/lib/alquran/base.rb +1 -1
- data/lib/alquran/edition.rb +2 -2
- data/lib/alquran/parah.rb +10 -8
- data/lib/alquran/surah.rb +3 -3
- data/lib/alquran.rb +0 -1
- data/lib/api/client.rb +2 -2
- data/lib/api/url_parser.rb +9 -9
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21326630848efbfefbe686f0137cc16e0a4631e6a36e982724296d06b1f1a606
|
4
|
+
data.tar.gz: b48384e8f0c33630460db0f2a5e351caadcc6f7222f0ae9f754e2a6aff02c3e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c8a3aabce4e7a031910b14e073f476fc46be1ae50eed29244ff8e4138442aab0cbd82b20877f81ca3fcea810763cf6faf2df1f37554726ef7e768b2823bb43
|
7
|
+
data.tar.gz: ec3487ffe6c77ae4eba56e4fdd0e53c39d7eb27a8796f7f9e38b4bbb2b0db79e5908632d53bc8b1a795ea6c3e47e1ab348e79069ea384c50085dd00107bf529d
|
data/lib/alquran/ayah.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Alquran
|
2
2
|
class Ayah < Base
|
3
3
|
class << self
|
4
|
-
def fetch(
|
5
|
-
Api::Client.fetch(filter_options(options))
|
4
|
+
def fetch(options)
|
5
|
+
Api::Client.fetch(filter_options(**options))
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
@@ -11,8 +11,8 @@ module Alquran
|
|
11
11
|
options.slice(:number).merge(self.entity_option).merge(action: :show).merge(extras: edition_option)
|
12
12
|
end
|
13
13
|
|
14
|
-
def filter_options(
|
15
|
-
return show_options(options) unless options.has_key?(:sajdah)
|
14
|
+
def filter_options(options)
|
15
|
+
return show_options(**options) unless options.has_key?(:sajdah)
|
16
16
|
|
17
17
|
action_option = { action: :sajdah }
|
18
18
|
|
data/lib/alquran/base.rb
CHANGED
data/lib/alquran/edition.rb
CHANGED
@@ -2,11 +2,11 @@ module Alquran
|
|
2
2
|
class Edition < Base
|
3
3
|
class << self
|
4
4
|
def fetch(**options)
|
5
|
-
Api::Client.fetch(filter_options(options))
|
5
|
+
Api::Client.fetch(filter_options(**options))
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
9
|
-
def filter_options(**
|
9
|
+
def filter_options(**_options)
|
10
10
|
self.entity_option.merge(action: :index)
|
11
11
|
end
|
12
12
|
end
|
data/lib/alquran/parah.rb
CHANGED
@@ -2,7 +2,7 @@ module Alquran
|
|
2
2
|
class Parah < Base
|
3
3
|
class << self
|
4
4
|
def fetch(**options)
|
5
|
-
Api::Client.fetch(filter_options(options))
|
5
|
+
Api::Client.fetch(filter_options(**options))
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
@@ -19,19 +19,21 @@ module Alquran
|
|
19
19
|
return show_options(options[:number]) unless options.has_key?(:collection)
|
20
20
|
|
21
21
|
action_option = case options
|
22
|
-
when -> (opts) { opts[:collection]
|
22
|
+
when -> (opts) { opts[:collection] == :surahs }
|
23
23
|
{ action: :surahs }
|
24
|
-
when -> (opts) { opts[:collection]
|
24
|
+
when -> (opts) { opts[:collection] == :ayahs }
|
25
25
|
{ action: :ayahs }
|
26
26
|
else
|
27
27
|
raise RuntimeApiError.new
|
28
28
|
end
|
29
29
|
|
30
|
-
extra_options =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
extra_options = if action_option[:action] == :ayahs
|
31
|
+
{
|
32
|
+
offset: options[:offset],
|
33
|
+
limit: options[:limit],
|
34
|
+
sajdah: options[:sajdah]
|
35
|
+
}.compact
|
36
|
+
end
|
35
37
|
|
36
38
|
options.slice(:number).merge(self.entity_option).merge(action_option).merge(extras: extra_options)
|
37
39
|
end
|
data/lib/alquran/surah.rb
CHANGED
@@ -2,7 +2,7 @@ module Alquran
|
|
2
2
|
class Surah < Base
|
3
3
|
class << self
|
4
4
|
def fetch(**options)
|
5
|
-
Api::Client.fetch(filter_options(options))
|
5
|
+
Api::Client.fetch(filter_options(**options))
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
@@ -10,14 +10,14 @@ module Alquran
|
|
10
10
|
self.entity_option.merge(action: :index)
|
11
11
|
end
|
12
12
|
|
13
|
-
def show_options(options)
|
13
|
+
def show_options(**options)
|
14
14
|
edition_option = { edition: options[:edition] }.compact
|
15
15
|
options.slice(:number).merge(self.entity_option).merge(action: :show).merge(extras: edition_option)
|
16
16
|
end
|
17
17
|
|
18
18
|
def filter_options(**options)
|
19
19
|
return index_options unless options.has_key?(:number)
|
20
|
-
return show_options(options) unless has_extra_option?(options)
|
20
|
+
return show_options(**options) unless has_extra_option?(**options)
|
21
21
|
|
22
22
|
action_option = { action: :ayahs }
|
23
23
|
|
data/lib/alquran.rb
CHANGED
data/lib/api/client.rb
CHANGED
data/lib/api/url_parser.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
module Api
|
2
2
|
module UrlParser
|
3
|
-
|
4
|
-
|
3
|
+
BASE_URL = 'http://api.alquranpak.com'
|
4
|
+
|
5
5
|
RELATIVE_PARAH_PATH = 'parahs'
|
6
6
|
RELATIVE_SURAH_PATH = 'surahs'
|
7
7
|
RELATIVE_AYAH_PATH = 'ayahs'
|
8
8
|
RELATIVE_EDITION_PATH = 'editions'
|
9
9
|
|
10
|
-
def parse_url(
|
11
|
-
method_name = "handle_#{params[:entity]
|
12
|
-
self.send(method_name, params)
|
10
|
+
def parse_url(params)
|
11
|
+
method_name = "handle_#{params[:entity]}_urls"
|
12
|
+
self.send(method_name, **params)
|
13
13
|
end
|
14
14
|
|
15
|
-
def handle_parah_urls(
|
15
|
+
def handle_parah_urls(params)
|
16
16
|
case params[:action]
|
17
17
|
when :index then [BASE_URL, RELATIVE_PARAH_PATH].join('/')
|
18
18
|
when :show then [BASE_URL, RELATIVE_PARAH_PATH, params[:number]].join('/')
|
@@ -23,7 +23,7 @@ module Api
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def handle_surah_urls(
|
26
|
+
def handle_surah_urls(params)
|
27
27
|
case params[:action]
|
28
28
|
when :index then [BASE_URL, RELATIVE_SURAH_PATH].join('/')
|
29
29
|
when :show
|
@@ -35,7 +35,7 @@ module Api
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def handle_ayah_urls(
|
38
|
+
def handle_ayah_urls(params)
|
39
39
|
case params[:action]
|
40
40
|
when :show
|
41
41
|
relative_url = [BASE_URL, RELATIVE_AYAH_PATH, params[:number]].join('/')
|
@@ -44,7 +44,7 @@ module Api
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def handle_edition_urls(
|
47
|
+
def handle_edition_urls(params)
|
48
48
|
[BASE_URL, RELATIVE_EDITION_PATH, params[:number]].join('/')
|
49
49
|
end
|
50
50
|
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alquran
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahsan Ellahi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-03 00:00:00.000000000 Z
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.17.1
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -54,10 +54,11 @@ files:
|
|
54
54
|
- lib/api/client.rb
|
55
55
|
- lib/api/url_parser.rb
|
56
56
|
- lib/extensions.rb
|
57
|
-
homepage:
|
58
|
-
licenses:
|
57
|
+
homepage: https://github.com/ahsanellahi/alquran
|
58
|
+
licenses:
|
59
|
+
- MIT
|
59
60
|
metadata: {}
|
60
|
-
post_install_message:
|
61
|
+
post_install_message:
|
61
62
|
rdoc_options: []
|
62
63
|
require_paths:
|
63
64
|
- lib
|
@@ -65,15 +66,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
+
version: 2.5.0
|
69
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
71
|
requirements:
|
71
72
|
- - ">="
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
76
|
-
signing_key:
|
76
|
+
rubygems_version: 3.1.2
|
77
|
+
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: Provides all the information regarding the Holy Quran (Book)
|
79
80
|
test_files: []
|