Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy or delete method #8

Open
marksiemers opened this issue Nov 12, 2017 · 7 comments
Open

Destroy or delete method #8

marksiemers opened this issue Nov 12, 2017 · 7 comments

Comments

@marksiemers
Copy link

Would it be possible to provide a destroy or delete method that is the opposite of render in that it will remove any files that would have been created by render?

@aaronstillwell
Copy link

I'd be happy to take this on and file a PR in the near future. (I've come here from amberframework/amber#188 as above).

I've reviewed some of the source and I've skimmed over the original issue for appending to files (#2). Is it logical to assume that using a - prefix might be suitable for marking a file for destruction?

Happy to hear some feedback on this before filing a PR @mosop

@marksiemers
Copy link
Author

@aaronstillwell - Thanks for offering to take this one.

As far as having a - indicate that a file would be deleted. That wouldn't match my use-case.

What I was looking for is something that takes the exact same logic to decide what files are rendered.

It could be the same structure as this method:

def render
  begin
    @entries.each do |entry|
      if @per_entry
        entry.render
      else
        entry.confirm
      end
    end
    @entries.each(&.render) unless @per_entry
  rescue ex : Quit
    @quitted = true
  end
end

Just, instead of entry.render, it would be entry.delete and instead of entry.confirm, entry.confirm.delete

If the minus (-) designation were to be used, I would expect it to remove lines from the file that match.

@aaronstillwell
Copy link

Woops, gotcha @marksiemers, you're absolutely right the - makes no sense. Happy to take this on using the approach you've described though 👌

@marksiemers
Copy link
Author

@aaronstillwell - Do you think you'll have time to work through this in the next week or so?

The amber team is updating some milestones and we're looking where to bucket a change that depends on this functionality.

If you're PR doesn't get approved here, we may do a fork into the amberframework org, and we could incorporate it there.

@aaronstillwell
Copy link

@marksiemers yes I plan to have it done this weekend. I'll happily move the resulting PR to the fork if it comes to that.

@marksiemers
Copy link
Author

@aaronstillwell - I screwed up the forking on this, but it should still be fine: https://github.com/amberframework/teeplate

You can open a PR there.

@mosop
Copy link
Owner

mosop commented Jun 7, 2018

Hi. This feature is interesting.

I was thinking if each file entry had an action type, such as create, append... etc., the software design would be more sophisticated.

Unfortunately, I hardly have enough time, but I want to try that.

AndiLavera added a commit to AndiLavera/teeplate that referenced this issue Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants