hurriyet_cli 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/hurriyet_cli.gemspec +2 -2
- data/lib/hurriyet_cli/articles.rb +9 -13
- data/lib/hurriyet_cli/cli.rb +17 -13
- data/lib/hurriyet_cli/columns.rb +11 -8
- data/lib/hurriyet_cli/pages.rb +11 -8
- data/lib/hurriyet_cli/version.rb +1 -1
- data/lib/hurriyet_cli/writers.rb +11 -8
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367e725fe44920ee1a769597f32fa9c9d9820ad2
|
4
|
+
data.tar.gz: dbaf872b454846adceefa3cfc588106eaef105d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78e2fba2963f2aa51e2b086878331af7e7b4710a36a3e388679fb10318b0d315c201e18f832ecd48d38c050b289faed0092dad26327400ac25b353508959f1bc
|
7
|
+
data.tar.gz: f0045ce161523452927cfa0adc1e93d9b826d1d468e8f323ac833f38e7f6dd1fb7793af290bacfde9db57812413abec7e16a967b85c3e651ced7fabf11b79c58
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# HurriyetCli
|
2
2
|
|
3
|
-
A Ruby CLI for Hurriyet Public API.
|
3
|
+
A Ruby CLI for [Hurriyet Public API]( http://developers.hurriyet.com.tr/).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,13 +20,17 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Export your API_KEY that you get from https://developers.hurriyet.com.tr
|
23
|
+
Export your ```API_KEY``` that you get from [https://developers.hurriyet.com.tr](https://developers.hurriyet.com.tr)
|
24
24
|
|
25
25
|
```bash
|
26
26
|
$ bundle exec bin/hurriyet_cli articles # Fetch all articles
|
27
27
|
$ bundle exec bin/hurriyet_cli articles --top 5 # Fetch top 5 articles
|
28
28
|
```
|
29
29
|
|
30
|
+
## Thanks
|
31
|
+
* [Yiğit Özkavcı](https://github.com/yigitozkavci/) for Ruby Hurriyet API Wrapper.
|
32
|
+
* [Hamdi Akoğuz](https://github.com/Hamdiakoguz) for his advices.
|
33
|
+
|
30
34
|
## License
|
31
35
|
|
32
36
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/hurriyet_cli.gemspec
CHANGED
@@ -15,8 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = "
|
19
|
-
spec.executables =
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = ["hurriyet_cli"]
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.12"
|
@@ -1,29 +1,25 @@
|
|
1
1
|
module HurriyetCli
|
2
2
|
class Articles
|
3
|
-
def
|
4
|
-
client =
|
5
|
-
|
6
|
-
formated_parse(articles)
|
3
|
+
def initialize(client, display = STDOUT)
|
4
|
+
@client = client
|
5
|
+
@display = display
|
7
6
|
end
|
8
7
|
|
9
|
-
def
|
10
|
-
|
11
|
-
articles = client.articles.all top: top
|
8
|
+
def fetch
|
9
|
+
articles = @client.articles.all
|
12
10
|
formated_parse(articles)
|
13
11
|
end
|
14
12
|
|
15
|
-
def
|
16
|
-
|
17
|
-
binding.pry
|
18
|
-
articles = client.articles.all filter: "'#{source} eq \'#{key}\''"
|
13
|
+
def top_articles(top)
|
14
|
+
articles = @client.articles.all top: top
|
19
15
|
formated_parse(articles)
|
20
16
|
end
|
21
17
|
|
22
18
|
private
|
23
|
-
def
|
19
|
+
def formated_parse(articles)
|
24
20
|
articles.each do |a|
|
25
21
|
created_at = Time.parse(a["CreatedDate"]).strftime("%d/%m/%y|%H:%M")
|
26
|
-
puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
|
22
|
+
@display.puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
data/lib/hurriyet_cli/cli.rb
CHANGED
@@ -5,54 +5,58 @@ require "thor/runner"
|
|
5
5
|
module HurriyetCli
|
6
6
|
class HammerOfTheGods < Thor
|
7
7
|
desc "articles", "Fetch all articles"
|
8
|
-
method_option :top,
|
9
|
-
# method_options [:source, :key]
|
8
|
+
method_option :top, desc: "Fetch N articles"
|
10
9
|
def articles
|
10
|
+
client = Hurriyet::Client.new(ENV['API_KEY'])
|
11
|
+
articles = HurriyetCli::Articles.new(client)
|
11
12
|
if options[:top]
|
12
13
|
puts "Fetching #{options[:top]} articles"
|
13
|
-
|
14
|
-
elsif options[:source]
|
15
|
-
# puts "Fetching #{options[:source]} by #{options[:key]} articles"
|
16
|
-
# HurriyetCli::Articles.filter_by(options[:source], options[:key])
|
14
|
+
articles.top_articles(options[:top])
|
17
15
|
else
|
18
16
|
puts "Fetching all articles"
|
19
|
-
|
17
|
+
articles.fetch
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
21
|
desc "columns", "Fetch all columns"
|
24
22
|
method_option :top, alias: :t, desc: "Fetch N columns"
|
25
23
|
def columns
|
24
|
+
client = Hurriyet::Client.new(ENV['API_KEY'])
|
25
|
+
columns = HurriyetCli::Columns.new(client)
|
26
26
|
if options[:top]
|
27
27
|
puts "Fetching #{options[:top]} columns"
|
28
|
-
|
28
|
+
columns.top_columns(options[:top])
|
29
29
|
else
|
30
30
|
puts "Fetching all columns"
|
31
|
-
|
31
|
+
columns.fetch
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
desc "pages", "Fetch all pages"
|
36
36
|
method_option :top, alias: :t, desc: "Fetch N pages"
|
37
37
|
def pages
|
38
|
+
client = Hurriyet::Client.new(ENV['API_KEY'])
|
39
|
+
pages = HurriyetCli::Pages.new(client)
|
38
40
|
if options[:top]
|
39
41
|
puts "Fetching #{options[:top]} pages"
|
40
|
-
|
42
|
+
pages.top_pages(options[:top])
|
41
43
|
else
|
42
44
|
puts "Fetching all pages"
|
43
|
-
|
45
|
+
pages.fetch
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
desc "writers", "Fetch all writers"
|
48
50
|
method_option :top, alias: :t, desc: "Fetch N writers"
|
49
51
|
def writers
|
52
|
+
client = Hurriyet::Client.new(ENV['API_KEY'])
|
53
|
+
writers = HurriyetCli::Writers.new(client)
|
50
54
|
if options[:top]
|
51
55
|
puts "Fetching #{options[:top]} writers"
|
52
|
-
|
56
|
+
writers.top_writers(options[:top])
|
53
57
|
else
|
54
58
|
puts "Fetching all writers"
|
55
|
-
|
59
|
+
writers.fetch
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|
data/lib/hurriyet_cli/columns.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
module HurriyetCli
|
2
2
|
class Columns
|
3
|
-
def
|
4
|
-
client =
|
5
|
-
|
3
|
+
def initialize(client, display = STDOUT)
|
4
|
+
@client = client
|
5
|
+
@display = display
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch
|
9
|
+
columns = @client.columns.all
|
6
10
|
formated_parse(columns)
|
7
11
|
end
|
8
12
|
|
9
|
-
def
|
10
|
-
|
11
|
-
columns = client.columns.all top: top
|
13
|
+
def top_columns(top)
|
14
|
+
columns = @client.columns.all top: top
|
12
15
|
formated_parse(columns)
|
13
16
|
end
|
14
17
|
|
15
18
|
private
|
16
|
-
def
|
19
|
+
def formated_parse(columns)
|
17
20
|
columns.each do |a|
|
18
21
|
created_at = Time.parse(a["CreatedDate"]).strftime("%d/%m/%y|%H:%M")
|
19
|
-
puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Fullname"]).orange} - #{Rainbow(a["Url"]).cyan}"
|
22
|
+
@display.puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Fullname"]).orange} - #{Rainbow(a["Url"]).cyan}"
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
data/lib/hurriyet_cli/pages.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
module HurriyetCli
|
2
2
|
class Pages
|
3
|
-
def
|
4
|
-
client =
|
5
|
-
|
3
|
+
def initialize(client, display = STDOUT)
|
4
|
+
@client = client
|
5
|
+
@display = display
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch
|
9
|
+
pages = @client.pages.all
|
6
10
|
formated_parse(pages)
|
7
11
|
end
|
8
12
|
|
9
|
-
def
|
10
|
-
|
11
|
-
pages = client.pages.all top: top
|
13
|
+
def top_pages(top)
|
14
|
+
pages = @client.pages.all top: top
|
12
15
|
formated_parse(pages)
|
13
16
|
end
|
14
17
|
|
15
18
|
private
|
16
|
-
def
|
19
|
+
def formated_parse(pages)
|
17
20
|
pages.each do |a|
|
18
21
|
created_at = Time.parse(a["CreatedDate"]).strftime("%d/%m/%y|%H:%M")
|
19
|
-
puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
|
22
|
+
@display.puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
data/lib/hurriyet_cli/version.rb
CHANGED
data/lib/hurriyet_cli/writers.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
module HurriyetCli
|
2
2
|
class Writers
|
3
|
-
def
|
4
|
-
client =
|
5
|
-
|
3
|
+
def initialize(client, display = STDOUT)
|
4
|
+
@client = client
|
5
|
+
@display = display
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch
|
9
|
+
writers = @client.writers.all
|
6
10
|
formated_parse(writers)
|
7
11
|
end
|
8
12
|
|
9
|
-
def
|
10
|
-
|
11
|
-
writers = client.writers.all top: top
|
13
|
+
def top_writers(top)
|
14
|
+
writers = @client.writers.all top: top
|
12
15
|
formated_parse(writers)
|
13
16
|
end
|
14
17
|
|
15
18
|
private
|
16
|
-
def
|
19
|
+
def formated_parse(writers)
|
17
20
|
writers.each do |a|
|
18
|
-
puts "#{Rainbow(a["Fullname"]).red} - #{Rainbow(a["Url"]).cyan}"
|
21
|
+
@display.puts "#{Rainbow(a["Fullname"]).red} - #{Rainbow(a["Url"]).cyan}"
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hurriyet_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ender Ahmet Yurt
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,7 +97,8 @@ dependencies:
|
|
97
97
|
description: A Ruby CLI via Hurriyet Public API via https://github.com/hurriyet/developers.hurriyet.com.tr
|
98
98
|
email:
|
99
99
|
- enderyurt@gmail.com
|
100
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- hurriyet_cli
|
101
102
|
extensions: []
|
102
103
|
extra_rdoc_files: []
|
103
104
|
files:
|