Class: Capricorn::Util::Internal

Inherits:
Capricorn::Util show all
Defined in:
lib/capricorn-util/internal.rb

Instance Method Summary collapse

Methods inherited from Capricorn::Util

banner, #help, #method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Capricorn::Util

Instance Method Details

#inspectorObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/capricorn-util/internal.rb', line 24

def inspector
  Erlang do |path|

    unless File.extname(path) == ".gem" and File.file?(path)
      error :not_found
    end

    begin
      format = Gem::Format.from_file_by_path(path)
    rescue Exception => e
      error :gem_error, e.message
    end

    spec = format.spec
    unless spec
      error :gem_error, "Invalid gem"
    end

    dependencies = spec.runtime_dependencies.collect do |dep|
      version_requirements = dep.version_requirements.as_list.collect do |req|
        op, version = *req.split(/\s+/, 2)
        BERT::Tuple[op, version]
      end
      BERT::Tuple[dep.name, version_requirements]
    end

    send BERT::Tuple[spec.name, spec.version.to_s, dependencies]

  end
end

#scaffolderObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/capricorn-util/internal.rb', line 8

def scaffolder
  Erlang do |cmd|
    case cmd.shift
    when :create
      recipe = cmd.shift
      app = convert_app(cmd.first)

      recipe_path = File.expand_path("../../lib/capricorn/recipes/#{recipe}.rb", __FILE__)
      ctx = Capricorn::SystemContext.run(recipe_path, :application => app)

      send t[true, t[ctx.www_user, ctx.www_group, ctx.root_path]]
    end
  end
end