nirvana 0.1.0 → 0.1.1

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.
data/.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
14
  s.rubyforge_project = 'tagaholic'
15
15
  s.executables = ['nirvana', 'nirvana-websocket']
16
- s.add_dependency 'ripl', '>= 0.2.1'
16
+ s.add_dependency 'ripl', '>= 0.3.0'
17
17
  s.add_dependency 'escape_utils', '>= 0.1.8'
18
18
  s.add_dependency 'json_pure', '>= 1.4.3'
19
19
  s.add_dependency 'em-websocket', '>= 0.1.4'
@@ -1,2 +1,6 @@
1
+ == 0.1.1
2
+ * Add commandline options via a Runner
3
+ * Fix to work with hirb
4
+
1
5
  == 0.1.0
2
6
  * Finally, a release
@@ -23,6 +23,29 @@ If you close the tab, the path to nirvana's html page is (for reopening)
23
23
 
24
24
  $ echo $(dirname $(gem which nirvana))/nirvana/public/index.html
25
25
 
26
+ To see what options nirvana takes (mostly options like ripl):
27
+
28
+ $ nirvana -h
29
+
30
+ Once you're in the nirvana web shell, autocompletion should work better than irb's (argument
31
+ autocompletion):
32
+
33
+ >> Bo[TAB]
34
+ >> Bond
35
+ >> Bond.const[TAB]
36
+ Bond.const_defined?
37
+ Bond.const_get
38
+ Bond.const_missing
39
+ Bond.const_set
40
+ Bond.constants
41
+ >> Bond.const_g[TAB]
42
+ >> Bond.const_get :Ag[TAB]
43
+ >> Bond.const_get :Agent
44
+
45
+ Also notice that a subset of readline's functionality is available. Try C-l, C-r or C-p and they
46
+ should do what readline normally does. For more keybindings, see
47
+ {readline.js}[http://github.com/cldwalker/readline.js].
48
+
26
49
  == Customize
27
50
  Since nirvana uses ripl under the hood, most shell behavior is customizable with ripl plugins which
28
51
  get loaded from ~/.riplrc. See {ripl}[http://github.com/cldwalker/ripl] for more.
@@ -40,8 +63,14 @@ report them on {readline.js}[http://github.com/cldwalker/readline.js/issues] or
40
63
  == Credits
41
64
  * {rkh's brirb}[http://github.com/rkh/brirb]: Original prototype which inspired this project
42
65
 
66
+ == License
67
+ nirvana is MIT licensed. nirvana comes bundled with other libraries which have the following
68
+ licenses: jquery (GPL2 and MIT), jquery.hotkeys plugin (no license), repl.js jquery plugin (MIT) and
69
+ readline.js jquery plugin (MIT).
70
+
43
71
  == Todo
44
72
  * Tests
73
+ * Easier way to reopen an existing session
45
74
  * Load ~/.irb_history into readline.js
46
75
  * Customizable html and js
47
76
  * Use text area for multi-line input
data/deps.rip CHANGED
@@ -1,4 +1,4 @@
1
- ripl >=0.2.1
1
+ ripl >=0.3.0
2
2
  escape_utils >=0.1.8
3
3
  json_pure >=1.4.3
4
4
  em-websocket >=0.1.4
@@ -2,20 +2,17 @@ require 'ripl'
2
2
  require 'ripl/web'
3
3
  require 'nirvana/shell'
4
4
  require 'nirvana/util'
5
+ require 'nirvana/runner'
5
6
  require 'nirvana/version'
6
7
 
7
8
  module Nirvana
8
- def self.start_shell
9
- stdout, stderr = Util.capture_all {
10
- Ripl::Runner.load_rc(Ripl.config[:riplrc])
11
- Ripl.shell(:name=>'nirvana', :readline=>false).before_loop
12
- }
13
- (result = stdout.to_s + stderr.to_s) ? Util.format_output(result) : result
14
- end
15
-
16
9
  def self.start
17
- system "nirvana-websocket &"
18
- html_file = File.expand_path(File.dirname(__FILE__) + '/nirvana/public/index.html')
19
- RUBY_PLATFORM[/darwin/i] ? system('open', html_file) : puts(html_file)
10
+ if Runner::EXIT_OPTIONS.include? ARGV[0]
11
+ Nirvana::Runner.run ARGV
12
+ else
13
+ system %[nirvana-websocket #{ARGV.join(' ')} &]
14
+ html_file = File.expand_path(File.dirname(__FILE__) + '/nirvana/public/index.html')
15
+ RUBY_PLATFORM[/darwin/i] ? system('open', html_file) : puts(html_file)
16
+ end
20
17
  end
21
18
  end
@@ -0,0 +1,28 @@
1
+ module Nirvana
2
+ class Runner < Ripl::Runner
3
+ self.app = 'nirvana'
4
+ EXIT_OPTIONS = %w{-h --help -v --version}
5
+
6
+ def self.run_command(argv)
7
+ begin
8
+ cmd = argv.shift
9
+ require "ripl/#{cmd}"
10
+ rescue LoadError
11
+ abort "`#{cmd}' is not a nirvana command."
12
+ end
13
+ start
14
+ end
15
+
16
+ def self.start(options={})
17
+ @argv = options[:argv]
18
+ parse_options @argv.dup
19
+ stdout, stderr = Util.capture_all {
20
+ load_rc(Ripl.config[:riplrc]) unless @argv.include? '-F'
21
+ Ripl::Shell.include Nirvana::Shell
22
+ (Ripl.config[:hirb] ||= {})[:pager] = false if defined? Hirb
23
+ Ripl.shell(:name=>'nirvana', :readline=>false).before_loop
24
+ }
25
+ (result = stdout.to_s + stderr.to_s) ? Util.format_output(result) : result
26
+ end
27
+ end
28
+ end
@@ -2,6 +2,7 @@ require 'json'
2
2
  require 'ripl/completion'
3
3
 
4
4
  module Nirvana
5
+ # Included into Ripl::Shell at runtime
5
6
  module Shell
6
7
  def web_loop_once(input)
7
8
  super
@@ -26,7 +27,10 @@ module Nirvana
26
27
  end
27
28
 
28
29
  def format_result(result)
29
- output = Util.format_output @stdout + super
30
+ stdout, stderr, output = Util.capture_all { super }
31
+ @stdout << (stdout.empty? ? output : stdout)
32
+ @stderr << stderr
33
+ output = Util.format_output @stdout
30
34
  output = "<div class='nirvana_warning'>#{@stderr}</div>" + output unless @stderr.to_s.empty?
31
35
  output
32
36
  end
@@ -51,5 +55,3 @@ module Nirvana
51
55
  end
52
56
  end
53
57
  end
54
-
55
- Ripl::Shell.send :include, Nirvana::Shell
@@ -1,3 +1,3 @@
1
1
  module Nirvana
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -7,7 +7,7 @@ module Nirvana
7
7
  EventMachine.run do
8
8
  EventMachine::WebSocket.start(:host => '127.0.0.1', :port => 8080) do |ws|
9
9
  ws.onopen {
10
- result = Nirvana.start_shell
10
+ result = Nirvana::Runner.run ARGV
11
11
  ws.send(result) unless result.to_s.empty?
12
12
  }
13
13
  ws.onmessage {|msg| ws.send Ripl.shell.web_loop_once(msg) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nirvana
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabriel Horner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-12 00:00:00 -05:00
18
+ date: 2011-01-03 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 21
29
+ hash: 19
30
30
  segments:
31
31
  - 0
32
- - 2
33
- - 1
34
- version: 0.2.1
32
+ - 3
33
+ - 0
34
+ version: 0.3.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -93,6 +93,7 @@ extra_rdoc_files:
93
93
  - README.rdoc
94
94
  - LICENSE.txt
95
95
  files:
96
+ - lib/nirvana/runner.rb
96
97
  - lib/nirvana/shell.rb
97
98
  - lib/nirvana/util.rb
98
99
  - lib/nirvana/version.rb