fixed manifest
[augment.git] / lib / augment.rb
blob3199080c9af3a08989397a4941a407ad7a7b523f
1 $LOAD_PATH << File.dirname(__FILE__)
2 $LOAD_PATH << File.dirname(__FILE__) + '/backends'
3 $LOAD_PATH << File.dirname(__FILE__) + '/frontends'
5 require 'rubygems'
7 require 'layer'
8 require 'flet'
9 require 'backend'
10 require 'frontend'
12 class Augment
13   VERSION = '1.0.0'
14   BACKENDS = {}
15   FRONTENDS = {}
16   
17   def initialize(action, file)
18     raise "No backend or frontend with that name." if action.nil?
19     action.run(file)
20   end
22   class << self
23     def interactive(backend_names = 'test')
24       loop do
25         begin
26           filename = STDIN.gets.chomp
27           backend_names.each { |backend| BACKENDS[backend].run(filename) }
28           puts "{\"#{filename}\" : #{File.read(augment_path(filename))} }"
29         rescue
30           puts "Error augmenting #{filename}."
31         end
32       end
33     end
34     
35     def augment_path(original)
36       "#{File.dirname(File.expand_path(original))}/.augment/#{File.basename(original)}"
37     end
38   end
39 end
41 Dir.glob(File.dirname(__FILE__) + '/*ends/*rb').each { |b| require b[0 .. -4] }