OSDN Git Service

temp
[pettanr/pettanr.git] / lib / manifest / manifest.rb
index 5facf00..b0eb591 100644 (file)
@@ -2,96 +2,71 @@
 module Pettanr
   class Manifest
     class Controller
-      attr :conf, :attributes, :associations
+      attr :item_name, :conf, :manifest, :model_name, :actions
       def initialize item_name, conf, manifest
         @item_name = item_name
         @conf = conf || {}
         @manifest = manifest
         @model_name = @conf['model_name']
+        @actions = @conf['actions'] || {}
       end
       
-      def actions
-        @model_manifest['actions'] || {}
+      def list_name action_name
+        a = @actions[action_name] || {}
+        l = a['list'] || {}
+        l['list_name']
       end
       
     end
     
     class Model
-      attr :item_name, :conf, :manifest, :attributes, :associations
+      attr :item_name, :conf, :manifest, :attributes, :associations, :belongs_to, :has_many, :has_one
       def initialize item_name, conf, manifest
         @item_name = item_name
         @conf = conf || {}
         @manifest = manifest
-      end
-      
-      def attributes
-        @model_manifest['attributes'] || {}
-      end
-      
-      def associations
-        @conf['name'] || {}
+        
+        @attributes = @conf['attributes']
+        @associations = @conf['associations'] || {}
+        @belongs_to = @associations['belongs_to'] || {}
+        @has_many = @associations['has_many'] || {}
+        @has_one = @associations['has_one'] || {}
       end
       
     end
     
     class List
-      attr :item_name, :conf, :manifest, :default_page_size
+      attr :item_name, :conf, :manifest, :default_page_size, :lists
       def initialize item_name, conf, manifest
         @item_name = item_name
         @conf = conf || {}
         @manifest = manifest
         @default_page_size = @conf['default_page_size'] || 20
+        @lists = @conf['lists'] || {}
       end
       
     end
     
-    class License
-      attr :conf
-      def initialize manifest
-        @manifest = manifest
-        @conf = @manifest['licenses'] || {}
-      end
-    end
-    
-    class Element
-      attr :conf
-      def initialize manifest
-        @manifest = manifest
-        @conf = @manifest['elements'] || {}
-      end
-    end
-    
-    class SpeechBalloonTemplate
-      attr :conf
-      def initialize manifest
-        @manifest = manifest
-        @conf = @manifest['speech_balloon_templates'] || {}
-      end
-    end
-    
-    class WritingFormat
-      attr :conf
-      def initialize manifest
-        @manifest = manifest
-        @conf = @manifest['writing_formats'] || {}
-      end
-    end
-    
-    class Profile
-      attr :conf
-      def initialize manifest
-        @manifest = manifest
-        @conf = @manifest['profile'] || {}
+    class SystemResources
+      attr :conf, :licenses, :elements, :speech_balloon_templates, :writing_formats
+      def initialize system_resource_conf
+        @conf = system_resource_conf || {}
+        @licenses = @conf['licenses'] || {}
+        @elements = @conf['elements'] || {}
+        @speech_balloon_templates = @conf['speech_balloon_templates'] || {}
+        @writing_formats = @conf['writing_formats'] || {}
       end
+      
     end
     
     class Profiler
-      attr :item_name, :conf, :manifest, :columns, :belongs_to, :has_many, :has_one
+      attr :item_name, :conf, :manifest, :columns, :lists, :belongs_to, :has_many, :has_one
       def initialize item_name, conf, manifest
         @item_name = item_name
         @conf = conf || {}
         @manifest = manifest
         @columns = @conf['columns'] || {}
+        @lists = @conf['lists'] || {}
         @associations_conf = @conf['associations'] || {}
         @belongs_to = @associations_conf['belongs_to'] || []
         @has_many = @associations_conf['has_many'] || []
@@ -126,48 +101,48 @@ module Pettanr
       
     end
     
-    attr :licenses, :elements, :speech_balloon_templates, :writing_formats, :profile,
-      :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers
+    attr :system_resources, :magic_numbers, :select_items,
+      :controller_managers, :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers
     def initialize manifest
       @manifest = manifest || {}
+      @system_resources = SystemResources.new(@manifest['system_resources'])
+      @magic_numbers = @manifest['magic_numbers']
+      @select_items = @manifest['select_items']
       @controllers = {}
       @models = {}
       @lists = {}
-      @licenses = License.new(manifest) 
-      @elements = Element.new(manifest)
-      @speech_balloon_templates = SpeechBalloonTemplate.new(manifest)
-      @writing_formats = WritingFormat.new(manifest)
-      @profile = Profile.new(manifest)
       @profilers = {}
       @filers = {}
       @forms = {}
+      @controller_managers = {}
       @model_managers = {}
       @list_managers = {}
       @profiler_managers = {}
       @filer_managers = {}
       @form_managers = {}
       (@manifest['controllers'] || {}).each {|item_name, controller_conf|
-        @controllers[item_name] = Controller.new(item_name, controller_conf, manifest) 
+        @controllers[item_name] = Controller.new(item_name, controller_conf, self) 
+        @controller_managers[item_name] = Pettanr::ControllerManager.new @controllers[item_name]
       }
       (@manifest['models'] || {}).each {|item_name, model_conf|
-        @models[item_name] = Model.new(item_name, model_conf, manifest
+        @models[item_name] = Model.new(item_name, model_conf, self
         @model_managers[item_name] = Pettanr::ModelManager.new @models[item_name]
       }
       (@manifest['lists'] || {}).each {|item_name, list_conf|
-        @lists[item_name] = List.new(item_name, list_conf, manifest
+        @lists[item_name] = List.new(item_name, list_conf, self
         @list_managers[item_name] = Pettanr::ListManager.new @lists[item_name]
       }
       @locals = @manifest['locals'] || {}
       (@locals['profilers'] || {}).each {|item_name, profiler_conf|
-        @profilers[item_name] = Profiler.new item_name, profiler_conf, manifest
+        @profilers[item_name] = Profiler.new item_name, profiler_conf, self
         @profiler_managers[item_name] = Pettanr::ProfilerManager.new @profilers[item_name]
       }
       (@locals['filers'] || {}).each {|item_name, filer_conf|
-        @filers[item_name] = Filer.new item_name, filer_conf, manifest
+        @filers[item_name] = Filer.new item_name, filer_conf, self
         @filer_managers[item_name] = Pettanr::FilerManager.new @filers[item_name]
       }
       (@locals['forms'] || {}).each {|item_name, form_conf|
-        @forms[item_name] = Form.new item_name, form_conf, manifest
+        @forms[item_name] = Form.new item_name, form_conf, self
         @form_managers[item_name] = Pettanr::FormManager.new @forms[item_name]
       }
     end