madrox 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +17 -0
- data/README.md +6 -0
- data/bin/madrox +46 -3
- data/lib/madrox.rb +1 -1
- data/madrox.gemspec +5 -3
- metadata +24 -6
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
CHANGED
data/bin/madrox
CHANGED
@@ -5,6 +5,9 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
|
5
5
|
require 'optparse'
|
6
6
|
require 'rubygems'
|
7
7
|
require 'madrox'
|
8
|
+
require 'open-uri'
|
9
|
+
require 'time'
|
10
|
+
require 'yajl'
|
8
11
|
|
9
12
|
help = <<HELP
|
10
13
|
Madrox is a distributed Twitter implementation on Git.
|
@@ -32,6 +35,18 @@ opts = OptionParser.new do |opts|
|
|
32
35
|
options[:msg] = msg
|
33
36
|
end
|
34
37
|
|
38
|
+
opts.on('--import [name]', "Import from external service (twitter)") do |name|
|
39
|
+
options[:import] = name.to_sym
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on('--since-id [ID]', "Oldest Twitter ID to import") do |id|
|
43
|
+
options[:since_id] = id
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on('--max-id [ID]', "Newest Twitter ID to import") do |id|
|
47
|
+
options[:max_id] = id
|
48
|
+
end
|
49
|
+
|
35
50
|
opts.on('--irb', "Loads an IRB session") do
|
36
51
|
options[:irb] = true
|
37
52
|
end
|
@@ -88,8 +103,36 @@ if options[:irb]
|
|
88
103
|
|
89
104
|
puts "Loaded Madrox wiki at #{File.expand_path(m_path).inspect}."
|
90
105
|
IRB.start_session(binding)
|
91
|
-
else
|
92
|
-
|
93
|
-
|
106
|
+
else
|
107
|
+
case options[:import]
|
108
|
+
when :twitter
|
109
|
+
puts "Importing tweets from Twitter..."
|
110
|
+
page = 1
|
111
|
+
result = []
|
112
|
+
tweets = []
|
113
|
+
url = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=#{timeline.user}&trim_user=1&count=200"
|
114
|
+
if options[:since_id]
|
115
|
+
url << "&since_id=#{options[:since_id]}"
|
116
|
+
end
|
117
|
+
if options[:max_id]
|
118
|
+
url << "&max_id=#{options[:max_id]}"
|
119
|
+
end
|
120
|
+
until page > 1 && result.empty?
|
121
|
+
open("#{url}&page=#{page}") do |f|
|
122
|
+
page += 1
|
123
|
+
result = Yajl::Parser.parse(f.read)
|
124
|
+
tweets.push *result if !result.empty?
|
125
|
+
end
|
126
|
+
end
|
127
|
+
puts "Importing #{tweets.size} tweets..."
|
128
|
+
tweets.reverse!
|
129
|
+
tweets.each_with_index do |tweet, idx|
|
130
|
+
puts tweet['id'] if (idx + 1) % 100 == 0
|
131
|
+
timeline.post(tweet['text'], :committed_date => Time.parse(tweet['created_at']))
|
132
|
+
end
|
133
|
+
else # no importer, just list their tweets
|
134
|
+
timeline.messages.each do |commit|
|
135
|
+
puts "[#{commit.committed_date}] @#{commit.author.name}: #{commit.message}"
|
136
|
+
end
|
94
137
|
end
|
95
138
|
end
|
data/lib/madrox.rb
CHANGED
data/madrox.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'madrox'
|
16
|
-
s.version = '0.1.
|
17
|
-
s.date = '2010-10-
|
16
|
+
s.version = '0.1.1'
|
17
|
+
s.date = '2010-10-23'
|
18
18
|
s.rubyforge_project = 'madrox'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
|
40
40
|
## List your runtime dependencies here. Runtime dependencies are those
|
41
41
|
## that are needed for an end user to actually USE your code.
|
42
|
-
|
42
|
+
s.add_dependency('yajl-ruby', ["~> 0.7.7"])
|
43
43
|
|
44
44
|
## List your development dependencies here. Development dependencies are
|
45
45
|
## those that are only needed during development
|
@@ -50,6 +50,8 @@ Gem::Specification.new do |s|
|
|
50
50
|
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
51
51
|
# = MANIFEST =
|
52
52
|
s.files = %w[
|
53
|
+
Gemfile
|
54
|
+
Gemfile.lock
|
53
55
|
LICENSE
|
54
56
|
README.md
|
55
57
|
Rakefile
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Rick Olson
|
@@ -14,10 +14,24 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-23 00:00:00 +02:00
|
18
18
|
default_executable: madrox
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: yajl-ruby
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 7
|
31
|
+
- 7
|
32
|
+
version: 0.7.7
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
21
35
|
description: Distributed Twitter implementation on Git.
|
22
36
|
email: technoweenie@gmail.com
|
23
37
|
executables:
|
@@ -27,6 +41,8 @@ extensions: []
|
|
27
41
|
extra_rdoc_files: []
|
28
42
|
|
29
43
|
files:
|
44
|
+
- Gemfile
|
45
|
+
- Gemfile.lock
|
30
46
|
- LICENSE
|
31
47
|
- README.md
|
32
48
|
- Rakefile
|
@@ -1489,6 +1505,7 @@ rdoc_options: []
|
|
1489
1505
|
require_paths:
|
1490
1506
|
- lib
|
1491
1507
|
required_ruby_version: !ruby/object:Gem::Requirement
|
1508
|
+
none: false
|
1492
1509
|
requirements:
|
1493
1510
|
- - ">="
|
1494
1511
|
- !ruby/object:Gem::Version
|
@@ -1496,6 +1513,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1496
1513
|
- 0
|
1497
1514
|
version: "0"
|
1498
1515
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1516
|
+
none: false
|
1499
1517
|
requirements:
|
1500
1518
|
- - ">="
|
1501
1519
|
- !ruby/object:Gem::Version
|
@@ -1505,7 +1523,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1505
1523
|
requirements: []
|
1506
1524
|
|
1507
1525
|
rubyforge_project: madrox
|
1508
|
-
rubygems_version: 1.3.
|
1526
|
+
rubygems_version: 1.3.7
|
1509
1527
|
signing_key:
|
1510
1528
|
specification_version: 2
|
1511
1529
|
summary: Distributed Twitter implementation on Git.
|