Permalink
Browse files

Removed active support and switched to echoe for gem management.

  • Loading branch information...
1 parent 906d34d commit fbb792561ea2aba8c8e7abb946d2a5e6e3d64fb0 @jnunemaker jnunemaker committed Dec 23, 2008
View
File renamed without changes.
View
File renamed without changes.
View
@@ -1,11 +1,4 @@
-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
@@ -20,9 +13,8 @@ examples/sent_messages.rb
examples/timeline.rb
examples/twitter.rb
examples/verify_credentials.rb
-lib/twitter.rb
+History
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
@@ -32,17 +24,19 @@ 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
-script/destroy
-script/generate
-script/txt2html
-setup.rb
+lib/twitter.rb
+License
+Manifest
+Rakefile
+README
spec/base_spec.rb
spec/cli/helper_spec.rb
spec/direct_message_spec.rb
@@ -62,9 +56,6 @@ 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
View
File renamed without changes.
View
@@ -1,4 +1,42 @@
-require 'config/requirements'
-require 'config/hoe' # setup Hoe + all gem configuration
+ProjectName = 'twitter'
+WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}"
-Dir['tasks/**/*.rake'].each { |rake| load rake }
+require 'rubygems'
+require 'rake'
+require 'echoe'
+require 'spec/rake/spectask'
+require "lib/#{ProjectName}/version"
+
+Echoe.new(ProjectName, Twitter::Version) do |p|
+ p.description = "a command line interface for twitter, also a library which wraps the twitter api"
+ p.url = "http://#{ProjectName}.rubyforge.org"
+ p.author = "John Nunemaker"
+ p.email = "nunemaker@gmail.com"
+ p.extra_deps = [['hpricot', '>= 0.6'], ['activesupport', '>= 2.1'], ['httparty', '>= 0.2.4']]
+ p.need_tar_gz = false
+ p.docs_host = WebsitePath
+end
+
+desc 'Upload website files to rubyforge'
+task :website do
+ sh %{rsync -av website/ #{WebsitePath}}
+ Rake::Task['website_docs'].invoke
+end
+
+task :website_docs do
+ Rake::Task['redocs'].invoke
+ sh %{rsync -av doc/ #{WebsitePath}/docs}
+end
+
+desc 'Preps the gem for a new release'
+task :prepare do
+ %w[manifest build_gemspec].each do |task|
+ Rake::Task[task].invoke
+ end
+end
+
+Rake::Task[:default].prerequisites.clear
+task :default => :spec
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList["spec/**/*_spec.rb"]
+end
View
@@ -10,11 +10,5 @@ if ARGV[0] && ARGV[0] == 'd' && !STDIN.tty?
ARGV[2] = "#{STDIN.read}#{ARGV[2]}"
end
-require 'rubygems'
-
-gem 'main', '>= 2.8.2'
-gem 'highline', '>= 1.4.0'
-gem 'activerecord', '>= 2.1'
-
-require 'twitter'
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'twitter'))
require 'twitter/cli'
View
@@ -1,72 +0,0 @@
-require 'twitter/version'
-
-AUTHOR = "John Nunemaker" # can also be an array of Authors
-EMAIL = "nunemaker@gmail.com"
-DESCRIPTION = "a command line interface for twitter, also a library which wraps the twitter api"
-GEM_NAME = "twitter" # what ppl will type to install your gem
-RUBYFORGE_PROJECT = "twitter" # The unix name for your project
-HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
-RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
-DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
-
-@config_file = "~/.rubyforge/user-config.yml"
-@config = nil
-RUBYFORGE_USERNAME = "unknown"
-def rubyforge_username
- unless @config
- begin
- @config = YAML.load(File.read(File.expand_path(@config_file)))
- rescue
- puts <<-EOS
-ERROR: No rubyforge config file found: #{@config_file}
-Run 'rubyforge setup' to prepare your env for access to Rubyforge
- - See http://newgem.rubyforge.org/rubyforge.html for more details
- EOS
- exit
- end
- end
- RUBYFORGE_USERNAME.replace @config["username"]
-end
-
-
-REV = nil
-# UNCOMMENT IF REQUIRED:
-# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
-VERS = Twitter::VERSION::STRING + (REV ? ".#{REV}" : "")
-RDOC_OPTS = ['--quiet', '--title', 'twitter documentation',
- "--opname", "index.html",
- "--line-numbers",
- "--main", "README",
- "--inline-source"]
-
-class Hoe
- def extra_deps
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
- @extra_deps
- end
-end
-
-# Generate all the Rake tasks
-# Run 'rake -T' to see list of generated tasks (from gem root directory)
-hoe = Hoe.new(GEM_NAME, VERS) do |p|
- p.author = AUTHOR
- p.description = DESCRIPTION
- p.email = EMAIL
- p.summary = DESCRIPTION
- p.url = HOMEPATH
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
- p.test_globs = ["test/**/test_*.rb"]
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
-
- # == Optional
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
- p.extra_deps = [['hpricot', '>= 0.6'], ['activesupport', '>= 2.1'], ['httparty', '>= 0.2.4']]
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
-
-end
-
-CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
-PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
-hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
-hoe.rsync_args = '-av --delete --ignore-errors'
View
@@ -1,17 +0,0 @@
-require 'fileutils'
-include FileUtils
-
-require 'rubygems'
-%w[rake hoe newgem rubigen].each do |req_gem|
- begin
- require req_gem
- rescue LoadError
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
- puts "Installation: gem install #{req_gem} -y"
- exit
- end
-end
-
-$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
-
-require 'twitter'
View
@@ -1,6 +1,12 @@
-%w(uri cgi net/http yaml rubygems hpricot active_support).each { |f| require f }
+require 'uri'
+require 'cgi'
+require 'net/http'
+require 'yaml'
+require 'time'
+require 'rubygems'
+require 'hpricot'
-$:.unshift(File.join(File.dirname(__FILE__)))
+$:.unshift(File.dirname(__FILE__))
require 'twitter/version'
require 'twitter/easy_class_maker'
require 'twitter/base'
View
@@ -184,7 +184,7 @@ def users(doc)
#
# ie: call(:public_timeline, :auth => false)
def call(method, options={})
- options.reverse_merge!({ :auth => true, :args => {} })
+ options = { :auth => true, :args => {} }.merge(options)
# Following line needed as lite=false doesn't work in the API: http://tinyurl.com/yo3h5d
options[:args].delete(:lite) unless options[:args][:lite]
args = options.delete(:args)
@@ -193,11 +193,12 @@ def call(method, options={})
# Makes a request to twitter.
def request(path, options={})
- options.reverse_merge!({
+ options = {
:headers => { "User-Agent" => @config[:email] },
- :method => :get
- })
- unless options[:since].blank?
+ :method => :get,
+ }.merge(options)
+
+ unless options[:since].nil?
since = options[:since].kind_of?(Date) ? options[:since].strftime('%a, %d-%b-%y %T GMT') : options[:since].to_s
options[:headers]["If-Modified-Since"] = since
end
@@ -233,7 +234,11 @@ def request(path, options={})
# Given a path and a hash, build a full path with the hash turned into a query string
def build_path(path, options)
- path += "?#{options.to_query}" unless options.blank?
+ unless options.nil?
+ query = options.inject('') { |str, h| str += "#{CGI.escape(h[0].to_s)}=#{CGI.escape(h[1].to_s)}&"; str }
+ path += "?#{query}"
+ end
+
path
end
View
@@ -1,8 +1,10 @@
require 'rubygems'
+
gem 'main', '>= 2.8.2'
gem 'highline', '>= 1.4.0'
gem 'activerecord', '>= 2.1'
gem 'sqlite3-ruby', '>= 1.2.1'
+
require 'main'
require 'highline/import'
require 'activerecord'
@@ -280,7 +282,7 @@ def run
do_work do
timeline = params['timeline'].value == 'me' ? 'user' : params['timeline'].value
options, since_id = {}, Configuration["#{timeline}_since_id"]
- options[:since_id] = since_id if !since_id.blank? && !params['force'].given?
+ options[:since_id] = since_id if !since_id.nil? && !params['force'].given?
cache = [:friends, :user].include?(timeline)
collection = base.timeline(timeline.to_sym, options)
output_tweets(collection, {:cache => cache, :since_prefix => timeline})
@@ -297,7 +299,7 @@ def run
def run
do_work do
options, since_id = {}, Configuration["replies_since_id"]
- options[:since_id] = since_id if !since_id.blank? && !params['force'].given?
+ options[:since_id] = since_id if !since_id.nil? && !params['force'].given?
collection = base.replies(options)
output_tweets(collection, {:since_prefix => 'replies'})
end
View
@@ -5,24 +5,34 @@ class NoActiveAccount < StandardError; end
class NoAccounts < StandardError; end
def output_tweets(collection, options={})
- options.reverse_merge!({
+ options = {
:cache => false,
:since_prefix => '',
:empty_msg => 'Nothing new since your last check.'
- })
+ }.merge(options)
+
if collection.size > 0
justify = collection.collect { |s| s.user.screen_name }.max { |a,b| a.length <=> b.length }.length rescue 0
indention = ' ' * (justify + 3)
say("\n#{indention}#{collection.size} new tweet(s) found.\n\n")
collection.each do |s|
Tweet.create_from_tweet(current_account, s) if options[:cache]
+
occurred_at = Time.parse(s.created_at).strftime('On %b %d at %l:%M%P')
formatted_time = '-' * occurred_at.length + "\n#{indention}#{occurred_at}"
formatted_name = s.user.screen_name.rjust(justify + 1)
formatted_msg = ''
- s.text.split(' ').in_groups_of(6, false) { |row| formatted_msg += row.join(' ') + "\n#{indention}" }
- say "#{CGI::unescapeHTML(formatted_name)}: #{CGI::unescapeHTML(formatted_msg)}#{formatted_time}\n\n"
+
+ s.text.split(' ').each_with_index do |word, idx|
+ formatted_msg += "#{word} "
+
+ sixth_word = idx != 0 && idx % 6 == 0
+ formatted_msg += "\n#{indention}" if sixth_word
+ end
+
+ say "#{CGI::unescapeHTML(formatted_name)}: #{CGI::unescapeHTML(formatted_msg)}\n#{indention}#{formatted_time}\n\n"
end
+
Configuration["#{options[:since_prefix]}_since_id"] = collection.first.id
else
say(options[:empty_msg])
@@ -35,7 +45,7 @@ def base(username=current_account.username, password=current_account.password)
def current_account
@current_account ||= Account.active
- raise Account.count == 0 ? NoAccounts : NoActiveAccount if @current_account.blank?
+ raise Account.count == 0 ? NoAccounts : NoActiveAccount if @current_account.nil?
@current_account
end
@@ -44,7 +54,7 @@ def attempt_import(&block)
if File.exists?(tweet_file)
say '.twitter file found, attempting import...'
config = YAML::load(File.read(tweet_file))
- if !config['email'].blank? && !config['password'].blank?
+ if !config['email'].nil? && !config['password'].nil?
Account.add(:username => config['email'], :password => config['password'])
say 'Account imported'
block.call if block_given?
View
@@ -11,7 +11,7 @@ class Search
def initialize(q=nil)
clear
- containing(q) unless q.blank?
+ containing(q) if q && q.strip != ''
end
def from(user)
View
@@ -1,9 +1,3 @@
module Twitter #:nodoc:
- module VERSION #:nodoc:
- MAJOR = 0
- MINOR = 3
- TINY = 8
-
- STRING = [MAJOR, MINOR, TINY].join('.')
- end
+ Version = '0.4.0'
end
View
No changes.
View
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-APP_ROOT = File.join(File.dirname(__FILE__), '..')
-
-begin
- require 'rubigen'
-rescue LoadError
- require 'rubygems'
- require 'rubigen'
-end
-require 'rubigen/scripts/destroy'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
-RubiGen::Scripts::Destroy.new.run(ARGV)
Oops, something went wrong.

0 comments on commit fbb7925

Please sign in to comment.