OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / lib / locmare / profiler.rb
1 require_dependency "locmare/profiler/header"
2 require_dependency "locmare/profiler/column"
3 require_dependency "locmare/profiler/association"
4 module Locmare
5   class Profiler
6     include ProfilerModule
7     attr :profiler_manifest, :item_name, :item, :operators, :template_dir, 
8       :header, :columns, :associations
9     def initialize item_name, item, operators
10       @item_name = item_name
11       @item = item
12       @operators = operators
13       # feasible show parsed extend data
14       @item.boosts 'post'
15       
16       @profiler_manifest = LocalManifest.manifest.profilers[@item_name]
17       @template_dir = 'templates/r/profiler/'
18       @header = Header.new self
19       @columns = {}
20       @profiler_manifest.columns.each {|name, column|
21         @columns[name] = Column.factory self, column
22       }
23       @associations = Association.new self, @profiler_manifest.associations
24     end
25     
26     def each_column
27       @profiler_manifest.column_names.each {|column_name|
28         yield @columns[column_name]
29       }
30     end
31     
32     def peta
33       Manifest.manifest.items[@item_name]
34     end
35     
36     def model
37       ::Manifest::item_name_to_model @item_name
38     end
39     
40     def template_file_name
41       "profiler"
42     end
43     
44     def template_name
45       self.template_dir + self.template_file_name
46     end
47     
48     def header_template_file_name
49       "header"
50     end
51     
52     def header_template_name
53       self.template_dir + self.header_template_file_name
54     end
55     
56     def columns_template_file_name
57       "columns"
58     end
59     
60     def columns_template_name
61       self.template_dir + self.columns_template_file_name
62     end
63     
64     def associations_template_file_name
65       "associations"
66     end
67     
68     def associations_template_name
69       self.template_dir + self.associations_template_file_name
70     end
71     
72     def image_dir
73       '/images/'
74     end
75     
76   end
77 end
78