Revision 912:5e80956cc792 lib/redmine/views/builders

View differences:

lib/redmine/views/builders/json.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2010  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
lib/redmine/views/builders/structure.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2010  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
24 24
        def initialize
25 25
          @struct = [{}]
26 26
        end
27
        
27

  
28 28
        def array(tag, options={}, &block)
29 29
          @struct << []
30 30
          block.call(self)
......
32 32
          @struct.last[tag] = ret
33 33
          @struct.last.merge!(options) if options
34 34
        end
35
        
35

  
36 36
        def method_missing(sym, *args, &block)
37 37
          if args.any?
38 38
            if args.first.is_a?(Hash)
......
49 49
              end
50 50
            end
51 51
          end
52
          
52

  
53 53
          if block
54 54
            @struct << (args.first.is_a?(Hash) ? args.first : {})
55 55
            block.call(self)
......
65 65
            end
66 66
          end
67 67
        end
68
        
68

  
69 69
        def output
70 70
          raise "Need to implement #{self.class.name}#output"
71 71
        end
lib/redmine/views/builders/xml.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2010  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
23 23
          super
24 24
          instruct!
25 25
        end
26
        
26

  
27 27
        def output
28 28
          target!
29 29
        end
30
        
30

  
31 31
        def method_missing(sym, *args, &block)
32 32
          if args.size == 1 && args.first.is_a?(Time)
33 33
            __send__ sym, args.first.xmlschema, &block
......
35 35
            super
36 36
          end
37 37
        end
38
        
38

  
39 39
        def array(name, options={}, &block)
40 40
          __send__ name, (options || {}).merge(:type => 'array'), &block
41 41
        end

Also available in: Unified diff