|
2 | 2 | require 'fileutils'
|
3 | 3 | require 'pathname_redmine_version'
|
4 | 4 |
|
| 5 | +# Identifies correct version of issues/VERSION.show.html.erb and |
| 6 | +# copies it to issues/show.html.erb |
5 | 7 | class SetupIssueShow
|
6 | 8 | attr_accessor :issues_directory
|
7 | 9 | attr_accessor :current_version
|
8 | 10 |
|
9 | 11 | def initialize
|
10 |
| - @issues_directory = Pathname.new( Redmine::Plugin.registered_plugins[:redmine_spent_time_in_issue_description].directory ).join("app","views","issues") |
11 |
| - @current_version = [ Redmine::VERSION::MAJOR, Redmine::VERSION::MINOR, Redmine::VERSION::TINY ].join('.') |
| 12 | + plugin_directory = Redmine::Plugin.registered_plugins[:redmine_spent_time_in_issue_description].directory |
| 13 | + @issues_directory = Pathname.new(plugin_directory).join('app', 'views', 'issues') |
| 14 | + @current_version = [Redmine::VERSION::MAJOR, Redmine::VERSION::MINOR, Redmine::VERSION::TINY].join('.') |
12 | 15 | end
|
13 | 16 |
|
14 | 17 | def show_file
|
15 |
| - possible_files = @issues_directory.children(false).select{ |files| files.to_s.index(/\d.*show/) } |
16 |
| - file = possible_files.sort{|x,y| y <=> x }.find do |file| |
| 18 | + possible_files = @issues_directory.children(false).select { |files| files.to_s.index(/\d.*show/) } |
| 19 | + show_file = possible_files.sort { |x, y| y <=> x }.find do |file| |
17 | 20 | version = file.to_s[0..4]
|
18 | 21 | version == @current_version || version < @current_version
|
19 | 22 | end
|
20 | 23 |
|
21 |
| - show_file = @issues_directory.join file unless file.nil? |
22 |
| - |
| 24 | + @issues_directory.join show_file unless show_file.nil? |
23 | 25 | end
|
24 | 26 |
|
25 | 27 | def replace
|
26 | 28 | FileUtils.copy_file show_file.to_s, @issues_directory.join('show.html.erb').to_s
|
27 | 29 | end
|
28 |
| - |
29 | 30 | end
|
0 commit comments