From 6049ad4bcbf0f290ed5d1fcdd2f1d21499b2cc11 Mon Sep 17 00:00:00 2001 From: Dr Nic Williams Date: Sun, 3 May 2009 12:04:51 +1000 Subject: [PATCH] initial import and initial scenario --- .gitignore | 6 + History.txt | 4 + Manifest.txt | 44 +++++ PostInstall.txt | 7 + README.rdoc | 48 +++++ Rakefile | 29 +++ bin/tweet-tail | 10 + features/command_line_app.feature | 17 ++ features/development.feature | 13 ++ features/fixtures/search-jaoo.json | 56 ++++++ features/fixtures/search-jaoo.short.json | 26 +++ features/step_definitions/common_steps.rb | 172 ++++++++++++++++++ .../step_definitions/twitter_data_steps.rb | 7 + features/support/common.rb | 29 +++ features/support/env.rb | 13 ++ features/support/matchers.rb | 11 ++ lib/tweet-tail.rb | 6 + lib/tweet-tail/cli.rb | 42 +++++ script/console | 10 + script/destroy | 14 ++ script/generate | 14 ++ test/test_helper.rb | 3 + test/test_tweet-tail.rb | 11 ++ test/test_tweet-tail_cli.rb | 14 ++ 24 files changed, 606 insertions(+) create mode 100644 .gitignore create mode 100644 History.txt create mode 100644 Manifest.txt create mode 100644 PostInstall.txt create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 bin/tweet-tail create mode 100644 features/command_line_app.feature create mode 100644 features/development.feature create mode 100644 features/fixtures/search-jaoo.json create mode 100644 features/fixtures/search-jaoo.short.json create mode 100644 features/step_definitions/common_steps.rb create mode 100644 features/step_definitions/twitter_data_steps.rb create mode 100644 features/support/common.rb create mode 100644 features/support/env.rb create mode 100644 features/support/matchers.rb create mode 100644 lib/tweet-tail.rb create mode 100644 lib/tweet-tail/cli.rb create mode 100755 script/console create mode 100755 script/destroy create mode 100755 script/generate create mode 100644 test/test_helper.rb create mode 100644 test/test_tweet-tail.rb create mode 100644 test/test_tweet-tail_cli.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..594b6b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +pkg +doc +.DS_Store +tmp +*.log +.test-result \ No newline at end of file diff --git a/History.txt b/History.txt new file mode 100644 index 0000000..733f8d0 --- /dev/null +++ b/History.txt @@ -0,0 +1,4 @@ +== 0.0.1 2009-05-01 + +* 1 major enhancement: + * Initial release diff --git a/Manifest.txt b/Manifest.txt new file mode 100644 index 0000000..09a8e00 --- /dev/null +++ b/Manifest.txt @@ -0,0 +1,44 @@ +History.txt +Manifest.txt +PostInstall.txt +README.rdoc +Rakefile +bin/tweet-tail +features/command_line_app.feature +features/development.feature +features/step_definitions/common_steps.rb +features/step_definitions/twitter_data_steps.rb +features/support/common.rb +features/support/env.rb +features/support/matchers.rb +lib/tweet-tail.rb +lib/tweet-tail/cli.rb +script/console +script/destroy +script/generate +test/fixtures/search-jaoo.html +test/fixtures/search-jaoo_files/Photo_24_normal.jpg +test/fixtures/search-jaoo_files/Picture_2_normal.png +test/fixtures/search-jaoo_files/Steve_Hayes_Thumbnail_normal.jpg +test/fixtures/search-jaoo_files/c_all.js +test/fixtures/search-jaoo_files/charlie_normal.jpg +test/fixtures/search-jaoo_files/expanding.gif +test/fixtures/search-jaoo_files/ga.js +test/fixtures/search-jaoo_files/gnome_normal.jpg +test/fixtures/search-jaoo_files/jquery-latest.txt +test/fixtures/search-jaoo_files/krab_60x60_normal.jpg +test/fixtures/search-jaoo_files/luke_g_normal.jpg +test/fixtures/search-jaoo_files/portraetminineu_normal.jpg +test/fixtures/search-jaoo_files/rmk_manga2_normal.jpg +test/fixtures/search-jaoo_files/rss.png +test/fixtures/search-jaoo_files/search_search.css +test/fixtures/search-jaoo_files/thread.png +test/fixtures/search-jaoo_files/thread_002.png +test/fixtures/search-jaoo_files/twitjaoo_normal.jpg +test/fixtures/search-jaoo_files/twitter-logo-small.png +test/fixtures/search-jaoo_files/twitter.css +test/fixtures/search-jaoo_files/twitter.png +test/fixtures/search.atom +test/test_helper.rb +test/test_tweet-tail.rb +test/test_tweet-tail_cli.rb diff --git a/PostInstall.txt b/PostInstall.txt new file mode 100644 index 0000000..a38ed14 --- /dev/null +++ b/PostInstall.txt @@ -0,0 +1,7 @@ + +For more information on tweet-tail, see http://tweet-tail.rubyforge.org + +NOTE: Change this information in PostInstall.txt +You can also delete it if you don't want it. + + diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..b16b31e --- /dev/null +++ b/README.rdoc @@ -0,0 +1,48 @@ += tweet-tail + +* http://github.com/drnic/tweet-tail + +== DESCRIPTION: + +FIX (describe your package) + +== FEATURES/PROBLEMS: + +* FIX (list of features or problems) + +== SYNOPSIS: + + FIX (code sample of usage) + +== REQUIREMENTS: + +* FIX (list of requirements) + +== INSTALL: + +* FIX (sudo gem install, anything else) + +== LICENSE: + +(The MIT License) + +Copyright (c) 2009 FIXME full name + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a43f21c --- /dev/null +++ b/Rakefile @@ -0,0 +1,29 @@ +require 'rubygems' unless ENV['NO_RUBYGEMS'] +%w[rake rake/clean fileutils newgem rubigen].each { |f| require f } +require File.dirname(__FILE__) + '/lib/tweet-tail' + +# Generate all the Rake tasks +# Run 'rake -T' to see list of generated tasks (from gem root directory) +$hoe = Hoe.new('tweet-tail', TweetTail::VERSION) do |p| + p.developer('Dr Nic', 'drnicwilliams@gmail.com') + p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") + p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required + p.rubyforge_name = p.name # TODO this is default value + # p.extra_deps = [ + # ['activesupport','>= 2.0.2'], + # ] + p.extra_dev_deps = [ + ['newgem', ">= #{::Newgem::VERSION}"] + ] + + p.clean_globs |= %w[**/.DS_Store tmp *.log] + path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}" + p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc') + p.rsync_args = '-av --delete --ignore-errors' +end + +require 'newgem/tasks' # load /tasks/*.rake +Dir['tasks/**/*.rake'].each { |t| load t } + +# TODO - want other tests/tasks run by default? Add them to the list +# task :default => [:spec, :features] diff --git a/bin/tweet-tail b/bin/tweet-tail new file mode 100644 index 0000000..a944f02 --- /dev/null +++ b/bin/tweet-tail @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# +# Created on 2009-5-1. +# Copyright (c) 2009. All rights reserved. + +require File.expand_path(File.dirname(__FILE__) + "/../lib/tweet-tail") + +require "tweet-tail/cli" + +TweetTail::CLI.execute(STDOUT, ARGV) diff --git a/features/command_line_app.feature b/features/command_line_app.feature new file mode 100644 index 0000000..0dc14d1 --- /dev/null +++ b/features/command_line_app.feature @@ -0,0 +1,17 @@ +Feature: Live twitter search results on command line + In order to reduce cost of getting live search results + As a twitter user + I want twitter search results appearing in the console + + Scenario: Display current search results + Given a safe folder + And twitter has some search results for "jaoo" + When I run local executable "tweet-tail" with arguments "jaoo" + Then I should see + """ + mattnhodges: Come speak with me at JAOO next week - http://jaoo.dk/ + Steve_Hayes: @VenessaP I think they went out for noodles. #jaoo + theRMK: Come speak with Matt at JAOO next week + drnic: reading my own abstract for JAOO presentation + """ + \ No newline at end of file diff --git a/features/development.feature b/features/development.feature new file mode 100644 index 0000000..8796ce8 --- /dev/null +++ b/features/development.feature @@ -0,0 +1,13 @@ +Feature: Development processes of newgem itself (rake tasks) + + As a Newgem maintainer or contributor + I want rake tasks to maintain and release the gem + So that I can spend time on the tests and code, and not excessive time on maintenance processes + + Scenario: Generate RubyGem + Given this project is active project folder + And "pkg" folder is deleted + When I invoke task "rake gem" + Then folder "pkg" is created + And file with name matching "pkg/*.gem" is created else you should run "rake manifest" to fix this + And gem spec key "rdoc_options" contains /--mainREADME.rdoc/ diff --git a/features/fixtures/search-jaoo.json b/features/fixtures/search-jaoo.json new file mode 100644 index 0000000..0fa752c --- /dev/null +++ b/features/fixtures/search-jaoo.json @@ -0,0 +1,56 @@ +{ + "results": [ + { + "text": "reading my own abstract for JAOO presentation", + "to_user_id": null, + "from_user": "drnic", + "id": 1666627310, + "from_user_id": 5075, + "iso_language_code": "en", + "source": "<a href="http:\/\/iconfactory.com\/software\/twitterrific">twitterrific<\/a>", + "profile_image_url": "http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/55631479\/Photo_24_normal.jpg", + "created_at": "Fri, 01 May 2009 04:45:42 +0000" + }, + { + "text": "Come speak with Matt at JAOO next week", + "to_user_id": null, + "from_user": "theRMK", + "id": 1666334207, + "from_user_id": 8783115, + "iso_language_code": "en", + "source": "<a href="http:\/\/83degrees.com\/to\/powertwitter">Power Twitter<\/a>", + "profile_image_url": "http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/110356397\/rmk_manga2_normal.jpg", + "created_at": "Fri, 01 May 2009 04:01:38 +0000" + }, + { + "text": "@VenessaP I think they went out for noodles. #jaoo", + "to_user_id": 102294, + "to_user": "VenessaP", + "from_user": "Steve_Hayes", + "id": 1666166639, + "from_user_id": 3169244, + "iso_language_code": "en", + "source": "<a href="http:\/\/www.atebits.com\/">Tweetie<\/a>", + "profile_image_url": "http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/68791310\/Steve_Hayes_Thumbnail_normal.jpg", + "created_at": "Fri, 01 May 2009 03:38:48 +0000" + }, + { + "text": "Come speak with me at JAOO next week - http:\/\/jaoo.dk\/", + "to_user_id": null, + "from_user": "mattnhodges", + "id": 1664823944, + "from_user_id": 503163, + "iso_language_code": "en", + "source": "<a href="http:\/\/desktop.seesmic.com\/">Seesmic Desktop<\/a>", + "profile_image_url": "http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/86466627\/Picture_2_normal.png", + "created_at": "Fri, 01 May 2009 01:06:48 +0000" + }], + "since_id": 0, + "max_id": 1682666650, + "refresh_url": "?since_id=1682666650&q=jaoo", + "results_per_page": 15, + "next_page": "?page=2&max_id=1682666650&q=jaoo", + "completed_in": 0.03198, + "page": 1, + "query": "jaoo" +} diff --git a/features/fixtures/search-jaoo.short.json b/features/fixtures/search-jaoo.short.json new file mode 100644 index 0000000..1957c67 --- /dev/null +++ b/features/fixtures/search-jaoo.short.json @@ -0,0 +1,26 @@ +{ + "results": [ + { + "text": "reading my own abstract for JAOO presentation", + "from_user": "drnic", + "id": 1666627310, + }, + { + "text": "Come speak with Matt at JAOO next week", + "from_user": "theRMK", + "id": 1666334207, + }, + { + "text": "@VenessaP I think they went out for noodles. #jaoo", + "to_user": "VenessaP", + "from_user": "Steve_Hayes", + }, + { + "text": "Come speak with me at JAOO next week - http:\/\/jaoo.dk\/", + "from_user": "mattnhodges", + "id": 1664823944, + }], + "refresh_url": "?since_id=1682666650&q=jaoo", + "results_per_page": 15, + "next_page": "?page=2&max_id=1682666650&q=jaoo" +} diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb new file mode 100644 index 0000000..1244f1c --- /dev/null +++ b/features/step_definitions/common_steps.rb @@ -0,0 +1,172 @@ +Given /^a safe folder/ do + FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp" + FileUtils.mkdir_p @tmp_root + FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home")) + @lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib') + Given %Q{env variable $HOME set to "#{@home_path}"} +end + +Given /^this project is active project folder/ do + Given "a safe folder" + @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..") +end + +Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value| + ENV[env_var] = value +end + +Given /"(.*)" folder is deleted/ do |folder| + in_project_folder { FileUtils.rm_rf folder } +end + +When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments| + @stdout = StringIO.new + in_project_folder do + if Object.const_defined?("APP_ROOT") + APP_ROOT.replace(FileUtils.pwd) + else + APP_ROOT = FileUtils.pwd + end + run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout) + end + File.open(File.join(@tmp_root, "generator.out"), "w") do |f| + @stdout.rewind + f << @stdout.read + end +end + +When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments| + @stdout = File.expand_path(File.join(@tmp_root, "executable.out")) + in_project_folder do + system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}" + end +end + +When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments| + @stdout = File.expand_path(File.join(@tmp_root, "executable.out")) + in_project_folder do + system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}" + end +end + +When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments| + @stdout = File.expand_path(File.join(@tmp_root, "executable.out")) + executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable)) + in_project_folder do + system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}" + end +end + +When /^I invoke task "rake (.*)"/ do |task| + @stdout = File.expand_path(File.join(@tmp_root, "tests.out")) + in_project_folder do + system "rake #{task} --trace > #{@stdout} 2> #{@stdout}" + end +end + +Then /^folder "(.*)" (is|is not) created/ do |folder, is| + in_project_folder do + File.exists?(folder).should(is == 'is' ? be_true : be_false) + end +end + +Then /^file "(.*)" (is|is not) created/ do |file, is| + in_project_folder do + File.exists?(file).should(is == 'is' ? be_true : be_false) + end +end + +Then /^file with name matching "(.*)" is created/ do |pattern| + in_project_folder do + Dir[pattern].should_not be_empty + end +end + +Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex| + in_project_folder do + actual_output = File.read(file) + (does == 'does') ? + actual_output.should(match(/#{regex}/)) : + actual_output.should_not(match(/#{regex}/)) + end +end + +Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file| + File.exists?(gem_file).should be_true + File.exists?(project_file).should be_true + gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}") + project_file_contents = File.read(File.join(@active_project_folder, project_file)) + project_file_contents.should == gem_file_contents +end + +Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator| + actual_output = File.read(@stdout) + does_invoke == "does" ? + actual_output.should(match(/dependency\s+#{generator}/)) : + actual_output.should_not(match(/dependency\s+#{generator}/)) +end + +Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2| + actual_output = File.read(@stdout) + actual_output.should match(/#{opt1}/) + actual_output.should match(/#{opt2}/) +end + +Then /^I should see$/ do |text| + actual_output = File.read(@stdout) + actual_output.should contain(text) +end + +Then /^I should not see$/ do |text| + actual_output = File.read(@stdout) + actual_output.should_not contain(text) +end + +Then /^I should see exactly$/ do |text| + actual_output = File.read(@stdout) + actual_output.should == text +end + +Then /^I should see all (\d+) tests pass/ do |expected_test_count| + expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors} + actual_output = File.read(@stdout) + actual_output.should match(expected) +end + +Then /^I should see all (\d+) examples pass/ do |expected_test_count| + expected = %r{^#{expected_test_count} examples?, 0 failures} + actual_output = File.read(@stdout) + actual_output.should match(expected) +end + +Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml| + in_project_folder do + yaml = eval yaml + YAML.load(File.read(file)).should == yaml + end +end + +Then /^Rakefile can display tasks successfully/ do + @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out")) + in_project_folder do + system "rake -T > #{@stdout} 2> #{@stdout}" + end + actual_output = File.read(@stdout) + actual_output.should match(/^rake\s+\w+\s+#\s.*/) +end + +Then /^task "rake (.*)" is executed successfully/ do |task| + @stdout.should_not be_nil + actual_output = File.read(@stdout) + actual_output.should_not match(/^Don't know how to build task '#{task}'/) + actual_output.should_not match(/Error/i) +end + +Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex| + in_project_folder do + gem_file = Dir["pkg/*.gem"].first + gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`) + spec_value = gem_spec.send(key.to_sym) + spec_value.to_s.should match(/#{regex}/) + end +end diff --git a/features/step_definitions/twitter_data_steps.rb b/features/step_definitions/twitter_data_steps.rb new file mode 100644 index 0000000..4beec6e --- /dev/null +++ b/features/step_definitions/twitter_data_steps.rb @@ -0,0 +1,7 @@ +Given /^twitter has some search results for "([^\"]*)"$/ do |query| + FakeWeb.register_uri( + :get, + "http://search.twitter.com/search.json?q=#{query}", + :file => File.dirname(__FILE__) + + "/../fixtures/search-#{query}.json") +end diff --git a/features/support/common.rb b/features/support/common.rb new file mode 100644 index 0000000..565842c --- /dev/null +++ b/features/support/common.rb @@ -0,0 +1,29 @@ +module CommonHelpers + def in_tmp_folder(&block) + FileUtils.chdir(@tmp_root, &block) + end + + def in_project_folder(&block) + project_folder = @active_project_folder || @tmp_root + FileUtils.chdir(project_folder, &block) + end + + def in_home_folder(&block) + FileUtils.chdir(@home_path, &block) + end + + def force_local_lib_override(project_name = @project_name) + rakefile = File.read(File.join(project_name, 'Rakefile')) + File.open(File.join(project_name, 'Rakefile'), "w+") do |f| + f << "$:.unshift('#{@lib_path}')\n" + f << rakefile + end + end + + def setup_active_project_folder project_name + @active_project_folder = File.join(@tmp_root, project_name) + @project_name = project_name + end +end + +World(CommonHelpers) \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..3286657 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,13 @@ +require File.dirname(__FILE__) + "/../../lib/tweet-tail" + +gem 'cucumber' +require 'cucumber' +gem 'rspec' +require 'spec' + +gem "fakeweb" +require "fakeweb" + +Before do + FakeWeb.allow_net_connect = false +end diff --git a/features/support/matchers.rb b/features/support/matchers.rb new file mode 100644 index 0000000..15d6972 --- /dev/null +++ b/features/support/matchers.rb @@ -0,0 +1,11 @@ +module Matchers + def contain(expected) + simple_matcher("contain #{expected.inspect}") do |given, matcher| + matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}" + matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}" + given.index expected + end + end +end + +World(Matchers) diff --git a/lib/tweet-tail.rb b/lib/tweet-tail.rb new file mode 100644 index 0000000..bcf60a9 --- /dev/null +++ b/lib/tweet-tail.rb @@ -0,0 +1,6 @@ +$:.unshift(File.dirname(__FILE__)) unless + $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) + +module TweetTail + VERSION = '0.0.1' +end \ No newline at end of file diff --git a/lib/tweet-tail/cli.rb b/lib/tweet-tail/cli.rb new file mode 100644 index 0000000..3fb4f53 --- /dev/null +++ b/lib/tweet-tail/cli.rb @@ -0,0 +1,42 @@ +require 'optparse' + +module TweetTail + class CLI + def self.execute(stdout, arguments=[]) + + # NOTE: the option -p/--path= is given as an example, and should be replaced in your application. + + options = { + :path => '~' + } + mandatory_options = %w( ) + + parser = OptionParser.new do |opts| + opts.banner = <<-BANNER.gsub(/^ /,'') + This application is wonderful because... + + Usage: #{File.basename($0)} [options] + + Options are: + BANNER + opts.separator "" + opts.on("-p", "--path=PATH", String, + "This is a sample message.", + "For multiple lines, add more strings.", + "Default: ~") { |arg| options[:path] = arg } + opts.on("-h", "--help", + "Show this help message.") { stdout.puts opts; exit } + opts.parse!(arguments) + + if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? } + stdout.puts opts; exit + end + end + + path = options[:path] + + # do stuff + stdout.puts "SUCCESS!! To update this executable, look in lib/tweet-tail/cli.rb" + end + end +end \ No newline at end of file diff --git a/script/console b/script/console new file mode 100755 index 0000000..61e06fd --- /dev/null +++ b/script/console @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# File: script/console +irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' + +libs = " -r irb/completion" +# Perhaps use a console_lib to store any extra methods I may want available in the cosole +# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}" +libs << " -r #{File.dirname(__FILE__) + '/../lib/tweet-tail.rb'}" +puts "Loading tweet-tail gem" +exec "#{irb} #{libs} --simple-prompt" \ No newline at end of file diff --git a/script/destroy b/script/destroy new file mode 100755 index 0000000..e48464d --- /dev/null +++ b/script/destroy @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path(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) diff --git a/script/generate b/script/generate new file mode 100755 index 0000000..c27f655 --- /dev/null +++ b/script/generate @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) + +begin + require 'rubigen' +rescue LoadError + require 'rubygems' + require 'rubigen' +end +require 'rubigen/scripts/generate' + +ARGV.shift if ['--help', '-h'].include?(ARGV[0]) +RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] +RubiGen::Scripts::Generate.new.run(ARGV) diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..01931f8 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,3 @@ +require 'stringio' +require 'test/unit' +require File.dirname(__FILE__) + '/../lib/tweet-tail' diff --git a/test/test_tweet-tail.rb b/test/test_tweet-tail.rb new file mode 100644 index 0000000..85cd5a1 --- /dev/null +++ b/test/test_tweet-tail.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/test_helper.rb' + +class TestTweetTail < Test::Unit::TestCase + + def setup + end + + def test_truth + assert true + end +end diff --git a/test/test_tweet-tail_cli.rb b/test/test_tweet-tail_cli.rb new file mode 100644 index 0000000..51c80fe --- /dev/null +++ b/test/test_tweet-tail_cli.rb @@ -0,0 +1,14 @@ +require File.join(File.dirname(__FILE__), "test_helper.rb") +require 'tweet-tail/cli' + +class TestTweetTailCli < Test::Unit::TestCase + def setup + TweetTail::CLI.execute(@stdout_io = StringIO.new, []) + @stdout_io.rewind + @stdout = @stdout_io.read + end + + def test_print_default_output + assert_match(/To update this executable/, @stdout) + end +end \ No newline at end of file