Skip to content
This repository
Browse code

Moving to MiniTest

  • Loading branch information...
commit 50a5a18b092e9a8dfcedd525b6932a487c2febd0 1 parent 49da643
☈king authored rking@sharpsaw.org committed
51 .gitignore
... ... @@ -1,50 +1 @@
1   -# rcov generated
2   -coverage
3   -coverage.data
4   -
5   -# rdoc generated
6   -rdoc
7   -
8   -# yard generated
9   -doc
10   -.yardoc
11   -
12   -# bundler
13   -.bundle
14   -
15   -# jeweler generated
16   -pkg
17   -
18   -# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19   -#
20   -# * Create a file at ~/.gitignore
21   -# * Include files you want ignored
22   -# * Run: git config --global core.excludesfile ~/.gitignore
23   -#
24   -# After doing this, these files will be ignored in all your git projects,
25   -# saving you from having to 'pollute' every project you touch with them
26   -#
27   -# 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)
28   -#
29   -# For MacOS:
30   -#
31   -#.DS_Store
32   -
33   -# For TextMate
34   -#*.tmproj
35   -#tmtags
36   -
37   -# For emacs:
38   -#*~
39   -#\#*
40   -#.\#*
41   -
42   -# For vim:
43   -#*.swp
44   -
45   -# For redcar:
46   -#.redcar
47   -
48   -# For rubinius:
49   -#*.rbc
50   -README.html
  1 +*.gem
14 Gemfile
... ... @@ -1,16 +1,12 @@
1 1 source "http://rubygems.org"
2   -gem 'pry'
3   -gem 'pry-doc' # Not strictly a "dependency", but I think I like it here.
  2 +gemspec
4 3
5 4 # Add dependencies to develop your gem here.
6 5 # Include everything needed to run rake, tests, features, etc.
7 6 group :development do
8   - gem "rspec"
9   - gem "yard"
10   - gem "rdoc"
11   - gem "bundler"
12   - gem "guard"
13   - gem "guard-rspec"
14   - gem "jeweler", "~> 1.8.3"
  7 + gem 'pry-full'
  8 + gem 'yard'
  9 + gem 'rdoc'
  10 + gem 'bundler'
15 11 # TODO gem "rcov", ">= 0"
16 12 end
115 Gemfile.lock
... ... @@ -1,42 +1,105 @@
  1 +PATH
  2 + remote: .
  3 + specs:
  4 + pry-docmore (0.0.1)
  5 + pry
  6 + pry-doc
  7 +
1 8 GEM
2 9 remote: http://rubygems.org/
3 10 specs:
  11 + awesome_print (1.1.0)
  12 + binding_of_caller (0.6.8)
  13 + bond (0.4.2)
4 14 coderay (1.0.6)
  15 + columnize (0.3.6)
  16 + debugger (1.1.4)
  17 + columnize (>= 0.3.1)
  18 + debugger-linecache (~> 1.1.1)
  19 + debugger-ruby_core_source (~> 1.1.3)
  20 + debugger-linecache (1.1.2)
  21 + debugger-ruby_core_source (>= 1.1.1)
  22 + debugger-ruby_core_source (1.1.3)
5 23 diff-lcs (1.1.3)
6   - ffi (1.0.11)
7   - git (1.2.5)
8   - guard (1.0.2)
9   - ffi (>= 0.5.0)
10   - thor (~> 0.14.6)
11   - guard-rspec (0.7.0)
12   - guard (>= 0.10.0)
13   - jeweler (1.8.3)
14   - bundler (~> 1.0)
15   - git (>= 1.2.5)
16   - rake
17   - rdoc
  24 + diffy (2.0.8)
  25 + eventmachine (1.0.0)
  26 + grit (2.5.0)
  27 + diff-lcs (~> 1.1)
  28 + mime-types (~> 1.15)
  29 + posix-spawn (~> 0.3.6)
  30 + highline (1.6.15)
  31 + interception (0.2)
  32 + jist (1.0.1)
  33 + json
