Permalink
Browse files

Moving to MiniTest

  • Loading branch information...
1 parent 49da643 commit 50a5a18b092e9a8dfcedd525b6932a487c2febd0 @rking committed with rking@sharpsaw.org Nov 8, 2012
Showing with 295 additions and 282 deletions.
  1. +1 −50 .gitignore
  2. +5 −9 Gemfile
  3. +87 −28 Gemfile.lock
  4. +0 −6 Guardfile
  5. +4 −33 Rakefile
  6. +10 −1 lib/pry-docmore.rb
  7. +19 −0 pry-docmore.gemspec
  8. +1 −1 pry-docmore.wiki
  9. +0 −154 spec/pry-docmore_spec.rb
  10. +168 −0 test/pry-docmore_spec.rb
  11. 0 spec/spec_helper.rb → test/test_helper.rb
View
51 .gitignore
@@ -1,50 +1 @@
-# rcov generated
-coverage
-coverage.data
-
-# rdoc generated
-rdoc
-
-# yard generated
-doc
-.yardoc
-
-# bundler
-.bundle
-
-# jeweler generated
-pkg
-
-# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
-#
-# * Create a file at ~/.gitignore
-# * Include files you want ignored
-# * Run: git config --global core.excludesfile ~/.gitignore
-#
-# After doing this, these files will be ignored in all your git projects,
-# saving you from having to 'pollute' every project you touch with them
-#
-# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
-#
-# For MacOS:
-#
-#.DS_Store
-
-# For TextMate
-#*.tmproj
-#tmtags
-
-# For emacs:
-#*~
-#\#*
-#.\#*
-
-# For vim:
-#*.swp
-
-# For redcar:
-#.redcar
-
-# For rubinius:
-#*.rbc
-README.html
+*.gem
View
14 Gemfile
@@ -1,16 +1,12 @@
source "http://rubygems.org"
-gem 'pry'
-gem 'pry-doc' # Not strictly a "dependency", but I think I like it here.
+gemspec
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
- gem "rspec"
- gem "yard"
- gem "rdoc"
- gem "bundler"
- gem "guard"
- gem "guard-rspec"
- gem "jeweler", "~> 1.8.3"
+ gem 'pry-full'
+ gem 'yard'
+ gem 'rdoc'
+ gem 'bundler'
# TODO gem "rcov", ">= 0"
end
View
115 Gemfile.lock
@@ -1,54 +1,113 @@
+PATH
+ remote: .
+ specs:
+ pry-docmore (0.0.1)
+ pry
+ pry-doc
+
GEM
remote: http://rubygems.org/
specs:
+ awesome_print (1.1.0)
+ binding_of_caller (0.6.8)
+ bond (0.4.2)
coderay (1.0.6)
+ columnize (0.3.6)
+ debugger (1.1.4)
+ columnize (>= 0.3.1)
+ debugger-linecache (~> 1.1.1)
+ debugger-ruby_core_source (~> 1.1.3)
+ debugger-linecache (1.1.2)
+ debugger-ruby_core_source (>= 1.1.1)
+ debugger-ruby_core_source (1.1.3)
diff-lcs (1.1.3)
- ffi (1.0.11)
- git (1.2.5)
- guard (1.0.2)
- ffi (>= 0.5.0)
- thor (~> 0.14.6)
- guard-rspec (0.7.0)
- guard (>= 0.10.0)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
+ diffy (2.0.8)
+ eventmachine (1.0.0)
+ grit (2.5.0)
+ diff-lcs (~> 1.1)
+ mime-types (~> 1.15)
+ posix-spawn (~> 0.3.6)
+ highline (1.6.15)
+ interception (0.2)
+ jist (1.0.1)
+ json
json (1.7.0)
method_source (0.7.1)
+ mime-types (1.19)
+ nokogiri (1.5.5)
+ plymouth (0.3.2)
+ pry-exception_explorer (>= 0.1.7)
+ posix-spawn (0.3.6)
pry (0.9.9.4)
coderay (~> 1.0.5)
method_source (~> 0.7.1)
slop (>= 2.4.4, < 3)
+ pry-awesome_print (9.6.5)
+ awesome_print (~> 1.1.0)
+ pry-debugger (0.2.0)
+ debugger (~> 1.1.3)
+ pry (~> 0.9.9)
+ pry-developer_tools (0.1.1)
+ pry (>= 0.9.8.pre, < 0.11)
pry-doc (0.4.1)
pry (>= 0.9.0)
yard (~> 0.7.4)
- rake (0.9.2.2)
+ pry-editline (1.1.1)
+ pry-exception_explorer (0.1.9)
+ pry-stack_explorer (>= 0.3.9)
+ pry-full (0.6)
+ bond
+ jist
+ plymouth
+ pry-awesome_print
+ pry-debugger
+ pry-developer_tools
+ pry-doc
+ pry-editline
+ pry-exception_explorer
+ pry-git
+ pry-highlight
+ pry-pretty-numeric
+ pry-remote-em
+ pry-rescue
+ pry-stack_explorer
+ pry-syntax-hacks
+ pry-theme
+ pry-git (0.2.3)
+ diffy
+ grit
+ pry (>= 0.9.8)
+ pry-highlight (0.0.1)
+ coderay
+ json
+ nokogiri
+ pry
+ pry-pretty-numeric (0.1.1)
+ pry
+ pry-remote-em (0.7.3)
+ eventmachine
+ highline
+ pry (~> 0.9)
+ pry-rescue (0.8)
+ interception
+ pry
+ pry-stack_explorer (0.4.6)
+ binding_of_caller (~> 0.6.2)
+ pry-syntax-hacks (0.0.6)
+ pry (>= 0.9.8)
+ pry-theme (0.1.3)
+ json
rdoc (3.12)
json (~> 1.4)
- rspec (2.10.0)
- rspec-core (~> 2.10.0)
- rspec-expectations (~> 2.10.0)
- rspec-mocks (~> 2.10.0)
- rspec-core (2.10.0)
- rspec-expectations (2.10.0)
- diff-lcs (~> 1.1.3)
- rspec-mocks (2.10.1)
slop (2.4.4)
- thor (0.14.6)
yard (0.7.5)
PLATFORMS
ruby
DEPENDENCIES
bundler
- guard
- guard-rspec
- jeweler (~> 1.8.3)
- pry
- pry-doc
+ pry-docmore!
+ pry-full
rdoc
- rspec
yard
View
6 Guardfile
@@ -1,6 +0,0 @@
-guard 'rspec', :version => 2 do
- watch(%r{^spec/.+_spec\.rb$})
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
-end
-# More info at https://github.com/guard/guard#readme
-# vim:ft=ruby
View
37 Rakefile
@@ -1,34 +1,8 @@
# encoding: utf-8
-require 'rubygems'
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-require 'rake'
-
-require 'jeweler'
-Jeweler::Tasks.new do |gem|
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "pry-docmore"
- gem.homepage = "http://github.com/ryanjosephking/pry-docmore"
- gem.license = "MIT"
- gem.summary = %Q{Beyond pry-doc: keywords, dollar-vars, etc.}
- gem.description = %Q{So things like `? alias` work from within pry. Scope is pretty much open beyond that... send in your ideas.}
- gem.email = "pry-docmore@sharpsaw.org"
- gem.authors = %w(rking banisterfiend)
- # dependencies defined in Gemfile
-end
-Jeweler::RubygemsDotOrgTasks.new
-
-require 'rspec/core'
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec) do |spec|
- spec.pattern = FileList['spec/**/*_spec.rb']
+task :i => :interact_here
+task :interact_here do
+ sh *%w(bundle exec pry -Ilib -rpry-docmore) + ARGV[1..-1]
end
# TODO
@@ -37,7 +11,4 @@ end
# spec.rcov = true
#end
-task :default => :spec
-
-require 'yard'
-YARD::Rake::YardocTask.new
+task :default => :tests
View
11 lib/pry-docmore.rb
@@ -1,8 +1,17 @@
# encoding: utf-8
+require 'pry'
class Pry
class Docmore
- Pry.commands.command ',?', 'Doc more — see global/keyword info' do
+ Pry.commands.command '/?' do
Pry.output.puts Pry::Docmore.explain arg_string.strip
+ prev = Pry.commands.entries.find do |cmd, inst| cmd == 'show-doc' end[1]
+ p prev
+ blk = prev.instance_variable_get :@block
+ p blk
+ blk.call arg_string
+ end
+
+ Pry.commands.command ',?', 'Doc more — see global/keyword info' do
end
def self.find_docs pattern
input = Dir['pry-docmore.wiki/*.md'].map do |file_name|
View
19 pry-docmore.gemspec
@@ -0,0 +1,19 @@
+# encoding: utf-8
+
+Gem::Specification.new do |gem|
+ gem.version = '0.0.1'
+ gem.name = 'pry-docmore'
+ gem.summary = 'Documents keywords and special vars. Currently uses the `,?` command, but soon plain `?`'
+ gem.description = `cd pry-docmore.wiki/; echo Ruby*`.
+ gsub(/Ruby (?:Global|Keyword):?\s*/, '').
+ gsub(/\(Dollar[^)]+\)/, '').
+ gsub(/\.md/, '').
+ gsub(/\s+/, ' ')
+ puts 'Desc is: ' + gem.description
+ gem.license = 'CC0'
+ gem.homepage = 'https://github.com/rking/pry-docmore/wiki'
+ gem.email = 'pry-docmore@sharpsaw.org'
+ gem.authors = %w(☈king)
+ %w(pry pry-doc).each {|e| gem.add_dependency e}
+ gem.files = Dir['{lib,pry-docmore.wiki}/**/*']
+end
2 pry-docmore.wiki
@@ -1 +1 @@
-Subproject commit f200fcef71b0c32a630e63702d608cdae2e1785c
+Subproject commit 63051f7ecd9ed6e6c17117718c2bdd34c46d6316
View
154 spec/pry-docmore_spec.rb
@@ -1,154 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-
-keywords = [
- {
- source: "http://www.zenspider.com/Languages/Ruby/QuickRef.html#reserved-words",
- words: %w(
- alias and BEGIN begin break case class def defined?
- do else elsif END end ensure false for if
- in module next nil not or redo rescue retry
- return self super then true undef unless until when
- while yield)
- },
- {
- source: 'http://krijnhoetmer.nl/stuff/ruby/keywords/',
- words: %w(alias and BEGIN begin break case class def defined? do else elsif END end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield)
- },
- {
- source: 'ruby source, lex.c, circa line 219',
- words: %w(alias and begin BEGIN break case class def defined? do else elsif __ENCODING__ end END ensure false __FILE__ for if in __LINE__ module next nil not or redo rescue retry return self super then true undef unless until when while yield)
- },
-]
-
-globals = [
- {
- source: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables',
- vars: %w($! $@ $& $` $' $+ $1 $~ $= $/ $\\ $, $; $. $< $> $_ $0 $* $$ $? $: $" $DEBUG $FILENAME $LOAD_PATH $stderr $stdin $stdout $VERBOSE $-0 $-a $-d $-F $-i $-I $-l $-p $-v $-w)
- },
- {
- source: 'ruby -e "p global_variables.map(&:to_s)"',
- vars: ["$;", "$-F", "$@", "$!", "$SAFE", "$~", "$&", "$`", "$'", "$+", "$=", "$KCODE", "$-K", "$,", "$/", "$-0", "$\\", "$_", "$stdin", "$stdout", "$stderr", "$>", "$<", "$.", "$FILENAME", "$-i", "$*", "$?", "$$", "$:", "$-I", "$LOAD_PATH", "$\"", "$LOADED_FEATURES", "$VERBOSE", "$-v", "$-w", "$-W", "$DEBUG", "$-d", "$0", "$PROGRAM_NAME", "$-p", "$-l", "$-a", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9"]
- },
-# {
-# source: 'pry: ls -g',
-# vars: `echo 'lg -g' | pry`.split /\s+/
-# }
-]
-
-def it_explains_each args
- description = " explained as a #{args[:label]}"
- it nil do
- args[:cases].each do |e|
- e[args[:specifically]].each do |v|
- self.example.metadata[:description_args] = v + description
- multiline_content = %r/.+\n.+/
- Pry::Docmore.explain(v).should match multiline_content
- end
- end
- end
-end
-
-describe "Pry::Docmore" do
- it_explains_each \
- label: 'Keyword',
- cases: keywords,
- specifically: :words
-
- it_explains_each \
- label: 'Global Variable',
- cases: globals,
- specifically: :vars
-
-# TODO - regex syntax!
-
-end
-
-__END__
-::::::::::::::
-input/dollarvars
-::::::::::::::
- case '_': /* $_: last read line string */
- c = nextc();
- if (parser_is_identchar()) {
- tokadd('$');
- tokadd('_');
- break;
- }
- pushback(c);
- c = '_';
- /* fall through */
- case '~': /* $~: match-data */
- case '*': /* $*: argv */
- case '$': /* $$: pid */
- case '?': /* $?: last status */
- case '!': /* $!: error string */
- case '@': /* $@: error position */
- case '/': /* $/: input record separator */
- case '\\': /* $\: output record separator */
- case ';': /* $;: field separator */
- case ',': /* $,: output field separator */
- case '.': /* $.: last read line number */
- case '=': /* $=: ignorecase */
- case ':': /* $:: load path */
- case '<': /* $<: reading filename */
- case '>': /* $>: default output handle */
- case '\"': /* $": already loaded files */
- tokadd('$');
- tokadd(c);
- tokfix();
- set_yylval_name(rb_intern(tok()));
- return tGVAR;
-
- case '-':
- tokadd('$');
- tokadd(c);
- c = nextc();
- if (parser_is_identchar()) {
- if (tokadd_mbchar(c) == -1) return 0;
- }
- else {
- pushback(c);
- }
- gvar:
- tokfix();
- set_yylval_name(rb_intern(tok()));
- return tGVAR;
-
- case '&': /* $&: last match */
- case '`': /* $`: string before last match */
- case '\'': /* $': string after last match */
- case '+': /* $+: string matches last paren. */
- if (last_state == EXPR_FNAME) {
- tokadd('$');
- tokadd(c);
- goto gvar;
- }
- set_yylval_node(NEW_BACK_REF(c));
- return tBACK_REF;
-
- case '1': case '2': case '3':
- case '4': case '5': case '6':
- case '7': case '8': case '9':
- tokadd('$');
- do {
- tokadd(c);
- c = nextc();
- } while (c != -1 && ISDIGIT(c));
- pushback(c);
- if (last_state == EXPR_FNAME) goto gvar;
- tokfix();
- set_yylval_node(NEW_NTH_REF(atoi(tok()+1)));
- return tNTH_REF;
-
- default:
- if (!parser_is_identchar()) {
- pushback(c);
- return '$';
- }
- case '0':
- tokadd('$');
- }
- break;
-::::::::::::::
-input/tokenlist
-::::::::::::::
View
168 test/pry-docmore_spec.rb
@@ -0,0 +1,168 @@
+require 'test_helper'
+require 'minitest/autorun'
+require 'pry-docmore'
+
+
+class Pry::DocmoreTest < MiniTest::Unit::TestCase
+ def assert_each_explained args
+ description = " explained as a #{args[:label]}"
+ args[:cases].each do |e|
+ e[args[:specifically]].each do |v|
+ assert_match /.+/, Pry::Docmore.explain(v), v + description
+ end
+ end
+ end
+
+ def test_keywords
+ assert_each_explained \
+ label: 'Keyword',
+ specifically: :words,
+ cases: [
+ {
+ source: "http://www.zenspider.com/Languages/Ruby/QuickRef.html#reserved-words",
+ words: %w(
+ alias and BEGIN begin break case class def defined?
+ do else elsif END end ensure false for if
+ in module next nil not or redo rescue retry
+ return self super then true undef unless until when
+ while yield)
+ },
+ {
+ source: 'http://krijnhoetmer.nl/stuff/ruby/keywords/',
+ words: %w(alias and BEGIN begin break case class def defined? do else
+ elsif END end ensure false for if in module next nil not or redo rescue retry
+ return self super then true undef unless until when while yield)
+ },
+ {
+ source: 'ruby source, lex.c, circa line 219',
+ words: %w(alias and begin BEGIN break case class def defined? do
+ else elsif __ENCODING__ end END ensure false __FILE__ for if in __LINE__
+ module next nil not or redo rescue retry return self super then true undef
+ unless until when while yield)
+ },
+ ]
+ end
+
+ def test_globals
+ assert_each_explained \
+ label: 'Global Variable',
+ specifically: :vars,
+ cases: [
+ {
+ source: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables',
+ vars: %w(
+ $! $@ $& $` $' $+ $1 $~ $= $/ $\\ $, $; $. $< $> $_ $0 $* $$ $? $: $"
+ $DEBUG $FILENAME $LOAD_PATH $stderr $stdin $stdout $VERBOSE $-0 $-a
+ $-d $-F $-i $-I $-l $-p $-v $-w)
+ },
+ {
+ source: 'ruby -e "p global_variables.map(&:to_s)"',
+ vars: ["$;", "$-F", "$@", "$!", "$SAFE", "$~", "$&", "$`", "$'",
+ "$+", "$=", "$KCODE", "$-K", "$,", "$/", "$-0", "$\\", "$_",
+ "$stdin", "$stdout", "$stderr", "$>", "$<", "$.", "$FILENAME",
+ "$-i", "$*", "$?", "$$", "$:", "$-I", "$LOAD_PATH", "$\"",
+ "$LOADED_FEATURES", "$VERBOSE", "$-v", "$-w", "$-W", "$DEBUG",
+ "$-d", "$0", "$PROGRAM_NAME", "$-p", "$-l", "$-a", "$1", "$2",
+ "$3", "$4", "$5", "$6", "$7", "$8", "$9"]
+ },
+ # {
+ # source: 'pry: ls -g',
+ # vars: `echo 'lg -g' | pry`.split /\s+/
+ # }
+ ]
+
+ end
+
+# TODO - regex syntax!
+
+end
+
+__END__
+::::::::::::::
+input/dollarvars
+::::::::::::::
+ case '_': /* $_: last read line string */
+ c = nextc();
+ if (parser_is_identchar()) {
+ tokadd('$');
+ tokadd('_');
+ break;
+ }
+ pushback(c);
+ c = '_';
+ /* fall through */
+ case '~': /* $~: match-data */
+ case '*': /* $*: argv */
+ case '$': /* $$: pid */
+ case '?': /* $?: last status */
+ case '!': /* $!: error string */
+ case '@': /* $@: error position */
+ case '/': /* $/: input record separator */
+ case '\\': /* $\: output record separator */
+ case ';': /* $;: field separator */
+ case ',': /* $,: output field separator */
+ case '.': /* $.: last read line number */
+ case '=': /* $=: ignorecase */
+ case ':': /* $:: load path */
+ case '<': /* $<: reading filename */
+ case '>': /* $>: default output handle */
+ case '\"': /* $": already loaded files */
+ tokadd('$');
+ tokadd(c);
+ tokfix();
+ set_yylval_name(rb_intern(tok()));
+ return tGVAR;
+
+ case '-':
+ tokadd('$');
+ tokadd(c);
+ c = nextc();
+ if (parser_is_identchar()) {
+ if (tokadd_mbchar(c) == -1) return 0;
+ }
+ else {
+ pushback(c);
+ }
+ gvar:
+ tokfix();
+ set_yylval_name(rb_intern(tok()));
+ return tGVAR;
+
+ case '&': /* $&: last match */
+ case '`': /* $`: string before last match */
+ case '\'': /* $': string after last match */
+ case '+': /* $+: string matches last paren. */
+ if (last_state == EXPR_FNAME) {
+ tokadd('$');
+ tokadd(c);
+ goto gvar;
+ }
+ set_yylval_node(NEW_BACK_REF(c));
+ return tBACK_REF;
+
+ case '1': case '2': case '3':
+ case '4': case '5': case '6':
+ case '7': case '8': case '9':
+ tokadd('$');
+ do {
+ tokadd(c);
+ c = nextc();
+ } while (c != -1 && ISDIGIT(c));
+ pushback(c);
+ if (last_state == EXPR_FNAME) goto gvar;
+ tokfix();
+ set_yylval_node(NEW_NTH_REF(atoi(tok()+1)));
+ return tNTH_REF;
+
+ default:
+ if (!parser_is_identchar()) {
+ pushback(c);
+ return '$';
+ }
+ case '0':
+ tokadd('$');
+ }
+ break;
+::::::::::::::
+input/tokenlist
+::::::::::::::
View
0 spec/spec_helper.rb → test/test_helper.rb
File renamed without changes.

0 comments on commit 50a5a18

Please sign in to comment.