Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 137131deb2000d664a639201dff12450c2a192a3 @vertiginous committed May 20, 2009
Showing with 238 additions and 0 deletions.
  1. +23 −0 .autotest
  2. +6 −0 History.txt
  3. +10 −0 Manifest.txt
  4. +48 −0 README.txt
  5. +12 −0 Rakefile
  6. +3 −0 bin/rem
  7. +7 −0 lib/rem.rb
  8. +35 −0 lib/rem/batch_file.rb
  9. +16 −0 lib/rem/ruby_manager.rb
  10. +61 −0 lib/rem/windows_env.rb
  11. +9 −0 lib/rem/windows_file.rb
  12. +8 −0 test/test_rem.rb
@@ -0,0 +1,23 @@
+# -*- ruby -*-
+
+require 'autotest/restart'
+
+# Autotest.add_hook :initialize do |at|
+# at.extra_files << "../some/external/dependency.rb"
+#
+# at.libs << ":../some/external"
+#
+# at.add_exception 'vendor'
+#
+# at.add_mapping(/dependency.rb/) do |f, _|
+# at.files_matching(/test_.*rb$/)
+# end
+#
+# %w(TestA TestB).each do |klass|
+# at.extra_class_map[klass] = "test/test_misc.rb"
+# end
+# end
+
+# Autotest.add_hook :run_command do |at|
+# system "rake build"
+# end
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2009-05-19
+
+* 1 major enhancement
+
+ * Birthday!
+
@@ -0,0 +1,10 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/rem
+lib/rem.rb
+lib/rem/batch_file.rb
+lib/rem/windows_env.rb
+lib/rem/windows_file.rb
+test/test_rem.rb
@@ -0,0 +1,48 @@
+= rem
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 FIX
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+require './lib/rem.rb'
+
+Hoe.new('rem', Rem::VERSION) do |p|
+ p.rubyforge_name = 'remx' # if different than lowercase project name
+ p.developer('Gordon Thiesfeld', 'gthiesfeld@gmail.com')
+end
+
+# vim: syntax=Ruby
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+abort "you need to write me"
@@ -0,0 +1,7 @@
+class Rem
+ VERSION = '1.0.0'
+end
+
+require 'rem/windows_file'
+require 'rem/windows_env'
+require 'rem/batch_file'
@@ -0,0 +1,35 @@
+
+
+class BatchFile
+
+ def initialize(ruby_exe)
+ ruby_exe = File.expand_path(ruby_exe)
+ @ruby_exe = File.basename(ruby_exe)
+ @bin_dir = WindowsFile.join(File.dirname(ruby_exe))
+ @rubyw_exe = 'rubyw.exe'
+ end
+
+ def update_path
+ paths=ENV['PATH'].split(';').map{ |dir| dir =~ /ruby/i ? @bin_dir : dir }
+ "SET PATH=#{paths.join(';')}"
+ end
+
+ def full_path_to(exe)
+ WindowsFile.join(@bin_dir, exe)
+ end
+
+ def ftype(files)
+ files.map{|filetype, open_with|
+ "FTYPE #{filetype}=#{open_with} \"%1\" %*"
+ }
+ end
+
+ def to_s
+ [ "@ECHO OFF",
+ ":: This batch file generated by #{File.basename($0)}",
+ ftype( :rbfile => full_path_to(@ruby_exe), :rbwfile => full_path_to(@rubyw_exe) ),
+ update_path
+ ].join("\n\n")
+ end
+
+end
@@ -0,0 +1,16 @@
+require 'rbconfig'
+require 'pp'
+
+rubies = Hash.new{|h,k| h[k] = {} }
+
+ruby_bins = Dir[File.join(Config::CONFIG['bindir'], '..', '..', '*', 'bin', 'ruby.exe')]
+ruby_bins.each do |ruby_exe|
+ puts BatchFile.new(ruby_exe)
+ puts
+ puts
+end
+
+# rubies.each{|ver,hash| puts ver
+# hash.each{|k,v| puts "#{k} = #{v}"}
+# }
+# puts 'rubyopt environment variable is set' if ENV['RUBYOPT']
@@ -0,0 +1,61 @@
+require 'rubygems'
+require 'ruby-wmi'
+
+class WindowsEnv
+
+ def self.system
+ new('<SYSTEM>')
+ end
+
+ def self.user
+ user = WMI::Win32_ComputerSystem.find(:first).username
+ new(user)
+ end
+
+ def initialize(account)
+ @env = WMI::Win32_Environment
+ @memo = Hash.new{|h,k| h[k]= @env.find(:first, :conditions => {:name => k, :username => account} ) }
+ end
+
+ def [](name)
+ @memo[name].variablevalue rescue nil
+ end
+
+ def []=(name, other)
+ @memo[name].variablevalue = other
+ @memo[name].put_
+ end
+
+ def to_hash
+ r = {}
+ vars = @env.find(:all, :conditions => {:username => @account})
+ vars.each{|var|
+ @memo[var.name] = var
+ r[var.name] = var.variablevalue
+ }
+ r
+ end
+
+ def has_key?(key)
+ !!self[key]
+ end
+
+end
+
+# env = WindowsEnv.user
+# home = env['home']
+# p home
+
+# env['home'] = env['home'] + '\desktop'
+
+# p env['home']
+
+# env['home'] = home
+# p env['home']
+
+# p env['path']
+
+# p env.has_key?('path')
+# p env.has_key?('rubyopt')
+
+# p WindowsEnv.system.to_hash
@@ -0,0 +1,9 @@
+
+class WindowsFile < File
+
+ def self.join(*items)
+ super.gsub('/','\\')
+ end
+
+end
+
@@ -0,0 +1,8 @@
+require "test/unit"
+require "rem"
+
+class TestRem < Test::Unit::TestCase
+ def test_sanity
+ flunk "write tests or I will kneecap you"
+ end
+end

0 comments on commit 137131d

Please sign in to comment.