dschn-twitter 0.3.7.2 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/spec/search_spec.rb CHANGED
@@ -49,6 +49,10 @@ describe Twitter::Search do
49
49
  @search.per_page(25).query[:rpp].should == 25
50
50
  end
51
51
 
52
+ it "should be able to specify the page number" do
53
+ @search.page(20).query[:page].should == 20
54
+ end
55
+
52
56
  it "should be able to specify only returning results greater than an id" do
53
57
  @search.since(1234).query[:since_id].should == 1234
54
58
  end
@@ -73,7 +77,7 @@ describe Twitter::Search do
73
77
 
74
78
  describe "fetching" do
75
79
  before do
76
- @response = open(File.dirname(__FILE__) + '/fixtures/friends_timeline.xml').read
80
+ @response = YAML.load_file(File.dirname(__FILE__) + '/fixtures/search_result_info.yml')
77
81
  @search.class.stub!(:get).and_return(@response)
78
82
  end
79
83
 
@@ -81,6 +85,13 @@ describe Twitter::Search do
81
85
  @search.class.should_receive(:get).and_return(@response)
82
86
  @search.from('jnunemaker').fetch().should == @response
83
87
  end
88
+
89
+ it "should support dot notation" do
90
+ @search.class.should_receive(:get).and_return(@response)
91
+ info = @search.from('httparty').fetch()
92
+ info["max_id"].should == info.max_id
93
+ info["results"].first["text"].should == info.results.first.text
94
+ end
84
95
  end
85
96
 
86
97
  it "should be able to iterate over results" do
data/spec/spec_helper.rb CHANGED
@@ -9,4 +9,15 @@ end
9
9
  dir = File.dirname(__FILE__)
10
10
 
11
11
  $:.unshift(File.join(dir, '/../lib/'))
12
- require dir + '/../lib/twitter'
12
+ require dir + '/../lib/twitter'
13
+
14
+
15
+ def stdout_for(&block)
16
+ # Inspired by http://www.ruby-forum.com/topic/58647
17
+ old_stdout = $stdout
18
+ $stdout = StringIO.new
19
+ yield
20
+ output = $stdout.string
21
+ $stdout = old_stdout
22
+ output
23
+ end
data/twitter.gemspec CHANGED
@@ -1,49 +1,45 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = %q{twitter}
3
- s.version = "0.3.7.2"
5
+ s.version = "0.4.1"
4
6
 
5
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
8
  s.authors = ["John Nunemaker"]
7
- s.date = %q{2008-08-26}
9
+ s.date = %q{2009-01-05}
8
10
  s.default_executable = %q{twitter}
9
11
  s.description = %q{a command line interface for twitter, also a library which wraps the twitter api}
10
12
  s.email = %q{nunemaker@gmail.com}
11
13
  s.executables = ["twitter"]
12
- s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt"]
13
- s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/twitter", "config/hoe.rb", "config/requirements.rb", "examples/blocks.rb", "examples/direct_messages.rb", "examples/favorites.rb", "examples/friends_followers.rb", "examples/friendships.rb", "examples/identica_timeline.rb", "examples/location.rb", "examples/posting.rb", "examples/replies.rb", "examples/search.rb", "examples/sent_messages.rb", "examples/timeline.rb", "examples/twitter.rb", "examples/verify_credentials.rb", "lib/twitter.rb", "lib/twitter/base.rb", "lib/twitter/cli.rb", "lib/twitter/cli/config.rb", "lib/twitter/cli/helpers.rb", "lib/twitter/cli/migrations/20080722194500_create_accounts.rb", "lib/twitter/cli/migrations/20080722194508_create_tweets.rb", "lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb", "lib/twitter/cli/migrations/20080722214606_create_configurations.rb", "lib/twitter/cli/models/account.rb", "lib/twitter/cli/models/configuration.rb", "lib/twitter/cli/models/tweet.rb", "lib/twitter/direct_message.rb", "lib/twitter/easy_class_maker.rb", "lib/twitter/rate_limit_status.rb", "lib/twitter/search.rb", "lib/twitter/status.rb", "lib/twitter/user.rb", "lib/twitter/version.rb", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/base_spec.rb", "spec/cli/helper_spec.rb", "spec/direct_message_spec.rb", "spec/fixtures/followers.xml", "spec/fixtures/friends.xml", "spec/fixtures/friends_for.xml", "spec/fixtures/friends_lite.xml", "spec/fixtures/friends_timeline.xml", "spec/fixtures/public_timeline.xml", "spec/fixtures/rate_limit_status.xml", "spec/fixtures/search_results.json", "spec/fixtures/status.xml", "spec/fixtures/user.xml", "spec/fixtures/user_timeline.xml", "spec/search_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/status_spec.rb", "spec/user_spec.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "twitter.gemspec", "website/css/common.css", "website/images/terminal_output.png", "website/index.html"]
14
+ s.extra_rdoc_files = ["bin/twitter", "lib/twitter/base.rb", "lib/twitter/cli/config.rb", "lib/twitter/cli/helpers.rb", "lib/twitter/cli/migrations/20080722194500_create_accounts.rb", "lib/twitter/cli/migrations/20080722194508_create_tweets.rb", "lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb", "lib/twitter/cli/migrations/20080722214606_create_configurations.rb", "lib/twitter/cli/models/account.rb", "lib/twitter/cli/models/configuration.rb", "lib/twitter/cli/models/tweet.rb", "lib/twitter/cli.rb", "lib/twitter/direct_message.rb", "lib/twitter/easy_class_maker.rb", "lib/twitter/rate_limit_status.rb", "lib/twitter/search.rb", "lib/twitter/status.rb", "lib/twitter/user.rb", "lib/twitter/version.rb", "lib/twitter.rb", "README"]
15
+ s.files = ["bin/twitter", "examples/blocks.rb", "examples/direct_messages.rb", "examples/favorites.rb", "examples/friends_followers.rb", "examples/friendships.rb", "examples/identica_timeline.rb", "examples/location.rb", "examples/posting.rb", "examples/replies.rb", "examples/search.rb", "examples/sent_messages.rb", "examples/timeline.rb", "examples/twitter.rb", "examples/verify_credentials.rb", "History", "lib/twitter/base.rb", "lib/twitter/cli/config.rb", "lib/twitter/cli/helpers.rb", "lib/twitter/cli/migrations/20080722194500_create_accounts.rb", "lib/twitter/cli/migrations/20080722194508_create_tweets.rb", "lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb", "lib/twitter/cli/migrations/20080722214606_create_configurations.rb", "lib/twitter/cli/models/account.rb", "lib/twitter/cli/models/configuration.rb", "lib/twitter/cli/models/tweet.rb", "lib/twitter/cli.rb", "lib/twitter/direct_message.rb", "lib/twitter/easy_class_maker.rb", "lib/twitter/rate_limit_status.rb", "lib/twitter/search.rb", "lib/twitter/status.rb", "lib/twitter/user.rb", "lib/twitter/version.rb", "lib/twitter.rb", "License", "Manifest", "Rakefile", "README", "spec/base_spec.rb", "spec/cli/helper_spec.rb", "spec/direct_message_spec.rb", "spec/fixtures/followers.xml", "spec/fixtures/friends.xml", "spec/fixtures/friends_for.xml", "spec/fixtures/friends_lite.xml", "spec/fixtures/friends_timeline.xml", "spec/fixtures/public_timeline.xml", "spec/fixtures/rate_limit_status.xml", "spec/fixtures/search_results.json", "spec/fixtures/status.xml", "spec/fixtures/user.xml", "spec/fixtures/user_timeline.xml", "spec/search_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/status_spec.rb", "spec/user_spec.rb", "twitter.gemspec", "website/css/common.css", "website/images/terminal_output.png", "website/index.html"]
14
16
  s.has_rdoc = true
