lib/nutrella/command.rb in nutrella-1.4.0 vs lib/nutrella/command.rb in nutrella-1.5.0
- old
+ new
@@ -12,26 +12,38 @@
@cache_filename = File.join(configuration_directory, ".nutrella.cache.yml")
@configuration_filename = File.join(configuration_directory, ".nutrella.yml")
end
def run
- open board_url # rubocop:disable Security/Open
+ launch(board_url)
end
private
+ def launch(url)
+ launch_command = configuration_values.fetch(:launch_command).gsub("$url$", url)
+
+ system(launch_command)
+ end
+
def board_url
- url_cache.fetch(@board_name) { task_board.lookup_or_create(@board_name).url }
+ enable_trello_app? ? trello_url(cached_url) : cached_url
end
+ def cached_url
+ @_cached_url ||= url_cache.fetch(@board_name) { task_board.lookup_or_create(@board_name).url }
+ end
+
def configuration_values
- @configuration_values ||= Nutrella::Configuration.values(configuration_filename)
+ @_configuration_values ||= Nutrella::Configuration.values(configuration_filename)
end
- def open(url)
- launch_command = configuration_values.fetch(:launch_command).gsub("$url$", url)
+ def enable_trello_app?
+ configuration_values.fetch(:enable_trello_app)
+ end
- system(launch_command)
+ def trello_url(http_url)
+ http_url.gsub(/^http.?:/, "trello:")
end
def task_board
Nutrella::TaskBoard.new(configuration_values)
end