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

Thor::Runner needs to be improved #29

Closed
kristianmandrup opened this issue Mar 9, 2010 · 5 comments
Closed

Thor::Runner needs to be improved #29

kristianmandrup opened this issue Mar 9, 2010 · 5 comments

Comments

@kristianmandrup
Copy link

I created a thor task to generate a new thor task project and one to create a skeleton ruby project.
In both cases I have a templates dir with the template files for the template statement.
They both run fine locally, but when I install the gem, only the thor file itself seems to be installed, not its templates dir. This seems a reasonable default, but how do I then force thor to deploy other files/dirs as part of the thor task?
I think I might instead have to build a generator gem with binaries? Seems like thor is only suitable in the simplest cases?

@kristianmandrup
Copy link
Author

I made a workaround which is actually pretty decent.

def self.source_root
template_path = ENV['THOR_TEMPLATE_PATH'] ? File.join(ENV['THOR_TEMPLATE_PATH'], 'new-thor-task') : File.dirname(FILE)
File.join(template_path, 'templates')
end

.bash_profile

export TEMPLATE_PATH=~/Development/Languages/Ruby/Templates
export THOR_TEMPLATE_PATH=$TEMPLATE_PATH/thor

Then I just create a new directory for each thor task under THOR_TEMPLATE_PATH and then copy the templates dir into this dir, fx

THOR_TEMPLATE_PATH/my_thor_task/templates

I will now try to fork thor and patch it with this or a similar solution.

@kristianmandrup
Copy link
Author

The Thor repository root is at ~/.thor (thor_root). Any directories inside thor_root are treated as task packages with a main.thor expected.

~/.thor/thor.yaml has pointers to your local thor projects, so they are not "truly" installed. There is a package option, but I'm not sure how to use it.

I have now added an option to deploy a task. This will create a task package, with the task code in a separate dir with a main.thor file. To do this run

$ thor install lib/mythor.thor

This latest version expects the thor file and supporting ruby code to all reside in a lib folder and any templates in a templates folder

/my_task
  + lib
    - mythor.thor
  + templates   

Enjoy!

@josevalim
Copy link
Contributor

Yes, I hear your pain. We need to improve the thor install urgently. In my Thor refactor, I haven't touched the Thor::Runner bit and it's a little bit falling behind the other features.

I've seen you've done a lot of work in your fork, but it's kinda of mixed. You are improving several parts and adding new features, so it makes hard to review.

Sorry, I should have reviewed it earlier but I'm quite busy lately. Are you interested in starting a new branch and port your Thor::Runner refactor? We can discuss the new features as we go.

If you don't have my private e-mail, please send me a message and I will reply! Thanks!

@kristianmandrup
Copy link
Author

Yeah, let us start a new branch. What should we call it? 'runner-upgrade' ?

@rafaelfranca
Copy link
Member

Closing since this is too old. If you still have the problem please let us know.

@rafaelfranca rafaelfranca closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
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

No branches or pull requests

3 participants