[katello-devel] T²-Pain generator

Petr Chalupa pchalupa at redhat.com
Thu Nov 15 17:33:25 UTC 2012


Now I am getting feeling that I am not getting it. What are you trying 
to accomplish with the generator? What will be the output of the generator?

Petr

On 15.11.12 18:20, David Davis wrote:
> So I think I understand your message. Luckily I think most of what you're talking about can be done inside the Rails generators using Thor or by creating separate classes that are used in the generator (as like template helpers or something). I'll try to incorporate that into my design.
>
> David
>
> ----- Original Message -----
>> From: "Petr Chalupa" <pchalupa at redhat.com>
>> To: "David Davis" <daviddavis at redhat.com>
>> Cc: katello-devel at redhat.com
>> Sent: Thursday, November 15, 2012 12:07:45 PM
>> Subject: Re: [katello-devel] T²-Pain  generator
>>
>> Sorry I was too vague. I meant to create a helper class (TwoPane)
>> where
>> its instance would directly render the TwoPane html code not the Ruby
>> code. I would use a class because this too complex to be done just
>> with
>> simple helper methods.
>>
>> I do not really know how to describe it so I try an example:
>>
>> module TwoPaneHelper
>>
>>     def twopane(options, &block)
>>       TwoPane.new(self, options, &block).render
>>     end
>>
>>     class TwoPane
>>       attr_reader :template, :options
>>       def initialize(template, options = { }, &block)
>>         @template, @options = template, options
>>         # eval block whit dsl for complex options
>>         instance_eval &block
>>       end
>>
>>       # dsl example method
>>       def ajax(options = { })
>>         self.options[:ajax_load]   = options[:load] || 'a default'
>>         self.options[:ajax_scroll] = options[:scroll] || 'a default'
>>       end
>>
>>       def left_side(options)
>>         # ...
>>       end
>>
>>       def render
>>         # stuff like
>>         template.content_tag :div
>>         template.render :partial => 'some template', :locals =>
>>         options
>>       end
>>     end
>>
>> end
>>
>> # usage in template
>> include TwoPaneHelper
>> twopane(:title => 'A Title') do
>>     ajax :load => 'whatever', :scroll => 'whatever'
>>     left_side do
>>       # some more configuration
>>     end
>> end
>>
>>
>> In case of two-pane I guess there would be a few classes (left, right
>> side etc.) which could be overridden and interchanged if needed.
>>
>> If I failed to make it more understandable please ask.
>>
>> Petr
>>
>> On 15.11.12 14:32, David Davis wrote:
>>> Do you have an example? I'm not sure I've ever seen Ruby source
>>> code generated with Ruby objects and meta-programming.
>>>
>>> One reason I prefer to use Rails generators is that I could tie
>>> into existing generators. Using Rails generators, I could reuse
>>> the existing generators for routes, models, migrations, etc. I
>>> could that with Ruby objects or some meta-programming but it
>>> wouldn't be as easy as calling hook_for or invoke from a new Rails
>>> generator.
>>>
>>> David
>>>
>>> ----- Original Message -----
>>>> From: "Petr Chalupa" <pchalupa at redhat.com>
>>>> To: katello-devel at redhat.com
>>>> Sent: Thursday, November 15, 2012 8:17:36 AM
>>>> Subject: Re: [katello-devel] T²-Pain  generator
>>>>
>>>> Hi,
>>>>
>>>> I this case I would suggest not to use Rails generator. I would
>>>> use
>>>> pure
>>>> Ruby objects and some meta-programing.
>>>>
>>>> My Reason: Once code for tupane is generated and specific changes
>>>> are
>>>> introduces into the generated code it is hard to keep the code
>>>> up-to-date with generator as the generator is being updated and
>>>> improved. Also erb files for generating Ruby tend to look horrible
>>>> and
>>>> unintelligible.
>>>>
>>>> Petr
>>>>
>>>> On 14.11.12 14:47, David Davis wrote:
>>>>> Not sure if I understand your question but the rails generator
>>>>> will
>>>>> generate a bunch of code for your when you call it. I haven't
>>>>> looked at the tupane code a lot yet but if there is a lot of
>>>>> javascript, we might be able to generate it. Basically, we'd be
>>>>> building on top of the "rails generate scaffold" command to
>>>>> generate a tupane layout instead of the typical Rails
>>>>> index/create/edit/show views.
>>>>>
>>>>> Here's more information:
>>>>>
>>>>> https://fedorahosted.org/katello/wiki/RailsGeneratorDesign
>>>>>
>>>>> David
>>>>>
>>>>> ----- Original Message -----
>>>>>> From: "Lukas Zapletal" <lzap at redhat.com>
>>>>>> To: katello-devel at redhat.com
>>>>>> Sent: Wednesday, November 14, 2012 8:40:41 AM
>>>>>> Subject: Re: [katello-devel] T²-Pain  generator
>>>>>>
>>>>>> Does that Rails Generator thing bring less JavaScript and more
>>>>>> Ruby?
>>>>>>
>>>>>> I mean, writing more code in Ruby and having most of the
>>>>>> JavaScript
>>>>>> stuff generated?
>>>>>>
>>>>>> Or is it something different?
>>>>>>
>>>>>> LZ
>>>>>>
>>>>>> On Wed, Nov 14, 2012 at 08:18:01AM -0500, David Davis wrote:
>>>>>>> So I'm working on some Rails generators and one of them is a
>>>>>>> T²-Pain generator. Originally we wanted to call it 2pane but I
>>>>>>> have found out that it won't work as module/class names in Ruby
>>>>>>> can't start with a number and you have to a module/class for
>>>>>>> the
>>>>>>> generator. Thus, I'm wondering which version of tUpay'n I
>>>>>>> should
>>>>>>> use.
>>>>>>>
>>>>>>> - tupane
>>>>>>> - twopane
>>>>>>> - two_pane
>>>>>>>
>>>>>>> My concern with the first one is that it's not self evident
>>>>>>> what
>>>>>>> it's referring to. Also, are there any other names that might
>>>>>>> work
>>>>>>> other than tu/two/2pane?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> katello-devel mailing list
>>>>>>> katello-devel at redhat.com
>>>>>>> https://www.redhat.com/mailman/listinfo/katello-devel
>>>>>>
>>>>>> --
>>>>>> Later,
>>>>>>
>>>>>>     Lukas "lzap" Zapletal
>>>>>>     #katello #systemengine
>>>>>>
>>>>>> _______________________________________________
>>>>>> katello-devel mailing list
>>>>>> katello-devel at redhat.com
>>>>>> https://www.redhat.com/mailman/listinfo/katello-devel
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> katello-devel mailing list
>>>>> katello-devel at redhat.com
>>>>> https://www.redhat.com/mailman/listinfo/katello-devel
>>>>>
>>>>
>>>> _______________________________________________
>>>> katello-devel mailing list
>>>> katello-devel at redhat.com
>>>> https://www.redhat.com/mailman/listinfo/katello-devel
>>




More information about the katello-devel mailing list