class Picatrix::Buffy

Constants

COL_ACTIONS
CRUFD
ITEM_ACTIONS

must be disjoint due to nature of protobuf

Attributes

app_name[RW]
representation_klasses[RW]
resources[RW]

Public Class Methods

new(pacman, options = {}, app_name = "app") click to toggle source
# File lib/picatrix/buffy.rb, line 17
def initialize(pacman, options = {}, app_name = "app")
  # thor related
  @options = options
  @destination_stack = [self.class.source_root]
  @app_name = app_name

  @representation_klasses = pacman.nodes.keys.map(&:camelize)

  @item_representations = @representation_klasses.map(&:singularize).uniq
  @col_representations = @representation_klasses.map(&:pluralize).uniq
  @resources = @item_representations + @col_representations

  @link_relations = pacman.edges.collect do |edge|
    target = edge[edge.keys.first][:target]
    link_relation = edge[edge.keys.first][:link_relation]
    if link_relation[0] != ':' && !CRUFD.map(&:downcase).include?(link_relation)
      "#{link_relation.camelize}" + "#{target.camelize}"
    end
  end.compact.uniq
end

Public Instance Methods

slay() click to toggle source
# File lib/picatrix/buffy.rb, line 38
def slay
  # TODO need to make prefix setter
  @prefix = app_name[0]
  @host = "http://localhost:9292/"

  template(
    'templates/namespaces.json',
    File.join("../../generated/#{app_name}/support/namespaces.json")
  )

  template(
    'templates/app.proto',
    File.join("../../generated/#{app_name}/support/#{app_name}.proto")
  )
end