hurriyet 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hurriyet/client.rb +26 -0
- data/lib/hurriyet/service/api_operation/list.rb +2 -2
- data/lib/hurriyet/service/api_operation/show.rb +10 -0
- data/lib/hurriyet/service/article.rb +1 -2
- data/lib/hurriyet/service/base.rb +31 -5
- data/lib/hurriyet/service/column.rb +13 -0
- data/lib/hurriyet/service/news_photo_gallery.rb +13 -0
- data/lib/hurriyet/service/page.rb +13 -0
- data/lib/hurriyet/service/path.rb +14 -0
- data/lib/hurriyet/service/writer.rb +15 -0
- data/lib/hurriyet.rb +0 -1
- metadata +7 -2
- data/lib/main.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77a38e5cb97504aea7c46a832e05211ac4930d7a
|
4
|
+
data.tar.gz: 2ed376c6b2585d6ff3096e0487f4ae353ca1add8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6f9c6fe219c2d7f5fdcb3ddd2ef5d8e86e3935fc7ce2b64b4c52b8124ab8b9a869f8cb04e180284d1b1c2899838ab8aca2939129b5c6056330b1c24737d925
|
7
|
+
data.tar.gz: d71ab554f33ae55e889eea68dc602e1f37ad270d7d55a23844b5f7618a61be12da84ae9bb981a0e8d8f509d9175d918d62f554a422f96773698678617c07441c
|
data/lib/hurriyet/client.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
require 'hurriyet/service/article'
|
2
|
+
require 'hurriyet/service/column'
|
3
|
+
require 'hurriyet/service/news_photo_gallery'
|
4
|
+
require 'hurriyet/service/page'
|
5
|
+
require 'hurriyet/service/path'
|
6
|
+
require 'hurriyet/service/writer'
|
7
|
+
|
2
8
|
module Hurriyet
|
3
9
|
class Client
|
4
10
|
attr_accessor :apikey
|
@@ -9,5 +15,25 @@ module Hurriyet
|
|
9
15
|
def articles
|
10
16
|
Service::Article.new self
|
11
17
|
end
|
18
|
+
|
19
|
+
def columns
|
20
|
+
Service::Column.new self
|
21
|
+
end
|
22
|
+
|
23
|
+
def news_photo_galleries
|
24
|
+
Service::NewsPhotoGallery.new self
|
25
|
+
end
|
26
|
+
|
27
|
+
def pages
|
28
|
+
Service::Page.new self
|
29
|
+
end
|
30
|
+
|
31
|
+
def paths
|
32
|
+
Service::Path.new self
|
33
|
+
end
|
34
|
+
|
35
|
+
def writers
|
36
|
+
Service::Writer.new self
|
37
|
+
end
|
12
38
|
end
|
13
39
|
end
|
@@ -1,18 +1,44 @@
|
|
1
1
|
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require 'hurriyet/service/api_operation/list'
|
4
|
+
require 'hurriyet/service/api_operation/show'
|
2
5
|
module Hurriyet
|
3
6
|
module Service
|
4
7
|
class Base
|
5
8
|
attr_accessor :client
|
6
|
-
|
9
|
+
ALLOWED_PARAMETERS = %w(filter select top).map!(&:to_sym).freeze
|
7
10
|
def initialize(client)
|
8
11
|
@client = client
|
9
12
|
@conn = Faraday.new(url: 'https://api.hurriyet.com.tr', headers: { apikey: @client.apikey })
|
10
13
|
end
|
11
14
|
|
12
|
-
def execute(endpoint)
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
def execute(endpoint, options = {})
|
16
|
+
@options = options
|
17
|
+
@endpoint = endpoint
|
18
|
+
make_call
|
19
|
+
end
|
20
|
+
|
21
|
+
def make_call
|
22
|
+
resp = @conn.get(url)
|
23
|
+
JSON.parse(resp.body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def url
|
27
|
+
"/#{version}/#{@endpoint}#{param_string}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def param_string
|
31
|
+
string = ''
|
32
|
+
@options.each_with_index do |(key, value), index|
|
33
|
+
raise unless allowed?(key)
|
34
|
+
prefix = index == 0 ? '?' : '&'
|
35
|
+
string << "#{prefix}$#{key}=#{value}"
|
36
|
+
end
|
37
|
+
string
|
38
|
+
end
|
39
|
+
|
40
|
+
def allowed?(key)
|
41
|
+
ALLOWED_PARAMETERS.include? key
|
16
42
|
end
|
17
43
|
|
18
44
|
def version
|
data/lib/hurriyet.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hurriyet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yigit Ozkavci
|
@@ -33,9 +33,14 @@ files:
|
|
33
33
|
- lib/hurriyet.rb
|
34
34
|
- lib/hurriyet/client.rb
|
35
35
|
- lib/hurriyet/service/api_operation/list.rb
|
36
|
+
- lib/hurriyet/service/api_operation/show.rb
|
36
37
|
- lib/hurriyet/service/article.rb
|
37
38
|
- lib/hurriyet/service/base.rb
|
38
|
-
- lib/
|
39
|
+
- lib/hurriyet/service/column.rb
|
40
|
+
- lib/hurriyet/service/news_photo_gallery.rb
|
41
|
+
- lib/hurriyet/service/page.rb
|
42
|
+
- lib/hurriyet/service/path.rb
|
43
|
+
- lib/hurriyet/service/writer.rb
|
39
44
|
homepage: http://rubygems.org/gems/hurriyet
|
40
45
|
licenses:
|
41
46
|
- MIT
|
data/lib/main.rb
DELETED