rubychina 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd8c0e17994a1a6d263514384a14c6207d115a27
4
+ data.tar.gz: a4b9b6303e671e315ad71f59b74fca229a0b62f6
5
+ SHA512:
6
+ metadata.gz: 8d25cee4621f01d99fc3a2794a698caa364bd4f49e76819947b656a026fc89a818b592ad8efa9407ea51b7ca53a33dc3273892d426b695c1d2bce6043369de5c
7
+ data.tar.gz: 982256f9c06d0bca7c7370d51f6895568581ec169be8595723d59f809a75d2df94e895fd0782fe2a8a50c1a61094db884719c4af8a966690377773b11558cf23
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubychina (0.0.1)
5
+ commander (~> 4.1.2)
6
+ excon (~> 0.25.3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ commander (4.1.5)
12
+ highline (~> 1.6.11)
13
+ diff-lcs (1.2.5)
14
+ excon (0.25.3)
15
+ highline (1.6.20)
16
+ rake (10.1.0)
17
+ rspec (2.14.1)
18
+ rspec-core (~> 2.14.0)
19
+ rspec-expectations (~> 2.14.0)
20
+ rspec-mocks (~> 2.14.0)
21
+ rspec-core (2.14.7)
22
+ rspec-expectations (2.14.4)
23
+ diff-lcs (>= 1.1.3, < 2.0)
24
+ rspec-mocks (2.14.4)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ rake
31
+ rspec
32
+ rubychina!
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Mattt Thompson (http://mattt.me/)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,110 @@
1
+ # rubychina
2
+ **A command-line interface for accessing rubychina session content**
3
+
4
+ [ASCIIrubychina](http://asciirubychina.com) provides searchable full-text transcripts of rubychina content. `rubychina` builds on its API, [which is documented in the project's README](https://github.com/mattt/asciirubychina.com#README).
5
+
6
+ > As a CLI aficionado, you should definitely check out [Nomad](http://nomad-cli.com/), a world-class command line utilities for iOS development.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ $ gem install rubychina
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+
18
+ $ rubychina list
19
+
20
+
21
+ 15664: 回复数量 [40] "[美国] 大家也可以考虑下国外"
22
+ 15690: 回复数量 [0] "Code Review 和 Refactoring 竟然有了快感,Code Climate 你赢了"
23
+ 15681: 回复数量 [25] "活着的意义"
24
+ 15683: 回复数量 [11] "git 这玩意有必要性升级吗?"
25
+ 15689: 回复数量 [0] "为你的所有敏感账户开启两步验证"
26
+ 14960: 回复数量 [6] "「推荐」Avdi 的新书"
27
+ 15393: 回复数量 [84] "[上海] 百度诚招高级研发工程师 Ruby"
28
+ 15512: 回复数量 [18] "[广州][2013年11月20日] GZRUBY 第 15 聚会 - Mini-Conf"
29
+ 15669: 回复数量 [9] "怎么样打印一下 ruby 的运行栈?"
30
+ 15330: 回复数量 [39] "[广州] BestApp 招聘 Rails 开发者 !"
31
+ 15687: 回复数量 [5] "总结了一下键盘上所有符号的英文说法"
32
+ 15688: 回复数量 [0] "买了个云梯 VPN"
33
+ 15661: 回复数量 [17] "求一份 Ruby 相关的远程兼职"
34
+ 15682: 回复数量 [3] "bootstrap3 modal 弹出框 remote 获取后,消去子元素后,再弹出 remote 加载失败!"
35
+ 15679: 回复数量 [14] "发现 rubychina 一个给力的地方"
36
+ 15686: 回复数量 [6] "Rails4 destroy"
37
+ 15444: 回复数量 [13] "[无锡] 福瑞博德公司招聘 senior Ruby 程序员"
38
+ 15665: 回复数量 [43] "心累了 想跟各位大哥聊聊"
39
+ 15631: 回复数量 [53] "BitCoin 有冲向$1000 的趋势啊 "
40
+ 15621: 回复数量 [37] "一个黑笑话"
41
+ 15685: 回复数量 [2] "能否将每个页面中执行的 SQL、解析时间等输出到页面上?"
42
+ 15678: 回复数量 [7] "一个 class 的意外写法。"
43
+ 15662: 回复数量 [4] "学习 rails 需要学习 javascript 前端知识么?"
44
+ 15684: 回复数量 [0] "刚学了两个多星期的 Ruby,动手写一个简单的有道词典"
45
+ 15607: 回复数量 [24] "Sublime text 离你到底有多远? | 入门贴"
46
+ 15657: 回复数量 [3] "practical object oriented ruby 之后推荐读些什么?"
47
+ 15680: 回复数量 [2] "eventmachine httpserver 没有成功调用到 post_init"
48
+ 15102: 回复数量 [18] "Webrick 源码阅读笔记"
49
+ 15412: 回复数量 [22] "[北京] 酷传招聘 Ruby on Rails 工程师"
50
+ 15676: 回复数量 [2] "MAC 下 rvm install 2.1.0 出错"
51
+
52
+ $ rubychina info 228
53
+
54
+ 我拷贝这里面的代码:https://github.com/eventmachine/evma_httpserver
55
+
56
+ 然后在post_init里面打了一个puts:
57
+
58
+ ```ruby
59
+ require 'eventmachine'
60
+ require 'evma_httpserver'
61
+
62
+ class MyHttpServer < EM::Connection
63
+ include EM::HttpServer
64
+
65
+ def post_init
66
+ super
67
+ no_environment_strings
68
+ puts "post init"
69
+ end
70
+
71
+ def process_http_request
72
+ response = EM::DelegatedHttpResponse.new(self)
73
+ response.status = 200
74
+ response.content_type 'text/html'
75
+ response.content = '<center><h1>Hi there</h1></center>'
76
+ response.send_response
77
+ end
78
+ end
79
+
80
+ EM.run{
81
+ EM.start_server '0.0.0.0', 8080, MyHttpServer
82
+ }
83
+ ```
84
+
85
+ 跑起来后,终端没有任何反应,post_init没有被调用到,不知道大家是不是也是这样?
86
+
87
+
88
+ $ rubychina open 228
89
+
90
+ # Opens browser to Ruby-China Topic 228
91
+
92
+
93
+ ```
94
+
95
+ ## Contact
96
+
97
+ Lin Xiangyu
98
+
99
+ - http://github.com/oa414
100
+ - lxyweb@gmail.com
101
+
102
+ ## Thanks
103
+
104
+ This project is base on <https://github.com/mattt/wwdc>
105
+
106
+ ## License
107
+
108
+ rubychina is available under the MIT license. See the LICENSE file for more info.
109
+
110
+ All content copyright © 2013 Apple Inc. All rights reserved.
@@ -0,0 +1,10 @@
1
+ require "bundler"
2
+ Bundler.setup
3
+
4
+ task :default => [:build]
5
+
6
+ task :build do
7
+ `pwd`
8
+ `gem build rubychina.gemspec`
9
+ `gem install rubychina*`
10
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'commander/import'
4
+
5
+ require 'rubychina'
6
+
7
+ require File.expand_path('../../lib/rubychina', __FILE__)
8
+
9
+ HighLine.track_eof = false # Fix for built-in Ruby
10
+ Signal.trap("INT") {} # Suppress backtrace when exiting command
11
+
12
+ program :version, RubyChina::VERSION
13
+ program :description, 'A command-line interface for accessing ruby-china topic content'
14
+
15
+ program :help, 'Author', 'Lin Xiangyu'
16
+ program :help, 'Website', 'https://github.com/oa414'
17
+ program :help_formatter, :compact
18
+
19
+ default_command :help
@@ -0,0 +1,6 @@
1
+
2
+ require File.expand_path('../rubychina/version', __FILE__)
3
+ require File.expand_path('../rubychina/helpers', __FILE__)
4
+ require File.expand_path('../rubychina/commands', __FILE__)
5
+
6
+
@@ -0,0 +1,10 @@
1
+ include RubyChina::Helpers
2
+
3
+
4
+
5
+ require File.expand_path('../commands/info', __FILE__)
6
+ require File.expand_path('../commands/list', __FILE__)
7
+ require File.expand_path('../commands/open', __FILE__)
8
+
9
+
10
+
@@ -0,0 +1,15 @@
1
+
2
+ command :info do |c|
3
+ c.syntax = 'rubychina info [topic]'
4
+ c.summary = 'Get information about a topic by its number'
5
+ c.description = ''
6
+
7
+ c.action do |args, options|
8
+ say_error "Missing topic id" and abort unless @number = (Integer(args.first) rescue nil)
9
+
10
+ session = get("/topics/#{@number}.json")
11
+
12
+ describe session
13
+ end
14
+ end
15
+
@@ -0,0 +1,15 @@
1
+ command :list do |c|
2
+ c.syntax = 'rubychina list '
3
+ c.summary = 'List recent 30 rubychina topics'
4
+ c.description = ''
5
+
6
+ c.action do |args, options|
7
+
8
+
9
+ topics = get("/topics.json")
10
+ topics.each do |topic|
11
+ puts %{\033[1m#{topic['id']}: 回复数量 [#{topic['replies_count']}] "#{topic['title']}"\033[0m}
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ command :open do |c|
2
+ c.syntax = 'rubychina open [SESSION]'
3
+ c.summary = 'Open your browser to the ruby-china to view topic'
4
+ c.description = ''
5
+
6
+ c.action do |args, options|
7
+ say_error "Missing topic number" and abort unless @number = (Integer(args.first) rescue nil)
8
+ `open http://ruby-china.org/topics/#{@number}`
9
+ end
10
+ end
@@ -0,0 +1,33 @@
1
+ require 'excon'
2
+ require 'json'
3
+ require "colored"
4
+
5
+ module RubyChina
6
+ module Helpers
7
+ def get(path)
8
+ response = Excon.get("http://ruby-china.org/api" + path)
9
+ say_error "Error #{response.status}" and abort unless response.status == 200
10
+
11
+ yield response if block_given?
12
+
13
+ JSON.parse(response.body)
14
+ end
15
+
16
+ def describe(topic)
17
+ puts %{\033[1m#{topic['id']}: 回复数量 [#{topic['replies_count']}] "#{topic['title']} "\033[0m}.green
18
+ puts topic['body'].yellow
19
+ puts "#" * 20
20
+ topic['replies'].each do |r|
21
+ puts r['user']['login'].red
22
+ puts "\t" * 2 + r['body']
23
+ puts "=" * 20
24
+ end
25
+ puts
26
+ end
27
+
28
+ private
29
+
30
+ def client
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module RubyChina
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "rubychina/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "rubychina"
8
+ s.license = "MIT"
9
+ s.authors = ["Mattt Thompson"]
10
+ s.email = "m@mattt.me"
11
+ s.homepage = "http://mattt.me"
12
+ s.version = RubyChina::VERSION
13
+ s.platform = Gem::Platform::RUBY
14
+ s.summary = "rubychina"
15
+ s.description = "A command-line interface for accessing rubychina session content"
16
+
17
+ s.add_dependency "commander", "~> 4.1.2"
18
+ s.add_dependency "excon", "~> 0.25.3"
19
+ s.add_dependency "colored", "~> 1.2"
20
+
21
+
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "rake"
24
+
25
+ s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(log|pkg|script|spec|test|vendor)/ }
26
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
+ s.require_paths = ["lib"]
29
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubychina
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mattt Thompson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: excon
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.25.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.25.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: colored
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A command-line interface for accessing rubychina session content
84
+ email: m@mattt.me
85
+ executables:
86
+ - rubychina
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - "./bin/rubychina"
91
+ - "./Gemfile"
92
+ - "./Gemfile.lock"
93
+ - "./lib/rubychina/commands/info.rb"
94
+ - "./lib/rubychina/commands/list.rb"
95
+ - "./lib/rubychina/commands/open.rb"
96
+ - "./lib/rubychina/commands.rb"
97
+ - "./lib/rubychina/helpers.rb"
98
+ - "./lib/rubychina/version.rb"
99
+ - "./lib/rubychina.rb"
100
+ - "./LICENSE"
101
+ - "./Rakefile"
102
+ - "./README.md"
103
+ - "./rubychina.gemspec"
104
+ - bin/rubychina
105
+ homepage: http://mattt.me
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.1.10
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: rubychina
129
+ test_files: []
130
+ has_rdoc: