get_news 0.1.0 → 0.1.1

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: 266e69bfae90040d99c274f4191da996edfd9952
4
- data.tar.gz: f1e45f53d6433d5a1c5d9082efdd2c13946f7b6a
3
+ metadata.gz: bfa2d5ef7d89cee5bf2dc76338600afdf091895e
4
+ data.tar.gz: 9d657ef7e18e86ec96d787316e2949769caa20b9
5
5
  SHA512:
6
- metadata.gz: edc3a1bc5290a516d792593ecdfa0f25f75e22e86565711043e5548aadafe43782deed8911d45bc33b41c2a5bf47142eddb6b74a0a273e0860e20484ddc066cd
7
- data.tar.gz: 7e85e95912becef77125fb3d06fc2c0627c514be2c6482ae0d8f8cee80414bd43343ecf55d4410daa997f77c223077e39e046c39e1993e349acd06bcfcb26620
6
+ metadata.gz: 3e28ed028ca0695e7cbf6f08c49aa95d4e11e6467c3b8067de4110f6e5115a958c26284c9c31a3e72a3f942d5d13dc074cc9875e195278541bb956c772e4ac6b
7
+ data.tar.gz: dff7eb006f354ef9e25a1367b5fffe8a6acedfea009bc81dee740d08aee81966628089b37dff9cc8b6b0d1e3b72a6f6268348266158948a0ea7ac44c35bf096b
data/README.md CHANGED
@@ -1,42 +1,77 @@
1
1
  [![Build Status](https://travis-ci.org/sinsnk/get_news.svg?branch=master)](https://travis-ci.org/sinsnk/get_news)
2
- # GetNews
2
+ [![Gem Version](https://badge.fury.io/rb/get_news.svg)](http://badge.fury.io/rb/get_news)
3
+ =======
4
+ # GetNews の概要
3
5
 
4
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/get_news`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ GetNews とは Google ニュースをキーワードで検索し、該当するニュースのタイトルを配列形式で取得するためのライブラリです。
5
7
 
6
- TODO: Delete this and the text above, and describe your gem
7
8
 
8
- ## Installation
9
+ ## インストール
10
+
11
+ アプリケーションの Gemfile に以下の行を記述します。
9
12
 
10
- Add this line to your application's Gemfile:
11
13
 
12
14
  ```ruby
13
15
  gem 'get_news'
14
16
  ```
15
17
 
16
- And then execute:
18
+ その後、以下のコマンドを実行します。
17
19
 
18
20
  $ bundle
19
21
 
20
- Or install it yourself as:
22
+ もしくは以下のコマンドを実行します。
21
23
 
22
24
  $ gem install get_news
23
25
 
24
- ## Usage
26
+ GetNews をアンインストールする場合は以下のコマンドを実行します。
27
+
28
+ $ gem uninstall get_news
29
+
30
+
31
+ ## 機能
32
+ * Google ニュースをキーワード検索
33
+
34
+ ## メソッド一覧
35
+
36
+ get_news(search_word, news_count)
37
+
38
+ search_word : String (検索キーワード)
39
+ news_count : Integer (取得条件)
40
+
41
+
42
+ ## 使用方法
43
+
44
+ ```ruby
45
+ require 'get_news'
46
+
47
+ #Google ニュースをキーワードで検索
48
+ @main = GetNews::Main.new
49
+ result = @main.get_news('IoT', 20)
50
+
51
+ #結果表示
52
+ for title in result do
53
+ print("title : " + title + "¥n")
54
+ end
55
+
56
+ ```
57
+
58
+ ## 開発/テスト
25
59
 
26
- TODO: Write usage instructions here
60
+ この Gem には MiniTest による単体テスト用コードが用意されています。
61
+ また Travis CI と連携し、テストの自動化を行っています。
27
62
 
28
- ## Development
63
+ https://travis-ci.org/sinsnk/get_news
29
64
 
30
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
65
 
32
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+ ##対応予定機能
33
67
 
34
- ## Contributing
68
+ * 日付、ニュースカテゴリ情報の追加
69
+ * 複数キーワードによる AND / OR 検索
35
70
 
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/get_news. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
71
 
72
+ ## ライセンス
38
73
 
39
- ## License
74
+ このソースコードのライセンスは [MIT License](http://opensource.org/licenses/MIT) です。
40
75
 
41
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
+ Copyright (c) 2015 AIIT Framework Development Team D
42
77
 
Binary file
@@ -1,7 +1,35 @@
1
1
  require "get_news/version"
2
+ require "nokogiri"
3
+ require "open-uri"
4
+ require "uri"
2
5
 
3
6
  module GetNews
4
7
  class Main
5
-
8
+ def get_news(search_word, news_count)
9
+ if news_count < 1
10
+ return
11
+ end
12
+
13
+ url = URI.escape('https://news.google.com/news?ned=us&ie=UTF-8&oe=UTF-8&q=' + search_word + '&output=atom&num=' + news_count.to_s + '&hl=ja')
14
+
15
+ charset = nil
16
+ xml = open(url) do |f|
17
+ charset = f.charset
18
+ f.read
19
+ end
20
+
21
+ doc = Nokogiri::XML(xml) do |config|
22
+ config.strict.nonet
23
+ end
24
+
25
+ title_array = []
26
+ doc.xpath('//xmlns:title').each_with_index do |val, index|
27
+ if index != 0
28
+ title_array.push(val.text)
29
+ end
30
+ end
31
+
32
+ title_array
33
+ end
6
34
  end
7
35
  end
@@ -1,3 +1,3 @@
1
1
  module GetNews
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_news
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sinsnk
@@ -69,6 +69,7 @@ files:
69
69
  - Rakefile
70
70
  - bin/console
71
71
  - bin/setup
72
+ - get_news-0.1.0.gem
72
73
  - get_news.gemspec
73
74
  - lib/get_news.rb
74
75
  - lib/get_news/version.rb