twigger 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-11-20
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/twigger
7
+ lib/twigger.rb
8
+ test/test_twigger.rb
@@ -0,0 +1,48 @@
1
+ = twigger
2
+
3
+ * http://ranch.ero.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ Import tweets into Pligger.
8
+
9
+ == SUMMARY:
10
+
11
+ Yep, that's what it does.
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ Relies on Pligger
16
+
17
+ == REQUIREMENTS:
18
+
19
+ A Pligger database on the localhost
20
+
21
+ == INSTALL:
22
+
23
+ * sudo gem install twigger
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2010 Dean Hudson
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,10 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.spec 'twigger' do
7
+ developer('Dean Hudson', 'dean@ero.com')
8
+
9
+ # self.rubyforge_name = 'twiggerx' # if different than 'twigger'
10
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'twitter'
5
+ require 'active_record'
6
+ require 'twigger'
7
+
8
+ ActiveRecord::Base.establish_connection(
9
+ :adapter => 'mysql',
10
+ :database => 'pligger',
11
+ :username => 'root',
12
+ :host => 'localhost'
13
+ )
14
+
15
+ abort "usage: twigger <search term>" unless ARGV[0]
16
+
17
+ while true do
18
+ puts "Searching for \"#{ARGV[0]}\"..."
19
+ cnt = Twigger.ingest_by_search(ARGV[0])
20
+ puts "Ingested #{cnt} tweets."
21
+ sleep 20
22
+ end
@@ -0,0 +1,51 @@
1
+ ActiveRecord::Base.table_name_prefix = "pligg_"
2
+
3
+ class Comment < ActiveRecord::Base
4
+ set_primary_key "comment_id"
5
+ end
6
+
7
+ class Link < ActiveRecord::Base
8
+ set_primary_key "link_id"
9
+ end
10
+
11
+ class Twigger
12
+ VERSION = '1.0.2'
13
+
14
+ def self.ingest_by_search(search_term)
15
+ search = Twitter::Search.new
16
+ cnt = 0
17
+ tweets = search.containing(search_term).fetch
18
+ tweets.each do |tweet|
19
+ next if Link.find_by_link_field1("#{tweet.id}")
20
+ l = create_link(tweet, search_term)
21
+ cnt += 1
22
+ end
23
+ return cnt
24
+ end
25
+
26
+ def self.create_link(tweet, search_term = nil)
27
+ l = Link.new
28
+ l.link_category = 1
29
+ l.link_author = 1
30
+ l.link_status = "published"
31
+ l.link_votes = 0
32
+ l.link_published_date = tweet.created_at
33
+ l.link_content = tweet.text
34
+ l.link_url_title = tweet.id
35
+ l.link_title_url = tweet.id
36
+ l.link_summary = tweet.text
37
+ l.link_tags = "twitter"
38
+ l.link_votes = 1
39
+ l.link_url = "http://twitter.com/#{tweet.twitter_handle}/statuses/#{tweet.uid}"
40
+ l.link_title = "From @#{tweet.from_user} via Twitter"
41
+ l.link_field6 = tweet.from_user
42
+ l.link_field5 = "twitter"
43
+ l.link_field4 = tweet.from_user
44
+ l.link_field3 = tweet.to_user
45
+ l.link_field2 = search_term
46
+ l.link_field1 = "#{tweet.id}"
47
+
48
+ l.save
49
+ return l
50
+ end
51
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "twigger"
3
+
4
+ class TestTwigger < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twigger
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 2
9
+ version: 1.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Dean Hudson
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-20 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rubyforge
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 4
32
+ version: 2.0.4
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 6
46
+ - 2
47
+ version: 2.6.2
48
+ type: :development
49
+ version_requirements: *id002
50
+ description: Import tweets into Pligger.
51
+ email:
52
+ - dean@ero.com
53
+ executables:
54
+ - twigger
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - History.txt
59
+ - Manifest.txt
60
+ - README.txt
61
+ files:
62
+ - .autotest
63
+ - History.txt
64
+ - Manifest.txt
65
+ - README.txt
66
+ - Rakefile
67
+ - bin/twigger
68
+ - lib/twigger.rb
69
+ - test/test_twigger.rb
70
+ has_rdoc: true
71
+ homepage: http://ranch.ero.com
72
+ licenses: []
73
+
74
+ post_install_message:
75
+ rdoc_options:
76
+ - --main
77
+ - README.txt
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ requirements: []
97
+
98
+ rubyforge_project: twigger
99
+ rubygems_version: 1.3.7
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Import tweets into Pligger.
103
+ test_files:
104
+ - test/test_twigger.rb