ytopics 0.0.1

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.
@@ -0,0 +1,20 @@
1
+ .DS_Store
2
+
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ytopics.gemspec
4
+ gemspec
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ytopics (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ ytopics!
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Keita Mori
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # Ytopics
2
+
3
+ View yahoo(.co.jp) topics on your terminal.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ytopics'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ytopics
18
+
19
+ ## Usage
20
+
21
+ $ ytopics
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
30
+
31
+ ## Inspired by
32
+
33
+ [仕事中、一瞬の隙も見逃さずに情報収集できるRubyワンライナーとスクリプト - maeharinの日記](http://d.hatena.ne.jp/maeharin/20130110/p1)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'ytopics'
5
+
6
+ puts "Yahoo topics v#{Ytopics::VERSION}"
7
+
8
+ Ytopics.start
@@ -0,0 +1,63 @@
1
+ require "ytopics/version"
2
+ require 'open-uri'
3
+ require 'readline'
4
+
5
+ module Ytopics
6
+ class Topic
7
+ attr_accessor :title, :body, :url
8
+
9
+ def initialize
10
+ yield self
11
+ end
12
+
13
+ def show
14
+ if self.body.nil?
15
+ flg = false
16
+ open(self.url, "r:euc-jp") do |f|
17
+ f.read.encode("utf-8").scan(/<!--HBODY-->(.+?)</) {|m|self.body = m.first}
18
+ end
19
+ end
20
+ puts "<#{self.title}>"
21
+ puts self.body
22
+ end
23
+ end
24
+
25
+ class << self
26
+ @@topics ||= []
27
+
28
+ def start
29
+ puts "type `exit` to end ytopics"
30
+ open('http://www.yahoo.co.jp') do |f|
31
+ f.read.scan(/topics.+?\*-([^<]+?)</) do |m|
32
+ next if /backnumber|photograph/ =~ m.first
33
+
34
+ ary = m.first.split('">')
35
+ @@topics << Topic.new do |t|
36
+ t.url = ary[0]
37
+ t.title = ary[1]
38
+ end
39
+ end
40
+ end
41
+
42
+ display
43
+
44
+ while buf = Readline.readline("ytopics> ", false)
45
+ line = buf.strip
46
+ break if line == 'exit'
47
+ unless /^[0-9]+$/ =~ line && @@topics.length > line.to_i
48
+ puts "Command not found"
49
+ next
50
+ end
51
+ @@topics[line.to_i].show
52
+ display
53
+ end
54
+ end
55
+
56
+ def display
57
+ @@topics.each_with_index do |t, idx|
58
+ puts "[#{idx}] #{t.title}"
59
+ end
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,3 @@
1
+ module Ytopics
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ytopics/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ytopics"
8
+ gem.version = Ytopics::VERSION
9
+ gem.authors = ["Keita Mori"]
10
+ gem.email = ["keita011@gmail.com"]
11
+ gem.description = "View yahoo(.co.jp) topics command."
12
+ gem.summary = "View yahoo(.co.jp) topics command."
13
+ gem.homepage = "http://github.com/dforest/ytopics"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ytopics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Keita Mori
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-12 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: View yahoo(.co.jp) topics command.
15
+ email:
16
+ - keita011@gmail.com
17
+ executables:
18
+ - ytopics
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/ytopics
29
+ - lib/ytopics.rb
30
+ - lib/ytopics/version.rb
31
+ - ytopics.gemspec
32
+ homepage: http://github.com/dforest/ytopics
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.24
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: View yahoo(.co.jp) topics command.
56
+ test_files: []