_vm 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ <�z'�wW{\[�Yi��v��_q����P�ge��VO�zk1G�ݓ� ����A�u����$,�!9�Ɓ��M�)&�c���U�W#�Ϛ�_
2
+ ��}s��2�҃�y=�0��h��փ��^
@@ -0,0 +1,3 @@
1
+ [submodule "shell-proxy"]
2
+ path = shell-proxy
3
+ url = git://github.com/richo/shell-proxy.git
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gem "shell-proxy"
@@ -0,0 +1,10 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ shell-proxy (0.0.1)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ shell-proxy
@@ -0,0 +1,30 @@
1
+ _vm
2
+ ===
3
+
4
+ A generic version manager.
5
+
6
+ So far, I've generically reimplemented [chruby][1]. The only point of this
7
+ experiment is to see whether or not machine generated posix shell is even sane.
8
+
9
+ Requires [shell-proxy][2] which is so alpha it's not even really published.
10
+ Pull it down and stick it in your load path.
11
+
12
+ If you want to play with it in it's current encarnation, you would want to do something like
13
+
14
+ ```bash
15
+
16
+ # In zsh, I'd love to know how to do this in bash:
17
+ emulate sh -c "`ruby _ruby`"
18
+
19
+ # in a posix compatible sh
20
+
21
+ eval "`ruby _ruby`"
22
+
23
+ ```
24
+
25
+ If you want to do this often, you shouldn't use rubygems and instead shim your
26
+ `RUBY_PATH` directly to shell-proxy, rubygems lookups are slow enough that you
27
+ don't want to do them every time.
28
+
29
+ [1]: https://github.com/postmodern/chruby
30
+ [2]: https://github.com/richo/shell-proxy
data/_ruby ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './manager'
4
+
5
+ class Ruby < Manager
6
+ include Plugin::List
7
+ # Needs to be included last of the main_case plugins
8
+ include Plugin::Set
9
+
10
+ include Plugin::Ruby::Use
11
+ end
12
+
13
+ _ruby = Ruby.new("ruby")
14
+ _ruby.build
@@ -0,0 +1,63 @@
1
+ if File.exists? (shell_proxy_path = File.expand_path("../shell-proxy/lib", __FILE__))
2
+ $:.unshift shell_proxy_path
3
+ end
4
+ require 'shell-proxy'
5
+
6
+ UNDERSCORE_VM_VERSION = "0.0.0"
7
+
8
+ module Plugin
9
+ def self.uuid
10
+ @current_id ||= 0
11
+ @current_id += 1
12
+ :"unique_plugin_method_#{@current_id}"
13
+ end
14
+ module Ruby
15
+ end
16
+ end
17
+
18
+ Dir[File.expand_path("../plugin/**/*.rb", __FILE__)].each do |f|
19
+ require f
20
+ end
21
+
22
+ class Manager < ShellProxy
23
+ @@plugins = Hash.new { |h, k| h[k] = Array.new }
24
+
25
+ def self.add_hook(to, &block)
26
+ uuid = Plugin.uuid
27
+ @@plugins[to] << uuid
28
+ define_method(uuid, &block)
29
+ end
30
+
31
+ attr_reader :name
32
+ def initialize(name)
33
+ @name = name
34
+ end
35
+
36
+ def build(io = nil)
37
+ __main__(io) do
38
+ def for_all(name, iter, &block)
39
+ __for(bare("${__#{name}_LIST}"), iter, &block)
40
+ end
41
+ build_main
42
+ end
43
+ end
44
+
45
+ def build_main
46
+ __function("_#{name}") do
47
+ __case(raw("$1")) do |c|
48
+ c.when("-h|--help") do
49
+ echo raw("usage: _#{name} [version] [opts]")
50
+ end
51
+ c.when("-v|--version") do
52
+ echo raw("_#{name} version #{UNDERSCORE_VM_VERSION}")
53
+ end
54
+ c.when("system") do
55
+ __eval("_#{name}_reset")
56
+ end
57
+ @@plugins[:main_case].each do |plugin|
58
+ self.send(plugin, c)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,20 @@
1
+ module Plugin::List
2
+ def self.included(mod)
3
+ mod.add_hook(:main_case) do |c|
4
+ c.when("") do
5
+ local bare("star")
6
+ for_all(name, "i") do
7
+ __if(raw("[[ \"$i\" == $#{name}_ROOT ]]")) do |ci|
8
+ ci.then do
9
+ __eval('star="*"')
10
+ end
11
+ ci.else do
12
+ __eval('star=" "')
13
+ end
14
+ end
15
+ echo raw(' $star $(basename $i)')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ module Plugin::Ruby::Use
2
+ def self.included(mod)
3
+ mod.add_hook(:toplevel) do
4
+ __function("_#{name}_use") do
5
+ __export("#{name}_ROOT", raw("$1"))
6
+ __export("RUBYOPT", raw("$2"))
7
+
8
+ __export("PATH", raw("${#{name}_ROOT}/bin:$PATH"))
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Plugin::Set
2
+ def self.included(mod)
3
+ mod.add_hook(:main_case) do |c|
4
+ c.when("*") do
5
+ for_all(name, "i") do
6
+ __if(raw("[[ `basename \"$i\"` == *$1* ]]")) do |ci|
7
+ ci.then do
8
+ shift
9
+ __eval("_#{name}_use \"$i\" \"$*\"")
10
+ __return(raw("$?"))
11
+ end
12
+ end
13
+ end
14
+ echo raw("_#{name}: unknown #{name}: $1")
15
+ end
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: _vm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Richo Healey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain:
12
+ - !binary |-
13
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURORENDQWh5Z0F3SUJB
14
+ Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJBTVE0d0RBWURWUVFEREFWeWFX
15
+ Tm8KYnpFWk1CY0dDZ21TSm9tVDhpeGtBUmtXQ1hCemVXTm9NSFJwYXpFVE1C
16
+ RUdDZ21TSm9tVDhpeGtBUmtXQTI1bApkREFlRncweE1qRXdNall4TXpNMU1U
17
+ WmFGdzB4TXpFd01qWXhNek0xTVRaYU1FQXhEakFNQmdOVkJBTU1CWEpwClky
18
+ aHZN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dsN3RnRlZXQ1UrWFZVQmM4WGZmcVRs
35
+ aE9iU0N6U0taNXRaCm51OHViQkV2RncwdXpHSkdRc0RoajFieHlpNUR1Yksy
36
+ WE94VTdHci9meUJWeHlzOUUwV01VUEVldDZseis2bGEKRVpvb0RGQTRZbU1J
37
+ Zlc4RnZqMi9UM1Yvc0wxdkpTRENkVHY3RUNkb1g1c25RbVR4RDlwRnNVbXhM
38
+ ZmlKL01GTQppaXcrT1B0dmxzST0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0t
39
+ LQo=
40
+ date: 2013-04-18 00:00:00.000000000 Z
41
+ dependencies: []
42
+ description: Generic version manager
43
+ email:
44
+ - richo@psych0tik.net
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitmodules
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - README.md
53
+ - _ruby
54
+ - manager.rb
55
+ - plugin/list.rb
56
+ - plugin/ruby/use.rb
57
+ - plugin/set.rb
58
+ homepage: http://github.com/richo/_vm
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - .
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.24
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Generic version manager
82
+ test_files: []
Binary file