Sha256: 60928fd4c1fe7b2e8eea8686f0ef4c3b94a889cfab88d64fafaa14a00dfb2c51

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

#!/usr/bin/env ruby
#
#  Created on 2008-2-19.
#  Copyright (c) 2008. All rights reserved.

begin
  require 'rubygems'
rescue LoadError
  # no rubygems to load, so we fail silently
end

require 'optparse'

# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.

OPTIONS = {
  :path     => '~'
}
MANDATORY_OPTIONS = %w(  )

parser = OptionParser.new do |opts|
  opts.banner = <<BANNER
This application is wonderful because...

Usage: #{File.basename($0)} [options]

Options are:
BANNER
  opts.separator ""
  opts.on("-p", "--path=PATH", String,
          "The root path for selecting files",
          "Default: ~") { |OPTIONS[:path]| }
  opts.on("-h", "--help",
          "Show this help message.") { puts opts; exit }
  opts.parse!(ARGV)

  if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
    puts opts; exit
  end
end

path = OPTIONS[:path]

require 'fileutils'
unpacked_msg = %x[gem unpack thoughtful]
unpacked_location = unpacked_msg.gsub(/^.*'(.*)'$/, '\1').chomp
Dir["vendor/thoughtful/**/.svn"].each do |file|
  mv(file, "#{unpacked_location}/lib/" + file.gsub(/^vendor\/thoughtful\/(.*)/,'\1').chomp) if file =~ /.svn/
end
FileUtils.rm_rf "vendor/thoughtful"
FileUtils.mv "#{unpacked_location}/lib/", "vendor/thoughtful"
FileUtils.rm_rf unpacked_location

current_environment = File.readlines("config/environment.rb")
require_line = "require RAILS_ROOT + '/vendor/thoughtful/thoughtful'"
File.open("config/environment.rb", "w") do |file|
  after_book = false
  current_environment.each do |line|
    if after_book
      if line.chomp != require_line.chomp
        file << require_line
        file << "\n"
      end
      after_book = false
    end
    file << line
    after_book = true if line =~ /require File\.join\(File\.dirname\(__FILE__\), 'boot'\)/
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thoughtful-0.0.7 bin/thoughtify
thoughtful-0.0.8 bin/thoughtify