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

Fixed #52 - Incorrect behavior when generate module which already exists #59

Merged
merged 7 commits into from
Dec 29, 2015
Merged

Fixed #52 - Incorrect behavior when generate module which already exists #59

merged 7 commits into from
Dec 29, 2015

Conversation

Beniamiiin
Copy link
Contributor

No description provided.

@@ -5,88 +6,85 @@
module Generamba

# Responsible for creating the whole code module using information from the CLI
class ModuleGenerator
class ModuleGenerator < Thor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you subclassing this class from Thor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don't subclassing from Thor, I don't use yes? method, from Thor module. Correct me if I am wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed two lines with the yes method.

I don't like the idea of using Thor and its functions on the business logic layer (and ModuleGenerator) definitely belongs to this layer. We shouldn't mess presentation and business logic in one class.

I see two possible solutions:

  • You can perform this check somewhere in the gen_command.rb (maybe by using some helper class)
  • You can post a warning, that these files are not empty, and stop the module generation process. To force overwrite, you can add some flag to generamba gen command, like generamba gen MyModule MyTemplate --force.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, perform this check in gen_command.rb right idea. And I noticed, that I don't sold this check, but only sold yes answer :( Then, I'll implementing this method in xcodeproj_helper.rb and move this check in gen_command.rb.

@etolstoy
Copy link
Member

@Beniamiiin thanks for contributing, a really nice implementation! I have a couple of questions - you can see them in code review.

Maybe you want to implement also another part of the issue?
1) No any warnings about deletion my files (it possible I already have some code here)

@Beniamiiin
Copy link
Contributor Author

Yes, I am implementing this too.

project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
module_group_already_exists = XcodeprojHelper.module_with_group_path_already_exists(project, code_module.module_group_path)

if (module_group_already_exists == true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, ruby style guidelines require not using brackets for if cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use brackets only this module, because in this module already used brackets.

@etolstoy
Copy link
Member

@Beniamiiin just a couple of minor fixes - and we can merge it! I thought of releasing a new version today - but I'll be unavailable for the following 10 days, so I won't be able to make a hotfix if something goes wrong.

I think we can schedule a new version something near the 15th of January.

@etolstoy
Copy link
Member

Thanks once again!

etolstoy added a commit that referenced this pull request Dec 29, 2015
Fixed #52 - Incorrect behavior when generate module which already exists
@etolstoy etolstoy merged commit a725e44 into strongself:develop Dec 29, 2015
@Beniamiiin Beniamiiin deleted the feature/fixIssue52 branch January 7, 2016 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants