alquran 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0d4684603e83ea987b54a2bce6e433dc356f3f5b47e2808708f2fee109ea680
4
- data.tar.gz: 642d68cb747f4eb031683ea227f9f4fee91e22428860fe83e243b8789cc37bc4
3
+ metadata.gz: 21326630848efbfefbe686f0137cc16e0a4631e6a36e982724296d06b1f1a606
4
+ data.tar.gz: b48384e8f0c33630460db0f2a5e351caadcc6f7222f0ae9f754e2a6aff02c3e1
5
5
  SHA512:
6
- metadata.gz: 7183f3d14f11371d041907989598293b9ebf3cb2033cacdaa8bcb15d2d5d1eceb34806e97575e8beb8795ac2c73d4f3a27efd6a5a7ff49d15eb3a7eaa265219d
7
- data.tar.gz: f57f0a15e00fbc48ecf64f4d565605531f9e6d44e09bc054435ee8f6be900076f9d0964148f22795c4e95f2aa6091835630f19345363359f4486fa081bf3c2d0
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(**options)
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(**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
@@ -3,7 +3,7 @@ module Alquran
3
3
  class << self
4
4
  protected
5
5
  def entity_option
6
- { entity: self.name.demodulize.downcase.to_sym }
6
+ { entity: self.name.split('::').last.downcase.to_sym }
7
7
  end
8
8
  end
9
9
  end
@@ -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(**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] === :surahs }
22
+ when -> (opts) { opts[:collection] == :surahs }
23
23
  { action: :surahs }
24
- when -> (opts) { opts[:collection] === :ayahs }
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
- offset: options[:offset],
32
- limit: options[:limit],
33
- sajdah: options[:sajdah]
34
- }.compact
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
@@ -1,5 +1,4 @@
1
1
  require 'httparty'
2
- require 'active_support/inflector'
3
2
 
4
3
  require_relative 'alquran/base'
5
4
  require_relative 'alquran/parah'
data/lib/api/client.rb CHANGED
@@ -3,8 +3,8 @@ module Api
3
3
  extend UrlParser
4
4
 
5
5
  class << self
6
- def fetch(**options)
7
- get(parse_url(options))
6
+ def fetch(options)
7
+ get(parse_url(**options))
8
8
  end
9
9
 
10
10
  private
@@ -1,18 +1,18 @@
1
1
  module Api
2
2
  module UrlParser
3
- # BASE_URL = 'http://api.alquranpak.com'
4
- BASE_URL = 'http://localhost:3001'
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(**params)
11
- method_name = "handle_#{params[:entity].to_s}_urls"
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(**params)
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(**params)
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(**params)
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(**params)
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: 0.0.0
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: :development
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: '0'
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.0.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: []