Class: Kitno::KillingInTheNamespaceOf
- Inherits:
-
Object
- Object
- Kitno::KillingInTheNamespaceOf
- Defined in:
- lib/kitno.rb
Constant Summary collapse
- CLASS_EXPRESSION =
/^class\s(?:@)?([A-Z][\w\.]*)/- REQUIRE_TEMPLATE =
"%{short_name} = require('%{path}')"
Instance Method Summary collapse
- #enumerate ⇒ Object
-
#initialize(options = {}) ⇒ KillingInTheNamespaceOf
constructor
A new instance of KillingInTheNamespaceOf.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ KillingInTheNamespaceOf
Returns a new instance of KillingInTheNamespaceOf.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kitno.rb', line 12 def initialize( = {}) @namespace, @directory, @output, globals, externals = .values_at( :namespace, :directory, :output, :globals, :externals ) @class_map = {} @files = [] @globals = parse_mappings(globals) if globals && globals.length > 0 @externals = parse_mappings(externals) if externals && externals.length > 0 @dependency_expression = /^(?!(\s\*|#)).*(?:new|extends)\s(#{Regexp.escape(@namespace)}[\w\.]*)/ end |
Instance Method Details
#enumerate ⇒ Object
47 48 49 50 51 |
# File 'lib/kitno.rb', line 47 def enumerate enumerate_files @class_map end |
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kitno.rb', line 30 def run enumerate_files @class_map.each_value do |descriptor| path, output_path = descriptor[:path] require_dependencies!(path, descriptor[:dependencies]) if @output output_path = Pathname.new(path).sub(@directory, @output) FileUtils.mkdir_p output_path.dirname.to_s end FileUtils.mv "#{path}.module", output_path.to_s end end |