Class: Picatrix::Jenny
- Inherits:
-
Object
- Object
- Picatrix::Jenny
- Includes:
- Thor::Actions, Thor::Base
- Defined in:
- lib/picatrix/jenny.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#destination_stack ⇒ Object
Returns the value of attribute destination_stack.
-
#options ⇒ Object
Returns the value of attribute options.
-
#rels ⇒ Object
Returns the value of attribute rels.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
-
#routes ⇒ Object
Returns the value of attribute routes.
Instance Method Summary collapse
- #generate_sinatra_of(app_name) ⇒ Object
-
#initialize(pacman, options = {}, app_name = "app") ⇒ Jenny
constructor
A new instance of Jenny.
- #just_do_it ⇒ Object
- #setup_framework_for(app_name) ⇒ Object
Constructor Details
#initialize(pacman, options = {}, app_name = "app") ⇒ Jenny
Returns a new instance of Jenny.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/picatrix/jenny.rb', line 15 def initialize(pacman, = {}, app_name = "app") # thor related @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 |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
9 10 11 |
# File 'lib/picatrix/jenny.rb', line 9 def app_name @app_name end |
#destination_stack ⇒ Object
Returns the value of attribute destination_stack.
9 10 11 |
# File 'lib/picatrix/jenny.rb', line 9 def destination_stack @destination_stack end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/picatrix/jenny.rb', line 9 def @options end |
#rels ⇒ Object
Returns the value of attribute rels.
9 10 11 |
# File 'lib/picatrix/jenny.rb', line 9 def rels @rels end |
#root_path ⇒ Object
Returns the value of attribute root_path.
9 10 11 |
# File 'lib/picatrix/jenny.rb', line 9 def root_path @root_path end |
#routes ⇒ Object
Returns the value of attribute routes.
9 10 11 |
# File 'lib/picatrix/jenny.rb', line 9 def routes @routes end |
Instance Method Details
#generate_sinatra_of(app_name) ⇒ Object
75 76 77 78 79 80 |
# 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 ⇒ Object
44 45 46 47 |
# 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) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 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.( File.join( jenny_path, "..", "..", "generated" ) ) $:.unshift File.( File.join( jenny_path, "..", "..", "generated", "#{app_name}" ) ) $:.unshift File.( 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 |