18 34 json (1.7.0)
19 35 method_source (0.7.1)
  36 + mime-types (1.19)
  37 + nokogiri (1.5.5)
  38 + plymouth (0.3.2)
  39 + pry-exception_explorer (>= 0.1.7)
  40 + posix-spawn (0.3.6)
20 41 pry (0.9.9.4)
21 42 coderay (~> 1.0.5)
22 43 method_source (~> 0.7.1)
23 44 slop (>= 2.4.4, < 3)
  45 + pry-awesome_print (9.6.5)
  46 + awesome_print (~> 1.1.0)
  47 + pry-debugger (0.2.0)
  48 + debugger (~> 1.1.3)
  49 + pry (~> 0.9.9)
  50 + pry-developer_tools (0.1.1)
  51 + pry (>= 0.9.8.pre, < 0.11)
24 52 pry-doc (0.4.1)
25 53 pry (>= 0.9.0)
26 54 yard (~> 0.7.4)
27   - rake (0.9.2.2)
  55 + pry-editline (1.1.1)
  56 + pry-exception_explorer (0.1.9)
  57 + pry-stack_explorer (>= 0.3.9)
  58 + pry-full (0.6)
  59 + bond
  60 + jist
  61 + plymouth
  62 + pry-awesome_print
  63 + pry-debugger
  64 + pry-developer_tools
  65 + pry-doc
  66 + pry-editline
  67 + pry-exception_explorer
  68 + pry-git
  69 + pry-highlight
  70 + pry-pretty-numeric
  71 + pry-remote-em
  72 + pry-rescue
  73 + pry-stack_explorer
  74 + pry-syntax-hacks
  75 + pry-theme
  76 + pry-git (0.2.3)
  77 + diffy
  78 + grit
  79 + pry (>= 0.9.8)
  80 + pry-highlight (0.0.1)
  81 + coderay
  82 + json
  83 + nokogiri
  84 + pry
  85 + pry-pretty-numeric (0.1.1)
  86 + pry
  87 + pry-remote-em (0.7.3)
  88 + eventmachine
  89 + highline
  90 + pry (~> 0.9)
  91 + pry-rescue (0.8)
  92 + interception
  93 + pry
  94 + pry-stack_explorer (0.4.6)
  95 + binding_of_caller (~> 0.6.2)
  96 + pry-syntax-hacks (0.0.6)
  97 + pry (>= 0.9.8)
  98 + pry-theme (0.1.3)
  99 + json
28 100 rdoc (3.12)
29 101 json (~> 1.4)
30   - rspec (2.10.0)
31   - rspec-core (~> 2.10.0)
32   - rspec-expectations (~> 2.10.0)
33   - rspec-mocks (~> 2.10.0)
34   - rspec-core (2.10.0)
35   - rspec-expectations (2.10.0)
36   - diff-lcs (~> 1.1.3)
37   - rspec-mocks (2.10.1)
38 102 slop (2.4.4)
39   - thor (0.14.6)
40 103 yard (0.7.5)
41 104
42 105 PLATFORMS
@@ -44,11 +107,7 @@ PLATFORMS
44 107
45 108 DEPENDENCIES
46 109 bundler
47   - guard
48   - guard-rspec
49   - jeweler (~> 1.8.3)
50   - pry
51   - pry-doc
  110 + pry-docmore!
  111 + pry-full
