boston-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'nokogiri'
4
+ gem 'htmlentities'
5
+
data/NOTES ADDED
@@ -0,0 +1,14 @@
1
+
2
+ lib/boston-ruby
3
+
4
+ bostonrb script
5
+
6
+ /updates
7
+
8
+ /blog_posts
9
+
10
+ /tweets
11
+
12
+
13
+
14
+ /weather
@@ -0,0 +1,91 @@
1
+ # boston-ruby
2
+
3
+ This tool lets you look up recent activity by BostonRB members from the command
4
+ line.
5
+
6
+ Usage: boston-ruby [command]
7
+
8
+ Commands:
9
+ m Show recent BostonRB mailing list posts
10
+ t Show recent tweets by BostonRB members
11
+ g Show recent github activity by BostonRB members
12
+
13
+
14
+ ## Sample output
15
+
16
+
17
+ BostonRB mailing list activity:
18
+
19
+ $ boston-ruby m
20
+
21
+ Re: [boston.rb] tethering/hotspot/mifi suggestions
22
+ --------------------------------------------------
23
+ http://groups.google.com/group/boston-rubygroup/browse_thread/thread/59bb3867e9924ac6
24
+
25
+ John Norman : Just out of curiosity: Did putting this:
26
+ 07:49PM 03/14 : ServerAliveInterval 60 (or a smaller interval.) in your
27
+ : .ssh/config help at all? (E.g.:
28
+ : [http://www.kehlet.cx/articles/129.html])
29
+
30
+ Daniel Choi : No I haven't. I didn't even know about that option. Thanks,
31
+ 07:50PM 03/14 : I'll try it!
32
+
33
+ Dan Pickett : If you have an android device, I highly recommend PDANet -
34
+ 07:52PM 03/14 : it has made this surburbanite's ride on the commuter rail
35
+ : very efficient!
36
+ [...]
37
+
38
+
39
+ BostonRB member tweets:
40
+
41
+ $ boston-ruby t
42
+
43
+ jayroh : Another beautiful site from the friendly people at : 04:09PM 03/20
44
+ : @the47th - http://t.co/HA1qqIQx :
45
+ kbedell : The latest Browser market shares: http://t.co/Uu5cTGyQ : 04:57PM 03/20
46
+ kbedell : Found an annoying javascript bug that only occurs in : 04:58PM 03/20
47
+ : Firefox 3.6. Crap. Who's still supporting that version? :
48
+ im_a_muppet : You know you have been pairing a little too much when tmux : 05:05PM 03/20
49
+ : makes it into a pun! #ALittleTooMux :
50
+ wpeterson : From my amazing coworkers: The Devops Dark Knight - : 05:08PM 03/20
51
+ : http://t.co/awWxeEbi #in :
52
+ dwhsix : @WorkBarBoston so you're "torqued", but are you still : 05:09PM 03/20
53
+ : hosting @sqoot 's event? :
54
+ bcardarella : @jayroh btw we haven't gotten a drink in a while. We : 06:00PM 03/20
55
+ : should fix that :
56
+ jayroh : @bcardarella no shit dude. Been a while! : 06:05PM 03/20
57
+ wpeterson : @teflonted can't do it in Gemfile. Bundle config. : 06:55PM 03/20
58
+ dwhsix : Ha, never looked at headers in a Facebook email: : 07:13PM 03/20
59
+ : X-Facebook: from zuckmail ([MTI3LjAuMC4x]) by :
60
+ : http://t.co/xFrkqvTy with HTTP (ZuckMail); :
61
+ doctorzaius : Lots of new movies that I want to see, but someone might : 07:23PM 03/20
62
+ : call me a "sheeple" so I better not. :
63
+ [...]
64
+
65
+ BostonRB member github activity:
66
+
67
+ $ boston-ruby g
68
+
69
+ cldwalker : cldwalker pushed to master at cldwalker/bacon : 05:49PM 03/20
70
+ berkmancenter : berkmancenter created repository brkmn : 05:53PM 03/20
71
+ sbisker : sbisker started watching Kicksend/mailcheck : 05:55PM 03/20
72
+ techiferous : techiferous pushed to master at techiferous/tabulous : 05:58PM 03/20
73
+ techiferous : techiferous created tag v1.3.0 at techiferous/tabulous : 05:58PM 03/20
74
+ techiferous : techiferous commented on pull request 14 on : 06:02PM 03/20
75
+ : techiferous/tabulous :
76
+ techiferous : techiferous commented on issue 13 on techiferous/tabulous : 06:04PM 03/20
77
+ techiferous : techiferous closed issue 13 on techiferous/tabulous : 06:04PM 03/20
78
+ robbfitzsimmons : robbfitzsimmons pushed to master at : 06:08PM 03/20
79
+ : robbfitzsimmons/sample_app :
80
+ cldwalker : cldwalker created branch fix_change_tests at : 06:10PM 03/20
81
+ : cldwalker/bacon :
82
+ cldwalker : cldwalker pushed to fix_change_tests at cldwalker/bacon : 06:19PM 03/20
83
+ cldwalker : cldwalker opened pull request 11 on chneukirchen/bacon : 06:25PM 03/20
84
+ cldwalker : cldwalker commented on pull request 10 on : 06:26PM 03/20
85
+ : chneukirchen/bacon :
86
+ croaky : croaky opened issue 9 on copycopter/style-guide : 06:37PM 03/20
87
+ jferris : jferris created repository jferris.github.com : 06:38PM 03/20
88
+ jferris : jferris created branch master at : 06:39PM 03/20
89
+ : jferris/jferris.github.com :
90
+ jferris : jferris pushed to master at jferris/jferris.github.com : 06:44PM 03/20
91
+ [...]
@@ -0,0 +1,6 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'boston-ruby'
3
+
4
+ command = ARGV.shift
5
+
6
+ case command
7
+ when /^m/
8
+ require 'boston-ruby/mailing_list'
9
+ when /^t/
10
+ require 'boston-ruby/twitter'
11
+ when /^b/
12
+ require 'boston-ruby/blogs'
13
+ when /^g/
14
+ require 'boston-ruby/github'
15
+ else
16
+ puts <<HELP
17
+ boston-ruby #{BostonRuby::VERSION}
18
+
19
+ Usage: boston-ruby [command]
20
+
21
+ Commands:
22
+ m Show recent BostonRB mailing list posts
23
+ t Show recent tweets by BostonRB members
24
+ g Show recent github activity by BostonRB members
25
+
26
+ Project homepage: http://github.com/danchoi/boston-ruby
27
+ Author: Daniel Choi <dhchoi@gmail.com>
28
+
29
+
30
+ HELP
31
+ exit 1
32
+ end
33
+
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require 'boston-ruby'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "boston-ruby"
8
+ s.version = BostonRuby::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.required_ruby_version = '>= 1.9.0'
11
+
12
+ s.authors = ["Daniel Choi"]
13
+ s.email = ["dhchoi@gmail.com"]
14
+ s.homepage = "http://github.com/danchoi/boston-ruby"
15
+ summary = %q{Track BostonRB group and member activity}
16
+ s.summary = summary
17
+ s.description = summary
18
+
19
+ s.rubyforge_project = "boston-ruby"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = []
23
+ s.executables = ['boston-ruby']
24
+ s.require_paths = ["lib"]
25
+
26
+ s.add_dependency 'nokogiri'
27
+ s.add_dependency 'htmlentities'
28
+ end
@@ -0,0 +1,32 @@
1
+ require 'htmlentities'
2
+
3
+ module BostonRuby
4
+
5
+ VERSION = '0.0.1'
6
+
7
+ MAX_WIDTH = 90
8
+ CODER = HTMLEntities.new
9
+
10
+ def self.format_item(longest_name_length, author, text, time, time_on_left=false)
11
+ timestamp = time.strftime("%I:%M%p %m/%d")
12
+ body_width = MAX_WIDTH - timestamp.length - longest_name_length - 4
13
+ wrapped_body_lines = CODER.decode(text).gsub(/\n/, " ").gsub(/.{1,#{body_width}}(?:\s|\Z)/){$&+"\n"}.split(/\n/)
14
+
15
+ out = []
16
+ if time_on_left
17
+ longest_name_length = [longest_name_length, timestamp.length].max
18
+ out << "%#{longest_name_length}s : %-#{body_width + 1}s" % [author, wrapped_body_lines.shift]
19
+ out << "%#{longest_name_length}s : %-#{body_width + 1}s" % [timestamp, wrapped_body_lines.shift]
20
+ wrapped_body_lines.each do |line|
21
+ out << "%#{longest_name_length}s : %-#{body_width + 1}s" % [" ", line]
22
+ end
23
+ else
24
+ out << "%#{longest_name_length}s : %-#{body_width + 1}s : %s" % [author, wrapped_body_lines.shift, timestamp]
25
+ wrapped_body_lines.each do |line|
26
+ out << "%#{longest_name_length}s : %-#{body_width + 1}s :" % [" ", line]
27
+ end
28
+ end
29
+ out.join("\n")
30
+ end
31
+
32
+ end
@@ -0,0 +1,40 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+ require 'date'
4
+ require 'boston-ruby'
5
+ require 'yaml'
6
+
7
+ posts = JSON.parse(open("http://ruby.bostonstuff.org/blog_posts").read)
8
+
9
+ puts "(Most recent post is last.)"
10
+ puts
11
+ longest_name_length = posts.reduce(0) {|max, post| [max, post['blog'].length].max}
12
+
13
+ posts.map {|post| post.merge(parsed_time: DateTime.parse(post['date']))}.
14
+ sort_by {|p| p[:parsed_time]}.each do |post|
15
+ text = [post['title'], post['summary'], post['href']].join("\n\n")
16
+ time = post[:parsed_time]
17
+
18
+ puts post['blog']
19
+ puts post['date_string']
20
+ puts post['title']
21
+ puts post["href"]
22
+ puts '-' * 3
23
+ end
24
+
25
+ __END__
26
+
27
+ Each blog:
28
+
29
+ - blog: ActBlueTechBlog
30
+ href: http://blog.actbluetech.com/2011/07/come-work-with-us.html
31
+ title: Come Work With Us
32
+ author: Bill Kirtley
33
+ date: '2011-07-29 15:22:05 -0400'
34
+ summary: ActBlue is the leading source of online funds for the Democratic Party
35
+ and an innovator in the field of grassroots politics. We build tools that are
36
+ used by hundreds of thousands of people to change the country everyday. We're
37
+ an established player (eight years strong!) gearing up to make a huge impact on
38
+ the 2012 election season....and we need you...
39
+ feed_url: http://blog.actbluetech.com/atom.xml
40
+ date_string: Jul 29 03:22 PM
@@ -0,0 +1,42 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+ require 'date'
4
+ require 'boston-ruby'
5
+ require 'yaml'
6
+
7
+ updates = JSON.parse(open("http://ruby.bostonstuff.org/updates").read)
8
+
9
+ puts "(Most recent update is last.)"
10
+ puts
11
+
12
+ longest_name_length = updates.reduce(0) {|max, x| [max, x['author'].length].max}
13
+
14
+ updates.reverse.each do |update|
15
+ author = update['author']
16
+ #text = [update['title'], update['content']].join("\n\n")
17
+ text = update['title']
18
+ time = DateTime.parse update['date']
19
+ puts BostonRuby.format_item(longest_name_length, author, text, time)
20
+ end
21
+
22
+ __END__
23
+
24
+ - update_id: tag:github.com,2008:PushEvent/1532252526
25
+ author: trevorrjohn
26
+ date: '2012-03-20 16:37:45 -0400'
27
+ title: trevorrjohn pushed to master at trevorrjohn/vim-config
28
+ content: ! " <span class=\"mini-icon push\"></span>\n \n <div class=\"title\">\n
29
+ \ <a href=\"https://github.com/trevorrjohn\">trevorrjohn</a> <span>pushed</span>
30
+ to master at <a href=\"https://github.com/trevorrjohn/vim-config\">trevorrjohn/vim-config</a>\n
31
+ \ <time class=\"js-relative-date\" datetime=\"2012-03-20T20:37:45Z\" title=\"2012-03-20
32
+ 20:37:45\"></time>\n </div>\n <div class=\"details\">\n \n \n
33
+ \ <div class=\"commits\">\n <ul>\n <li>\n <a
34
+ href=\"https://github.com/trevorrjohn\" class=\"committer\">trevorrjohn</a> committed
35
+ <a href=\"https://github.com/trevorrjohn/vim-config/commit/bac294aef9ef746ca8110656962e6c10955d2e8e\">bac294a</a>\n
36
+ \ \n <div class=\"message\">\n <blockquote>updated
37
+ command-t install instructions</blockquote>\n </div>\n </li>\n
38
+ \ </ul>\n </div>\n </div>\n"
39
+ media: https://secure.gravatar.com/avatar/78a67425fcb9730d29ab6a59710fe35e?s=30&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png
40
+ date_string: Mar 20 04:37 PM
41
+
42
+
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ require 'nokogiri'
3
+ require 'date'
4
+ require 'boston-ruby'
5
+
6
+ xml = `curl -A "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" -s http://groups.google.com/group/boston-rubygroup/feed/atom_v1_0_msgs.xml?num=50`
7
+ doc = Nokogiri::XML.parse xml
8
+
9
+ threads = Hash.new
10
+
11
+ doc.search('entry').reverse.each {|entry|
12
+ title = entry.at('title').inner_text
13
+ thread_link = entry.at('link')[:href].sub(/\/[^\/]*$/, '')
14
+ data = {
15
+ author: entry.at('author/name/text()').to_s,
16
+ updated: DateTime.parse(entry.at('updated/text()').to_s),
17
+ link_id: entry.at('link')[:href][/\/([^\/]*)\?/, 1],
18
+ summary: entry.at('summary').inner_text.gsub("<br>", " ").gsub(/\s{2,}/, ' ').strip,
19
+ }
20
+ thread_uid = thread_link[/[^\/]+$/, 0]
21
+ threads[thread_uid] ||= ({title: nil, posts: []})
22
+ threads[thread_uid][:title] ||= title
23
+ threads[thread_uid][:link] ||= thread_link
24
+ threads[thread_uid][:posts] << data
25
+ }
26
+
27
+ puts "(Most recently updated thread is last.)"
28
+ puts
29
+ threads.each do |uid, thread|
30
+ puts thread[:title]
31
+ puts '-' * thread[:title].size
32
+ puts thread[:link]
33
+ puts
34
+
35
+ longest_name_length = thread[:posts].reduce(0) {|max, post| [max, post[:author].length].max}
36
+
37
+ thread[:posts].each do |post|
38
+
39
+ # turn links into markdown-esque text
40
+ html = Nokogiri::HTML(post[:summary])
41
+ html.search('a').each do |a|
42
+ a.swap("[#{a[:href]}]")
43
+ end
44
+ coder = HTMLEntities.new
45
+ text = coder.decode html.inner_text
46
+ time = post[:updated]
47
+ author = post[:author]
48
+
49
+ puts BostonRuby.format_item(longest_name_length, author, text, time, true)
50
+ puts
51
+
52
+ end
53
+ puts
54
+
55
+ end
@@ -0,0 +1,35 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+ require 'date'
4
+ require 'boston-ruby'
5
+
6
+ tweets = JSON.parse(open("http://ruby.bostonstuff.org/tweets?raw=true").read)
7
+
8
+ longest_name_length = tweets.reduce(0) {|max, post| [max, post['user_screen_name'].length].max}
9
+
10
+ puts "(Most recent tweet is last.)"
11
+ puts
12
+
13
+ tweets.map {|post| post.merge(parsed_time: DateTime.parse(post['created_at']))}.
14
+ sort_by {|p| p[:parsed_time]}.each do |post|
15
+ author = post['user_screen_name']
16
+ text = post['text']
17
+ time = post[:parsed_time]
18
+ puts BostonRuby.format_item(longest_name_length, author, text, time)
19
+ end
20
+
21
+ __END__
22
+
23
+ Each tweet:
24
+
25
+
26
+ ---
27
+ - id: 182473702477283329
28
+ created_at: '2012-03-21 10:28:15 -0400'
29
+ user_screen_name: patricksroberts
30
+ user_profile_image_url: http://a0.twimg.com/profile_images/1807338004/small_avatar_normal.jpg
31
+ user_description: Software Developer @ Iora Health, Co-organizer of BostonRB
32
+ user_location: Cambridge, MA
33
+ user_followers_count: 145
34
+ text: Converting JS to coffee. SO GOOD.
35
+ retweet_count: 0
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boston-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Choi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: htmlentities
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Track BostonRB group and member activity
47
+ email:
48
+ - dhchoi@gmail.com
49
+ executables:
50
+ - boston-ruby
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - NOTES
57
+ - README.md
58
+ - Rakefile
59
+ - bin/boston-ruby
60
+ - boston-ruby.gemspec
61
+ - lib/boston-ruby.rb
62
+ - lib/boston-ruby/blogs.rb
63
+ - lib/boston-ruby/github.rb
64
+ - lib/boston-ruby/mailing_list.rb
65
+ - lib/boston-ruby/twitter.rb
66
+ homepage: http://github.com/danchoi/boston-ruby
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.9.0
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project: boston-ruby
86
+ rubygems_version: 1.8.19
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Track BostonRB group and member activity
90
+ test_files: []