hurriyet_cli 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f5f3cc61939344134ac6c6bfa2e57a7ed830242
4
- data.tar.gz: e19ae8d79488143017e241634241c04577822628
3
+ metadata.gz: e9722f496af91a162f5d8e9c6c93ccd40c792366
4
+ data.tar.gz: c92d375bb2ffdf07e6e2a41902c31a760c7ba6de
5
5
  SHA512:
6
- metadata.gz: 98936716ec1e83aee618091065e287ec7b96f68079f1160fdd202d92f7e4396e7ef5a4fe5a8a89bb723106f09c617cdb14e0b6f92be0ae848ce7a545d38f905d
7
- data.tar.gz: 79eb099442bc6dda31f54fa94ca8986dc20e8c1a22b73d8f9e75eda676b28988b3b82a1b9b86a188b9a64def3c184e3fa96ad3ce239ea538960142e3066be84a
6
+ metadata.gz: 8bacfb481dada5511937a9ce265c3263cc97f40134270749bf00e39e4a99cd0e0d5209558169447235b57ab4626dd98c119d38d22f8a84558f39da0592d6de44
7
+ data.tar.gz: a2708b6b9f7c7ccba39e712f77efd149f7268ab509d6c9928e275fbe6ee09d624e7347b0de468484fe6ab60ed372823330cae1adc7628f18bc71e2c02007a24d
data/.gitignore CHANGED
@@ -7,3 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ *.gem
12
+ .ruby-version
13
+
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in hurriyet_cli.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ gem 'rb-readline'
9
+ end
data/README.md CHANGED
@@ -23,7 +23,8 @@ Or install it yourself as:
23
23
  Export your API_KEY that you get from https://developers.hurriyet.com.tr/
24
24
 
25
25
  ```bash
26
- $ bundle exec bin/hurriyet-cli articles # Fetch all articles
26
+ $ bundle exec bin/hurriyet_cli articles # Fetch all articles
27
+ $ bundle exec bin/hurriyet_cli articles --top 5 # Fetch top 5 articles
27
28
  ```
28
29
 
29
30
  ## License
data/lib/hurriyet_cli.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  require "hurriyet_cli/version"
2
2
  require "hurriyet_cli/cli"
3
+ require "hurriyet_cli/articles"
4
+ require "hurriyet_cli/columns"
5
+ require "hurriyet_cli/pages"
6
+ require "hurriyet_cli/writers"
3
7
  require "hurriyet"
4
8
  require "rainbow"
9
+ require "pry"
5
10
 
6
11
  module HurriyetCli
7
12
  end
@@ -0,0 +1,30 @@
1
+ module HurriyetCli
2
+ class Articles
3
+ def self.fetch
4
+ client = Hurriyet::Client.new(ENV["API_KEY"])
5
+ articles = client.articles.all
6
+ formated_parse(articles)
7
+ end
8
+
9
+ def self.top_articles(top)
10
+ client = Hurriyet::Client.new(ENV["API_KEY"])
11
+ articles = client.articles.all top: top
12
+ formated_parse(articles)
13
+ end
14
+
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}\''"
19
+ formated_parse(articles)
20
+ end
21
+
22
+ private
23
+ def self.formated_parse(articles)
24
+ articles.each do |a|
25
+ created_at = Time.parse(a["CreatedDate"]).strftime("%d/%m/%y|%H:%M")
26
+ puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -5,14 +5,54 @@ require "thor/runner"
5
5
  module HurriyetCli
6
6
  class HammerOfTheGods < Thor
7
7
  desc "articles", "Fetch all articles"
8
-
8
+ method_option :top, alias: :t, desc: "Fetch N articles"
9
+ # method_options [:source, :key]
9
10
  def articles
10
- puts "Fetching all articles"
11
- client = Hurriyet::Client.new(ENV["API_KEY"])
12
- articles = client.articles.all
13
- articles.each do |a|
14
- created_at = Time.parse(a["CreatedDate"]).strftime("%d/%m/%y|%H:%M")
15
- puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
11
+ if options[:top]
12
+ 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])
17
+ else
18
+ puts "Fetching all articles"
19
+ HurriyetCli::Articles.fetch
20
+ end
21
+ end
22
+
23
+ desc "columns", "Fetch all columns"
24
+ method_option :top, alias: :t, desc: "Fetch N columns"
25
+ def columns
26
+ if options[:top]
27
+ puts "Fetching #{options[:top]} columns"
28
+ HurriyetCli::Columns.top_columns(options[:top])
29
+ else
30
+ puts "Fetching all columns"
31
+ HurriyetCli::Columns.fetch
32
+ end
33
+ end
34
+
35
+ desc "pages", "Fetch all pages"
36
+ method_option :top, alias: :t, desc: "Fetch N pages"
37
+ def pages
38
+ if options[:top]
39
+ puts "Fetching #{options[:top]} pages"
40
+ HurriyetCli::Pages.top_pages(options[:top])
41
+ else
42
+ puts "Fetching all pages"
43
+ HurriyetCli::Pages.fetch
44
+ end
45
+ end
46
+
47
+ desc "writers", "Fetch all writers"
48
+ method_option :top, alias: :t, desc: "Fetch N writers"
49
+ def writers
50
+ if options[:top]
51
+ puts "Fetching #{options[:top]} writers"
52
+ HurriyetCli::Writers.top_writers(options[:top])
53
+ else
54
+ puts "Fetching all writers"
55
+ HurriyetCli::Writers.fetch
16
56
  end
17
57
  end
18
58
  end
@@ -0,0 +1,23 @@
1
+ module HurriyetCli
2
+ class Columns
3
+ def self.fetch
4
+ client = Hurriyet::Client.new(ENV["API_KEY"])
5
+ columns = client.columns.all
6
+ formated_parse(columns)
7
+ end
8
+
9
+ def self.top_columns(top)
10
+ client = Hurriyet::Client.new(ENV["API_KEY"])
11
+ columns = client.columns.all top: top
12
+ formated_parse(columns)
13
+ end
14
+
15
+ private
16
+ def self.formated_parse(columns)
17
+ columns.each do |a|
18
+ 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}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module HurriyetCli
2
+ class Pages
3
+ def self.fetch
4
+ client = Hurriyet::Client.new(ENV["API_KEY"])
5
+ pages = client.pages.all
6
+ formated_parse(pages)
7
+ end
8
+
9
+ def self.top_pages(top)
10
+ client = Hurriyet::Client.new(ENV["API_KEY"])
11
+ pages = client.pages.all top: top
12
+ formated_parse(pages)
13
+ end
14
+
15
+ private
16
+ def self.formated_parse(pages)
17
+ pages.each do |a|
18
+ created_at = Time.parse(a["CreatedDate"]).strftime("%d/%m/%y|%H:%M")
19
+ puts "#{created_at} - #{Rainbow(a["Title"]).red} - #{Rainbow(a["Url"]).cyan}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module HurriyetCli
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,22 @@
1
+ module HurriyetCli
2
+ class Writers
3
+ def self.fetch
4
+ client = Hurriyet::Client.new(ENV["API_KEY"])
5
+ writers = client.writers.all
6
+ formated_parse(writers)
7
+ end
8
+
9
+ def self.top_writers(top)
10
+ client = Hurriyet::Client.new(ENV["API_KEY"])
11
+ writers = client.writers.all top: top
12
+ formated_parse(writers)
13
+ end
14
+
15
+ private
16
+ def self.formated_parse(writers)
17
+ writers.each do |a|
18
+ puts "#{Rainbow(a["Fullname"]).red} - #{Rainbow(a["Url"]).cyan}"
19
+ end
20
+ end
21
+ end
22
+ 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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ender Ahmet Yurt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,8 +114,12 @@ files:
114
114
  - bin/setup
115
115
  - hurriyet_cli.gemspec
116
116
  - lib/hurriyet_cli.rb
117
+ - lib/hurriyet_cli/articles.rb
117
118
  - lib/hurriyet_cli/cli.rb
119
+ - lib/hurriyet_cli/columns.rb
120
+ - lib/hurriyet_cli/pages.rb
118
121
  - lib/hurriyet_cli/version.rb
122
+ - lib/hurriyet_cli/writers.rb
119
123
  homepage: http://rubygems.org/gems/hurriyet_cli
120
124
  licenses:
121
125
  - MIT