52 112 rdoc
53   - rspec
54 113 yard
6 Guardfile
... ... @@ -1,6 +0,0 @@
1   -guard 'rspec', :version => 2 do
2   - watch(%r{^spec/.+_spec\.rb$})
3   - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4   -end
5   -# More info at https://github.com/guard/guard#readme
6   -# vim:ft=ruby
37 Rakefile
... ... @@ -1,34 +1,8 @@
1 1 # encoding: utf-8
2 2
3   -require 'rubygems'
4   -require 'bundler'
5   -begin
6   - Bundler.setup(:default, :development)
7   -rescue Bundler::BundlerError => e
8   - $stderr.puts e.message
9   - $stderr.puts "Run `bundle install` to install missing gems"
10   - exit e.status_code
11   -end
12   -require 'rake'
13   -
14   -require 'jeweler'
15   -Jeweler::Tasks.new do |gem|
16   - # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17   - gem.name = "pry-docmore"
18   - gem.homepage = "http://github.com/ryanjosephking/pry-docmore"
19   - gem.license = "MIT"
20   - gem.summary = %Q{Beyond pry-doc: keywords, dollar-vars, etc.}
21   - gem.description = %Q{So things like `? alias` work from within pry. Scope is pretty much open beyond that... send in your ideas.}
22   - gem.email = "pry-docmore@sharpsaw.org"
23   - gem.authors = %w(rking banisterfiend)
24   - # dependencies defined in Gemfile
25   -end
26   -Jeweler::RubygemsDotOrgTasks.new
27   -
28   -require 'rspec/core'
29   -require 'rspec/core/rake_task'
30   -RSpec::Core::RakeTask.new(:spec) do |spec|
31   - spec.pattern = FileList['spec/**/*_spec.rb']
  3 +task :i => :interact_here
  4 +task :interact_here do
  5 + sh *%w(bundle exec pry -Ilib -rpry-docmore) + ARGV[1..-1]
32 6 end
33 7
34 8 # TODO
@@ -37,7 +11,4 @@ end
37 11 # spec.rcov = true
38 12 #end
39 13
40   -task :default => :spec
41   -
42   -require 'yard'
43   -YARD::Rake::YardocTask.new
  14 +task :default => :tests
11 lib/pry-docmore.rb
... ... @@ -1,8 +1,17 @@
1 1 # encoding: utf-8
  2 +require 'pry'
2 3 class Pry
3 4 class Docmore
4   - Pry.commands.command ',?', 'Doc more — see global/keyword info' do
  5 + Pry.commands.command '/?' do
5 6 Pry.output.puts Pry::Docmore.explain arg_string.strip
  7 + prev = Pry.commands.entries.find do |cmd, inst| cmd == 'show-doc' end[1]
  8 + p prev
  9 + blk = prev.instance_variable_get :@block
  10 + p blk
  11 + blk.call arg_string
  12 + end
  13 +
  14 + Pry.commands.command ',?', 'Doc more — see global/keyword info' do
6 15 end
7 16 def self.find_docs pattern
8 17 input = Dir['pry-docmore.wiki/*.md'].map do |file_name|
19 pry-docmore.gemspec
... ... @@ -0,0 +1,19 @@
  1 +# encoding: utf-8
  2 +
  3 +Gem::Specification.new do |gem|
  4 + gem.version = '0.0.1'
  5 + gem.name = 'pry-docmore'
  6 + gem.summary = 'Documents keywords and special vars. Currently uses the `,?` command, but soon plain `?`'
  7 + gem.description = `cd pry-docmore.wiki/; echo Ruby*`.
  8 + gsub(/Ruby (?:Global|Keyword):?\s*/, '').
  9 + gsub(/\(Dollar[^)]+\)/, '').
  10 + gsub(/\.md/, '').
  11 + gsub(/\s+/, ' ')
  12 + puts 'Desc is: ' + gem.description
  13 + gem.license = 'CC0'
  14 + gem.homepage = 'https://github.com/rking/pry-docmore/wiki'
  15 + gem.email = 'pry-docmore@sharpsaw.org'
  16 + gem.authors = %w(☈king)
  17 + %w(pry pry-doc).each {|e| gem.add_dependency e}
  18 + gem.files = Dir['{lib,pry-docmore.wiki}/**/*']
  19 +end
2  pry-docmore.wiki
Source Rendered
... ... @@ -1 +1 @@
1   -Subproject commit f200fcef71b0c32a630e63702d608cdae2e1785c
  1 +Subproject commit 63051f7ecd9ed6e6c17117718c2bdd34c46d6316
