nrser-rash 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +104 -0
  3. data/.gitmodules +4 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/.yardopts +7 -0
  7. data/Gemfile +10 -0
  8. data/README.md +4 -0
  9. data/Rakefile +6 -0
  10. data/bash/source-profile.sh +17 -0
  11. data/dev/bin/.gitkeep +0 -0
  12. data/dev/bin/console +33 -0
  13. data/dev/bin/rake +3 -0
  14. data/dev/bin/rash +16 -0
  15. data/dev/bin/rspec +3 -0
  16. data/dev/ref/autocomplete.rb +62 -0
  17. data/dev/scratch/apps.AppleScript +14 -0
  18. data/dev/scratch/blocks.rb +232 -0
  19. data/dev/scratch/decorating_methods.rb +18 -0
  20. data/dev/scratch/functions.sh +80 -0
  21. data/dev/scratch/if.sh +16 -0
  22. data/dev/scratch/inc.rb +3 -0
  23. data/dev/scratch/inheriting_env/main.rb +44 -0
  24. data/dev/scratch/inheriting_env/sub.rb +9 -0
  25. data/dev/scratch/load_main.rb +5 -0
  26. data/dev/scratch/load_module.rb +19 -0
  27. data/dev/scratch/lsregister-dump.txt +30165 -0
  28. data/dev/scratch/main.rb +4 -0
  29. data/dev/scratch/optparse.rb +43 -0
  30. data/dev/scratch/overridding-cd.sh +53 -0
  31. data/dev/scratch/path.sh +22 -0
  32. data/dev/scratch/pirating_methods.rb +62 -0
  33. data/dev/scratch/profile.sh +624 -0
  34. data/dev/scratch/return.sh +5 -0
  35. data/dev/scratch/source_rvm.sh +11 -0
  36. data/dev/scratch/stub-names/project/test +3 -0
  37. data/exe/rash +4 -0
  38. data/lib/nrser/rash/cli/call.rb +137 -0
  39. data/lib/nrser/rash/cli/help.rb +29 -0
  40. data/lib/nrser/rash/cli/list.rb +36 -0
  41. data/lib/nrser/rash/cli/run.rb +54 -0
  42. data/lib/nrser/rash/cli.rb +21 -0
  43. data/lib/nrser/rash/config.rb +172 -0
  44. data/lib/nrser/rash/core_ext/object.rb +55 -0
  45. data/lib/nrser/rash/formatters.rb +105 -0
  46. data/lib/nrser/rash/functions.rb +154 -0
  47. data/lib/nrser/rash/helpers.rb +53 -0
  48. data/lib/nrser/rash/testing.rb +305 -0
  49. data/lib/nrser/rash/util.rb +260 -0
  50. data/lib/nrser/rash/version.rb +17 -0
  51. data/lib/nrser/rash.rb +40 -0
  52. data/nrser-rash.gemspec +48 -0
  53. data/tmp/.gitkeep +0 -0
  54. metadata +248 -0
@@ -0,0 +1,44 @@
1
+ require 'io/wait'
2
+
3
+ ENV['X'] = 'ex'
4
+
5
+ # open a pipe to `sub.rb` for reading and writing
6
+ fp = IO.popen("ruby #{File.dirname(__FILE__)}/sub.rb", 'r+')
7
+
8
+ # read the initial dump from it
9
+ sub_output_1 = ""
10
+ # we need to wait until it's sent data
11
+ sleep 1 while (not fp.ready?)
12
+ # then read into `sub_output_1` while it's still has data
13
+ while fp.ready?
14
+ # i don't know if i need to read in chunks of 1 or what but that seemed
15
+ # like a safe choice. there is a also a `read_nonblocking` call that
16
+ # might be useful instead but looks kinda complicated
17
+ sub_output_1 += fp.read(1)
18
+ end
19
+ # ok, there is no more output waiting
20
+ # dump what we have
21
+ puts "*** SUB OUTPUT 1 ***"
22
+ puts sub_output_1
23
+
24
+ # this means the pipe is read for input
25
+ # we now have control back and sub is blocked waiting on our write
26
+ # change an ENV var now
27
+ ENV['Y'] = 'why'
28
+ puts "WRITING...."
29
+ fp.puts "hey there!"
30
+ puts "WRITTEN."
31
+
32
+ # that should get sub un-blocked
33
+ # now repeat the process above to see what it says
34
+ sub_output_2 = ""
35
+ sleep 1 while (not fp.ready?)
36
+ while fp.ready? && (not fp.eof?)
37
+ sub_output_2 += fp.read(1)
38
+ end
39
+ puts "*** SUB OUTPUT 2 ***"
40
+ puts sub_output_2
41
+ # doesn't look like it gets the ENV update
42
+
43
+ # be a good samaritan
44
+ fp.close
@@ -0,0 +1,9 @@
1
+ puts "sub is here!"
2
+ puts "ENV['X']=#{ENV['X'].inspect}"
3
+ puts "ENV['Y']=#{ENV['Y'].inspect}"
4
+ $stdout.flush
5
+ s = gets
6
+ puts "sub got #{s.inspect}"
7
+ puts "ENV['X']=#{ENV['X'].inspect}"
8
+ puts "ENV['Y']=#{ENV['Y'].inspect}"
9
+ $stdout.flush
@@ -0,0 +1,5 @@
1
+ module M; end
2
+
3
+ load "#{ File.dirname(__FILE__) }/load_module.rb", true
4
+
5
+ p M.singleton_methods
@@ -0,0 +1,19 @@
1
+ def local
2
+ puts 'called local'
3
+ end
4
+
5
+ module M
6
+ puts 'here bro!'
7
+
8
+ def self.f
9
+ g
10
+ end
11
+
12
+ private
13
+
14
+ def self.g
15
+ puts 'called g'
16
+ end
17
+ end
18
+
19
+ M.f