I'd like to be able to give my wars a dynamic name (which includes the svn branch, svn revision, date stamp, etc.). warble.rb: https://gist.github.com/3183573 warble.rake: https://gist.github.com/3183570 This works, but the war naming routine runs once for every prerequisite rake task (assets:clean, assets:precompile, etc.). It's a relatively expensive routine, so I'd like to get it to run only once. Also, I'm new to Rake (and Ruby), so my code is probably pretty ugly, and I'll gladly take suggestions. Thanks, Jamie
on 2012-07-26 20:46
on 2012-07-27 03:58
I think it's just because the instance variable in which you're trying
to cache the name lives in an object that is not long-lived. Perhaps
try moving the code into a module as class methods like this, so the
instance variable lives in the module object which is not going to be
refreshed.
```ruby
module Warbler
def self.create_war_name
...
end
def self.svn_war_name
@war_name ||= create_war_name
end
end
Warbler::Config.new do |config|
config.jar_name = Warbler.svn_war_name
...
end
Regards,
/Nick
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.