154 spec/pry-docmore_spec.rb
... ... @@ -1,154 +0,0 @@
1   -require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2   -
3   -keywords = [
4   - {
5   - source: "http://www.zenspider.com/Languages/Ruby/QuickRef.html#reserved-words",
6   - words: %w(
7   - alias and BEGIN begin break case class def defined?
8   - do else elsif END end ensure false for if
9   - in module next nil not or redo rescue retry
10   - return self super then true undef unless until when
11   - while yield)
12   - },
13   - {
14   - source: 'http://krijnhoetmer.nl/stuff/ruby/keywords/',
15   - 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)
16   - },
17   - {
18   - source: 'ruby source, lex.c, circa line 219',
19   - 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)
20   - },
21   -]
22   -
23   -globals = [
24   - {
25   - source: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables',
26   - vars: %w($! $@ $& $` $' $+ $1 $~ $= $/ $\\ $, $; $. $< $> $_ $0 $* $$ $? $: $" $DEBUG $FILENAME $LOAD_PATH $stderr $stdin $stdout $VERBOSE $-0 $-a $-d $-F $-i $-I $-l $-p $-v $-w)
27   - },
28   - {
29   - source: 'ruby -e "p global_variables.map(&:to_s)"',
30   - 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"]
31   - },
32   -# {
33   -# source: 'pry: ls -g',
34   -# vars: `echo 'lg -g' | pry`.split /\s+/
35   -# }
36   -]
37   -
38   -def it_explains_each args
39   - description = " explained as a #{args[:label]}"
40   - it nil do
41   - args[:cases].each do |e|
42   - e[args[:specifically]].each do |v|
43   - self.example.metadata[:description_args] = v + description
44   - multiline_content = %r/.+\n.+/
45   - Pry::Docmore.explain(v).should match multiline_content
46   - end
47   - end
48   - end
49   -end
50   -
51   -describe "Pry::Docmore" do
52   - it_explains_each \
53   - label: 'Keyword',
54   - cases: keywords,
55   - specifically: :words
56   -
57   - it_explains_each \
58   - label: 'Global Variable',
59   - cases: globals,
60   - specifically: :vars
61   -
62   -# TODO - regex syntax!
63   -
64   -end
65   -
66   -__END__
67   -::::::::::::::
68   -input/dollarvars
69   -::::::::::::::
70   - case '_': /* $_: last read line string */
71   - c = nextc();
72   - if (parser_is_identchar()) {
73   - tokadd('$');
74   - tokadd('_');
75   - break;
76   - }
77   - pushback(c);
78   - c = '_';
79   - /* fall through */
80   - case '~': /* $~: match-data */
81   - case '*': /* $*: argv */
82   - case '$': /* $$: pid */
83   - case '?': /* $?: last status */
84   - case '!': /* $!: error string */
85   - case '@': /* $@: error position */
86   - case '/': /* $/: input record separator */
87   - case '\\': /* $\: output record separator */
88   - case ';': /* $;: field separator */
89   - case ',': /* $,: output field separator */
90   - case '.': /* $.: last read line number */
91   - case '=': /* $=: ignorecase */
92   - case ':': /* $:: load path */
93   - case '<': /* $<: reading filename */
94   - case '>': /* $>: default output handle */
95   - case '\"': /* $": already loaded files */
96   - tokadd('$');
97   - tokadd(c);
98   - tokfix();
99   - set_yylval_name(rb_intern(tok()));
100   - return tGVAR;
101   -
102   - case '-':
103   - tokadd('$');
104   - tokadd(c);
105   - c = nextc();
106   - if (parser_is_identchar()) {
107   - if (tokadd_mbchar(c) == -1) return 0;
108   - }
109   - else {
110   - pushback(c);
111   - }
112   - gvar:
113   - tokfix();
114   - set_yylval_name(rb_intern(tok()));
115   - return tGVAR;
116   -
117   - case '&': /* $&: last match */
118   - case '`': /* $`: string before last match */
119   - case '\'': /* $': string after last match */
120   - case '+': /* $+: string matches last paren. */
121   - if (last_state == EXPR_FNAME) {
122   - tokadd('$');
123   - tokadd(c);
124   - goto gvar;
125   - }
126   - set_yylval_node(NEW_BACK_REF(c));
127   - return tBACK_REF;
128   -
129   - case '1': case '2': case '3':
130   - case '4': case '5': case '6':
131   - case '7': case '8': case '9':
132   - tokadd('$');
133   - do {
134   - tokadd(c);
135   - c = nextc();
136   - } while (c != -1 && ISDIGIT(c));
137   - pushback(c);
138   - if (last_state == EXPR_FNAME) goto gvar;
139   - tokfix();
140   - set_yylval_node(NEW_NTH_REF(atoi(tok()+1)));
141   - return tNTH_REF;
142   -
143   - default:
144   - if (!parser_is_identchar()) {
145   - pushback(c);
146   - return '$';
147   - }
148   - case '0':
149   - tokadd('$');
150   - }
151   - break;
152   -::::::::::::::
153   -input/tokenlist
154   -::::::::::::::
168 test/pry-docmore_spec.rb
... ... @@ -0,0 +1,168 @@
  1 +require 'test_helper'
  2 +require 'minitest/autorun'
  3 +require 'pry-docmore'
  4 +
  5 +
  6 +class Pry::DocmoreTest < MiniTest::Unit::TestCase
  7 + def assert_each_explained args
  8 + description = " explained as a #{args[:label]}"
  9 + args[:cases].each do |e|
  10 + e[args[:specifically]].each do |v|
  11 + assert_match /.+/, Pry::Docmore.explain(v), v + description
  12 + end
  13 + end
  14 + end
  15 +
  16 + def test_keywords
  17 + assert_each_explained \
  18 + label: 'Keyword',
  19 + specifically: :words,
  20 + cases: [
  21 + {
  22 + source: "http://www.zenspider.com/Languages/Ruby/QuickRef.html#reserved-words",
  23 + words: %w(
  24 + alias and BEGIN begin break case class def defined?
  25 + do else elsif END end ensure false for if
  26 + in module next nil not or redo rescue retry
  27 + return self super then true undef unless until when
  28 + while yield)
  29 + },
  30 + {
  31 + source: 'http://krijnhoetmer.nl/stuff/ruby/keywords/',
  32 + words: %w(alias and BEGIN begin break case class def defined? do else
  33 + elsif END end ensure false for if in module next nil not or redo rescue retry
  34 + return self super then true undef unless until when while yield)
  35 + },
  36 + {
  37 + source: 'ruby source, lex.c, circa line 219',
  38 + words: %w(alias and begin BEGIN break case class def defined? do
  39 + else elsif __ENCODING__ end END ensure false __FILE__ for if in __LINE__
  40 + module next nil not or redo rescue retry return self super then true undef
  41 + unless until when while yield)
  42 + },
  43 + ]
  44 + end
  45 +
  46 + def test_globals
  47 + assert_each_explained \
  48 + label: 'Global Variable',
  49 + specifically: :vars,
  50 + cases: [
  51 + {
  52 + source: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables',
  53 + vars: %w(
  54 + $! $@ $& $` $' $+ $1 $~ $= $/ $\\ $, $; $. $< $> $_ $0 $* $$ $? $: $"
  55 + $DEBUG $FILENAME $LOAD_PATH $stderr $stdin $stdout $VERBOSE $-0 $-a
  56 + $-d $-F $-i $-I $-l $-p $-v $-w)
  57 + },
  58 + {
  59 + source: 'ruby -e "p global_variables.map(&:to_s)"',
  60 + vars: ["$;", "$-F", "$@", "$!", "$SAFE", "$~", "$&", "$`", "$'",
  61 + "$+", "$=", "$KCODE", "$-K", "$,", "$/", "$-0", "$\\", "$_",
  62 + "$stdin", "$stdout", "$stderr", "$>", "$<", "$.", "$FILENAME",
  63 + "$-i", "$*", "$?", "$$", "$:", "$-I", "$LOAD_PATH", "$\"",
  64 + "$LOADED_FEATURES", "$VERBOSE", "$-v", "$-w", "$-W", "$DEBUG",
  65 + "$-d", "$0", "$PROGRAM_NAME", "$-p", "$-l", "$-a", "$1", "$2",
  66 + "$3", "$4", "$5", "$6", "$7", "$8", "$9"]
  67 + },
  68 + # {
  69 + # source: 'pry: ls -g',
  70 + # vars: `echo 'lg -g' | pry`.split /\s+/
  71 + # }
  72 + ]
  73 +
  74 + end
  75 +
  76 +# TODO - regex syntax!
  77 +
  78 +end
  79 +
  80 +__END__
  81 +::::::::::::::
  82 +input/dollarvars
  83 +::::::::::::::
  84 + case '_': /* $_: last read line string */
  85 + c = nextc();
  86 + if (parser_is_identchar()) {
  87 + tokadd('$');
  88 + tokadd('_');
  89 + break;
  90 + }
  91 + pushback(c);
  92 + c = '_';
  93 + /* fall through */
  94 + case '~': /* $~: match-data */
  95 + case '*': /* $*: argv */
  96 + case '$': /* $$: pid */
  97 + case '?': /* $?: last status */
  98 + case '!': /* $!: error string */
  99 + case '@': /* $@: error position */
  100 + case '/': /* $/: input record separator */
  101 + case '\\': /* $\: output record separator */
  102 + case ';': /* $;: field separator */
  103 + case ',': /* $,: output field separator */
  104 + case '.': /* $.: last read line number */
  105 + case '=': /* $=: ignorecase */
  106 + case ':': /* $:: load path */
  107 + case '<': /* $<: reading filename */
  108 + case '>': /* $>: default output handle */
  109 + case '\"': /* $": already loaded files */
  110 + tokadd('$');
  111 + tokadd(c);
  112 + tokfix();
  113 + set_yylval_name(rb_intern(tok()));
  114 + return tGVAR;
  115 +
  116 + case '-':
  117 + tokadd('$');
  118 + tokadd(c);
  119 + c = nextc();
  120 + if (parser_is_identchar()) {
  121 + if (tokadd_mbchar(c) == -1) return 0;
  122 + }
  123 + else {
  124 + pushback(c);
  125 + }
  126 + gvar:
  127 + tokfix();
  128 + set_yylval_name(rb_intern(tok()));
  129 + return tGVAR;
  130 +
  131 + case '&': /* $&: last match */
  132 + case '`': /* $`: string before last match */
  133 + case '\'': /* $': string after last match */
  134 + case '+': /* $+: string matches last paren. */
  135 + if (last_state == EXPR_FNAME) {
  136 + tokadd('$');
  137 + tokadd(c);
  138 + goto gvar;
  139 + }
  140 + set_yylval_node(NEW_BACK_REF(c));
  141 + return tBACK_REF;
  142 +
  143 + case '1': case '2': case '3':
  144 + case '4': case '5': case '6':
  145 + case '7': case '8': case '9':
  146 + tokadd('$');
  147 + do {
  148 + tokadd(c);
  149 + c = nextc();
  150 + } while (c != -1 && ISDIGIT(c));
  151 + pushback(c);
  152 + if (last_state == EXPR_FNAME) goto gvar;
  153 + tokfix();
  154 + set_yylval_node(NEW_NTH_REF(atoi(tok()+1)));
  155 + return tNTH_REF;
  156 +
  157 + default:
  158 + if (!parser_is_identchar()) {
  159 + pushback(c);
  160 + return '$';
  161 + }
  162 + case '0':
  163 + tokadd('$');
  164 + }
  165 + break;
  166 +::::::::::::::
  167 +input/tokenlist
  168 +::::::::::::::
0  spec/spec_helper.rb → test/test_helper.rb
File renamed without changes

0 comments on commit 50a5a18

Please sign in to comment.
Something went wrong with that request. Please try again.