15
17
  s.homepage = %q{http://twitter.rubyforge.org}
16
- s.rdoc_options = ["--main", "README.txt"]
18
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Twitter", "--main", "README"]
17
19
  s.require_paths = ["lib"]
18
20
  s.rubyforge_project = %q{twitter}
19
- s.rubygems_version = %q{1.2.0}
21
+ s.rubygems_version = %q{1.3.1}
20
22
  s.summary = %q{a command line interface for twitter, also a library which wraps the twitter api}
21
23
 
22
24
  if s.respond_to? :specification_version then
23
25
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
26
  s.specification_version = 2
25
27
 
26
- if current_version >= 3 then
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
29
  s.add_runtime_dependency(%q<hpricot>, [">= 0.6"])
28
30
  s.add_runtime_dependency(%q<activesupport>, [">= 2.1"])
29
- s.add_runtime_dependency(%q<main>, [">= 2.8.2"])
30
- s.add_runtime_dependency(%q<highline>, [">= 1.4.0"])
31
- s.add_runtime_dependency(%q<activerecord>, [">= 2.1"])
32
- s.add_runtime_dependency(%q<httparty>, [">= 0.1.0"])
31
+ s.add_runtime_dependency(%q<httparty>, [">= 0.2.4"])
32
+ s.add_development_dependency(%q<echoe>, [">= 0"])
33
33
  else
34
34
  s.add_dependency(%q<hpricot>, [">= 0.6"])
35
35
  s.add_dependency(%q<activesupport>, [">= 2.1"])
36
- s.add_dependency(%q<main>, [">= 2.8.2"])
37
- s.add_dependency(%q<highline>, [">= 1.4.0"])
38
- s.add_dependency(%q<activerecord>, [">= 2.1"])
39
- s.add_dependency(%q<httparty>, [">= 0.1.0"])
36
+ s.add_dependency(%q<httparty>, [">= 0.2.4"])
37
+ s.add_dependency(%q<echoe>, [">= 0"])
40
38
  end
41
39
  else
42
40
  s.add_dependency(%q<hpricot>, [">= 0.6"])
43
41
  s.add_dependency(%q<activesupport>, [">= 2.1"])
44
- s.add_dependency(%q<main>, [">= 2.8.2"])
45
- s.add_dependency(%q<highline>, [">= 1.4.0"])
46
- s.add_dependency(%q<activerecord>, [">= 2.1"])
47
- s.add_dependency(%q<httparty>, [">= 0.1.0"])
42
+ s.add_dependency(%q<httparty>, [">= 0.2.4"])
43
+ s.add_dependency(%q<echoe>, [">= 0"])
48
44
  end
49
- end
45
+ end
data/website/index.html CHANGED
@@ -87,7 +87,10 @@ Twitter::Search.new.from('jnunemaker').to('oaknd1').fetch()
87
87
 
88
88
  <p><img src="images/terminal_output.png" alt="Terminal Output" style="width:560px;" /></p>
89
89
 
90
- <p><strong>Note: If you want to use twitter from the command line be sure that sqlite3 and the sqlite3-ruby gem are installed.</strong> I removed the sqlite3-ruby gem as a dependency because you shouldn't need that to just use the API wrapper. Eventually I'll move the CLI interface into another gem.</p>
90
+ <p>I removed the command line dependencies from the gem dependencies list so if you want to use the command line part of the twitter gem be sure to install the following gems as well.</p>
91
+
92
+ <pre><code>$ sudo gem install main highline sqlite3-ruby
93
+ $ sudo gem install activerecord -v 2.2.2</code></pre>
91
94
 
92
95
  <p>The first thing you'll want to do is install the database so your account(s) can be stored.</p>
93
96
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dschn-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7.2
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-26 00:00:00 -07:00
12
+ date: 2009-01-05 00:00:00 -08:00
13
13
  default_executable: twitter
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -31,40 +31,22 @@ dependencies:
31
31
  version: "2.1"
32
32
  version:
33
33
  - !ruby/object:Gem::Dependency
34
- name: main
35
- version_requirement:
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.8.2
41
- version:
42
- - !ruby/object:Gem::Dependency
43
- name: highline
44
- version_requirement:
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.4.0
50
- version:
51
- - !ruby/object:Gem::Dependency
52
- name: activerecord
34
+ name: httparty
53
35
  version_requirement:
54
36
  version_requirements: !ruby/object:Gem::Requirement
55
37
  requirements:
56
38
  - - ">="
57
39
  - !ruby/object:Gem::Version
58
- version: "2.1"
40
+ version: 0.2.4
59
41
  version:
60
42
  - !ruby/object:Gem::Dependency
61
- name: httparty
43
+ name: echoe
62
44
  version_requirement:
63
45
  version_requirements: !ruby/object:Gem::Requirement
64
46
  requirements:
65
47
  - - ">="
66
48
  - !ruby/object:Gem::Version
67
- version: 0.1.0
49
+ version: "0"
68
50
  version:
69
51
  description: a command line interface for twitter, also a library which wraps the twitter api
70
52
  email: nunemaker@gmail.com
@@ -73,19 +55,29 @@ executables:
73
55
  extensions: []
74
56
 
75
57
  extra_rdoc_files:
76
- - History.txt
77
- - License.txt
78
- - Manifest.txt
79
- - README.txt
58
+ - bin/twitter
59
+ - lib/twitter/base.rb
60
+ - lib/twitter/cli/config.rb
61
+ - lib/twitter/cli/helpers.rb
62
+ - lib/twitter/cli/migrations/20080722194500_create_accounts.rb
63
+ - lib/twitter/cli/migrations/20080722194508_create_tweets.rb
64
+ - lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb
65
+ - lib/twitter/cli/migrations/20080722214606_create_configurations.rb
66
+ - lib/twitter/cli/models/account.rb
67
+ - lib/twitter/cli/models/configuration.rb
68
+ - lib/twitter/cli/models/tweet.rb
69
+ - lib/twitter/cli.rb
70
+ - lib/twitter/direct_message.rb
71
+ - lib/twitter/easy_class_maker.rb
72
+ - lib/twitter/rate_limit_status.rb
73
+ - lib/twitter/search.rb
74
+ - lib/twitter/status.rb
75
+ - lib/twitter/user.rb
76
+ - lib/twitter/version.rb
77
+ - lib/twitter.rb
78
+ - README
80
79
  files:
81
- - History.txt
82
- - License.txt
83
- - Manifest.txt
84
- - README.txt
85
- - Rakefile
86
80
  - bin/twitter
87
- - config/hoe.rb
88
- - config/requirements.rb
89
81
  - examples/blocks.rb
90
82
  - examples/direct_messages.rb
91
83
  - examples/favorites.rb
@@ -100,9 +92,8 @@ files:
100
92
  - examples/timeline.rb
101
93
  - examples/twitter.rb
102
94
  - examples/verify_credentials.rb
103
- - lib/twitter.rb
95
+ - History
104
96
  - lib/twitter/base.rb
105
- - lib/twitter/cli.rb
106
97
  - lib/twitter/cli/config.rb
107
98
  - lib/twitter/cli/helpers.rb
108
99
  - lib/twitter/cli/migrations/20080722194500_create_accounts.rb
@@ -112,6 +103,7 @@ files:
112
103
  - lib/twitter/cli/models/account.rb
113
104
  - lib/twitter/cli/models/configuration.rb
114
105
  - lib/twitter/cli/models/tweet.rb
106
+ - lib/twitter/cli.rb
115
107
  - lib/twitter/direct_message.rb
116
108
  - lib/twitter/easy_class_maker.rb
117
109
  - lib/twitter/rate_limit_status.rb
@@ -119,10 +111,11 @@ files:
119
111
  - lib/twitter/status.rb
120
112
  - lib/twitter/user.rb
121
113
  - lib/twitter/version.rb
122
- - script/destroy
123
- - script/generate
124
- - script/txt2html
125
- - setup.rb
114
+ - lib/twitter.rb
115
+ - License
116
+ - Manifest
117
+ - Rakefile
118
+ - README
126
119
  - spec/base_spec.rb
127
120
  - spec/cli/helper_spec.rb
128
121
  - spec/direct_message_spec.rb
@@ -142,9 +135,6 @@ files:
142
135
  - spec/spec_helper.rb
143
136
  - spec/status_spec.rb
144
137
  - spec/user_spec.rb
145
- - tasks/deployment.rake
146
- - tasks/environment.rake
147
- - tasks/website.rake
148
138
  - twitter.gemspec
149
139
  - website/css/common.css
150
140
  - website/images/terminal_output.png
@@ -153,8 +143,12 @@ has_rdoc: true
153
143
  homepage: http://twitter.rubyforge.org
154
144
  post_install_message:
155
145
  rdoc_options:
146
+ - --line-numbers
147
+ - --inline-source
148
+ - --title
149
+ - Twitter
156
150
  - --main
157
- - README.txt
151
+ - README
158
152
  require_paths:
159
153
  - lib
160
154
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -167,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
161
  requirements:
168
162
  - - ">="
169
163
  - !ruby/object:Gem::Version
170
- version: "0"
164
+ version: "1.2"
171
165
  version:
172
166
  requirements: []
173
167
 
data/config/hoe.rb DELETED
@@ -1,74 +0,0 @@
1
- require 'twitter/version'
2
-
3
- AUTHOR = "John Nunemaker" # can also be an array of Authors
4
- EMAIL = "nunemaker@gmail.com"
5
- DESCRIPTION = "a command line interface for twitter, also a library which wraps the twitter api"
6
- GEM_NAME = "twitter" # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = "twitter" # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
10
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
11
-
12
- @config_file = "~/.rubyforge/user-config.yml"
13
- @config = nil
14
- RUBYFORGE_USERNAME = "unknown"
15
- def rubyforge_username
16
- unless @config
17
- begin
18
- @config = YAML.load(File.read(File.expand_path(@config_file)))
19
- rescue
20
- puts <<-EOS
21
- ERROR: No rubyforge config file found: #{@config_file}
22
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
23
- - See http://newgem.rubyforge.org/rubyforge.html for more details
24
- EOS
25
- exit
26
- end
27
- end
28
- RUBYFORGE_USERNAME.replace @config["username"]
29
- end
30
-
31
-
32
- REV = nil
33
- # UNCOMMENT IF REQUIRED:
34
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
35
- VERS = Twitter::VERSION::STRING + (REV ? ".#{REV}" : "")
36
- RDOC_OPTS = ['--quiet', '--title', 'twitter documentation',
37
- "--opname", "index.html",
38
- "--line-numbers",
39
- "--main", "README",
40
- "--inline-source"]
41
-
42
- class Hoe
43
- def extra_deps
44
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
45
- @extra_deps
46
- end
47
- end
48
-
49
- # Generate all the Rake tasks
50
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
51
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
52
- p.author = AUTHOR
53
- p.description = DESCRIPTION
54
- p.email = EMAIL
55
- p.summary = DESCRIPTION
56
- p.url = HOMEPATH
57
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
58
- p.test_globs = ["test/**/test_*.rb"]
59
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
60
-
61
- # == Optional
62
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
63
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
64
- p.extra_deps = [['hpricot', '>= 0.6'], ['activesupport', '>= 2.1'],
65
- ['main', '>= 2.8.2'], ['highline', '>= 1.4.0'],
66
- ['activerecord', '>= 2.1'], ['httparty', '>= 0.1.0']]
67
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
68
-
69
- end
70
-
71
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
72
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
73
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
74
- hoe.rsync_args = '-av --delete --ignore-errors'
@@ -1,17 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
-
4
- require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
6
- begin
7
- require req_gem
8
- rescue LoadError
9
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
- puts "Installation: gem install #{req_gem} -y"
11
- exit
12
- end
13
- end
14
-
15
- $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
-
17
- require 'twitter'
data/script/destroy DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
data/script/txt2html DELETED
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- begin
5
- require 'newgem'
6
- rescue LoadError
7
- puts "\n\nGenerating the website requires the newgem RubyGem"
8
- puts "Install: gem install newgem\n\n"
9
- exit(1)
10
- end
11
- require 'redcloth'
12
- require 'syntax/convertors/html'
13
- require 'erb'
14
- require File.dirname(__FILE__) + '/../lib/twitter/version.rb'
15
-
16
- version = Twitter.git::VERSION::STRING
17
- download = 'http://rubyforge.org/projects/twitter'
18
-
19
- class Fixnum
20
- def ordinal
21
- # teens
22
- return 'th' if (10..19).include?(self % 100)
23
- # others
24
- case self % 10
25
- when 1: return 'st'
26
- when 2: return 'nd'
27
- when 3: return 'rd'
28
- else return 'th'
29
- end
30
- end
31
- end
32
-
33
- class Time
34
- def pretty
35
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
36
- end
37
- end
38
-
39
- def convert_syntax(syntax, source)
40
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
41
- end
42
-
43
- if ARGV.length >= 1
44
- src, template = ARGV
45
- template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
46
-
47
- else
48
- puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
49
- exit!
50
- end
51
-
52
- template = ERB.new(File.open(template).read)
53
-
54
- title = nil
55
- body = nil
56
- File.open(src) do |fsrc|
57
- title_text = fsrc.readline
58
- body_text = fsrc.read
59
- syntax_items = []
60
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61
- ident = syntax_items.length
62
- element, syntax, source = $1, $2, $3
63
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64
- "syntax-temp-#{ident}"
65
- }
66
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
67
- body = RedCloth.new(body_text).to_html
68
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
69
- end
70
- stat = File.stat(src)
71
- created = stat.ctime
72
- modified = stat.mtime
73
-
74
- $stdout << template.result(binding)