class Picatrix::Jenny
Attributes
app_name[RW]
destination_stack[RW]
options[RW]
rels[RW]
root_path[RW]
routes[RW]
Public Class Methods
new(pacman, options = {}, app_name = "app")
click to toggle source
# File lib/picatrix/jenny.rb, line 15 def initialize(pacman, options = {}, app_name = "app") # thor related @options = options @destination_stack = [self.class.source_root] @nodes = pacman.nodes @edges = pacman.edges @app_name = app_name @rels = LinkRelationIndex.new(@edges).masoned # TODO @meta = {} if File.exist?( namespaces_path = "generated/#{app_name}/support/namespaces.json" ) #TODO this should be coming in from graph instead @namespaces = JSON.parse( File.read( namespaces_path ) ) @prefix = "#{@namespaces["@namespaces"].keys.first}:" else puts "no generated/#{app_name}/support/namespaces.json file" @namespaces = {} @prefix = "" end end
Public Instance Methods
generate_sinatra_of(app_name)
click to toggle source
# File lib/picatrix/jenny.rb, line 75 def generate_sinatra_of(app_name) template( 'templates/app.rb', File.join("../../generated/#{app_name}/#{app_name}.rb") ) end
just_do_it()
click to toggle source
# File lib/picatrix/jenny.rb, line 44 def just_do_it setup_framework_for(app_name) generate_sinatra_of(app_name) end
setup_framework_for(app_name)
click to toggle source
# File lib/picatrix/jenny.rb, line 49 def setup_framework_for(app_name) template( 'templates/mason.rb', File.join("../../generated/#{app_name}/support/mason.rb") ) Protoc.to_ruby(app_name) begin jenny_path = File.dirname( __FILE__ ) $:.unshift File.expand_path( File.join( jenny_path, "..", "..", "generated" ) ) $:.unshift File.expand_path( File.join( jenny_path, "..", "..", "generated", "#{app_name}" ) ) $:.unshift File.expand_path( File.join( jenny_path, "..", "..", "generated", "#{app_name}", "support" ) ) require_all("./generated/#{app_name}/**/*.rb") rescue LoadError => e puts "#{e}" end @control_templates = Cruddy.new(@edges).controls @resources = Prototyper.new(@nodes, {}, app_name).resources @routes = Routes.new(@edges, @control_templates) # make this available to the app scope @root_path = @routes.root_path end
Private Instance Methods
send_method_for(method)
click to toggle source
# File lib/picatrix/jenny.rb, line 83 def send_method_for(method) { post: :create, patch: :find, get: :find, delete: :find }[method] end