Scenarios [work in progress]

- [x] Add the concept of Scenarios (Agent Groups)
- [x] Allow Scenarios to be exported as JSON dumps
- [x] Allow Scenarios to be imported
- [x] Repeated import of the same Scenario should offer to update the existing one
- [ ] Show visual diff when the existing Scenario has been edited
Yup!

I'm working on adding a smart diff now, so if you reimport a scenario after
having edited it, it shows you the changes.

On Saturday, June 7, 2014, Dominik Sander <notifications@github.com> wrote:

> In app/models/scenario_import.rb:
>
> > +  def parsed_data
> > +    @parsed_data ||= data && JSON.parse(data) rescue {}
> > +  end
> > +
> > +  def do_import?
> > +    do_import == "1"
> > +  end
> > +
> > +  def import!(options = {})
> > +    guid = parsed_data['guid']
> > +    description = parsed_data['description']
> > +    name = parsed_data['name']
> > +    agents = parsed_data['agents']
> > +    links = parsed_data['links']
> > +    source_url = parsed_data['source_url'].presence || nil
> > +    @scenario = user.scenarios.where(:guid => guid).first_or_initialize
>
> Neat! Did not know first_or_initialize existed, much nicer syntax then
> using find_or_initialize_by
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/cantino/huginn/pull/325/files#r13521776>.
>