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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9722f496af91a162f5d8e9c6c93ccd40c792366
4
- data.tar.gz: c92d375bb2ffdf07e6e2a41902c31a760c7ba6de
3
+ metadata.gz: 367e725fe44920ee1a769597f32fa9c9d9820ad2
4
+ data.tar.gz: dbaf872b454846adceefa3cfc588106eaef105d3
5
5
  SHA512:
6
- metadata.gz: 8bacfb481dada5511937a9ce265c3263cc97f40134270749bf00e39e4a99cd0e0d5209558169447235b57ab4626dd98c119d38d22f8a84558f39da0592d6de44
7
- data.tar.gz: a2708b6b9f7c7ccba39e712f77efd149f7268ab509d6c9928e275fbe6ee09d624e7347b0de468484fe6ab60ed372823330cae1adc7628f18bc71e2c02007a24d
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 = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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 self.fetch
4
- client = Hurriyet::Client.new(ENV["API_KEY"])
5
- articles = client.articles.all
6
- formated_parse(articles)
3
+ def initialize(client, display = STDOUT)
4
+ @client = client
5
+ @display = display
7
6
  end
8
7
 
9
- def self.top_articles(top)
10
- client = Hurriyet::Client.new(ENV["API_KEY"])
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 self.filter_by(source, key)
16
- client = Hurriyet::Client.new(ENV["API_KEY"])
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 self.formated_parse(articles)
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
@@ -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, alias: :t, desc: "Fetch N articles"
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
- HurriyetCli::Articles.top_articles(options[:top])
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
- HurriyetCli::Articles.fetch
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
- HurriyetCli::Columns.top_columns(options[:top])
28
+ columns.top_columns(options[:top])
29
29
  else
30
30
  puts "Fetching all columns"
31
- HurriyetCli::Columns.fetch
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
- HurriyetCli::Pages.top_pages(options[:top])
42
+ pages.top_pages(options[:top])
41
43
  else
42
44
  puts "Fetching all pages"
43
- HurriyetCli::Pages.fetch
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
- HurriyetCli::Writers.top_writers(options[:top])
56
+ writers.top_writers(options[:top])
53
57
  else
54
58
  puts "Fetching all writers"
55
- HurriyetCli::Writers.fetch
59
+ writers.fetch
56
60
  end
57
61
  end
58
62
  end
@@ -1,22 +1,25 @@
1
1
  module HurriyetCli
2
2
  class Columns
3
- def self.fetch
4
- client = Hurriyet::Client.new(ENV["API_KEY"])
5
- columns = client.columns.all
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 self.top_columns(top)
10
- client = Hurriyet::Client.new(ENV["API_KEY"])
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 self.formated_parse(columns)
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
@@ -1,22 +1,25 @@
1
1
  module HurriyetCli
2
2
  class Pages
3
- def self.fetch
4
- client = Hurriyet::Client.new(ENV["API_KEY"])
5
- pages = client.pages.all
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 self.top_pages(top)
10
- client = Hurriyet::Client.new(ENV["API_KEY"])
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 self.formated_parse(pages)
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
@@ -1,3 +1,3 @@
1
1
  module HurriyetCli
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,21 +1,24 @@
1
1
  module HurriyetCli
2
2
  class Writers
3
- def self.fetch
4
- client = Hurriyet::Client.new(ENV["API_KEY"])
5
- writers = client.writers.all
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 self.top_writers(top)
10
- client = Hurriyet::Client.new(ENV["API_KEY"])
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 self.formated_parse(writers)
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ender Ahmet Yurt
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-22 00:00:00.000000000 Z
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: