ops_routes 0.4.0 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.4
@@ -1,5 +1,6 @@
1
1
  class OpsController < ApplicationController
2
-
2
+ unloadable
3
+
3
4
  def version
4
5
  render :text => OpsRoutes.check_version(request.headers)
5
6
  end
data/lib/ops_routes.rb CHANGED
@@ -51,6 +51,26 @@ module OpsRoutes
51
51
  end
52
52
  end
53
53
 
54
+ def previous_versions
55
+ return @previous_versions if @previous_versions
56
+ @previous_versions = []
57
+ dirs = Dir.pwd.split('/')
58
+ if dirs.last =~ /^\d+$/
59
+ Dir["../*"].each do |dir|
60
+ next if dir =~ /#{dirs.last}$/
61
+ version = File.join(dir, 'VERSION')
62
+ revision = File.join(dir, 'REVISION')
63
+ if File.exists?(version) && File.exists?(revision)
64
+ @previous_versions << { :version => File.read(version).chomp.gsub('^{}', ''),
65
+ :revision => File.read(revision).chomp,
66
+ :time => File.stat(revision).mtime }
67
+ end
68
+ end
69
+ @previous_versions.sort!{ |a, b| a[:time] <=> b[:time] }
70
+ end
71
+ @previous_versions
72
+ end
73
+
54
74
  def version_file
55
75
  @version_file ||= File.join(file_root, 'VERSION')
56
76
  end
@@ -102,12 +122,12 @@ module OpsRoutes
102
122
  @headers.select{|k,v| k.match(/^[-A-Z_].*$/) }
103
123
  end
104
124
 
105
- def version_link
106
- "https://github.com/primedia/#{app_name}/tree/#{version_or_branch}" unless version_or_branch =~ /^Unknown/
125
+ def version_link(version)
126
+ "https://github.com/primedia/#{app_name}/tree/#{version}" unless version_or_branch =~ /^Unknown/
107
127
  end
108
128
 
109
- def last_commit_link
110
- "https://github.com/primedia/#{app_name}/commit/#{last_commit}" unless version_or_branch =~ /^Unknown/
129
+ def commit_link(commit)
130
+ "https://github.com/primedia/#{app_name}/commit/#{commit}" unless commit =~ /^Unknown/
111
131
  end
112
132
 
113
133
  end
@@ -6,6 +6,10 @@
6
6
  .label {float: left; width: 400px; font-weight: bold}
7
7
  .spacer {clear: both; padding: 10px;}
8
8
  .value {float: left; width: 500px; text-align: right;}
9
+ td {padding: 0 5px}
10
+ #previous_versions .value {clear: both; width: 1000px; text-align: left;}
11
+ #previous_versions tr.header td {font-weight: bold}
12
+ #previous_versions .value tr.even {background: #dddddd;}
9
13
  #headers .value {clear: both; width: 1000px; text-align: left;}
10
14
  #headers .value tr.even {background: #dddddd;}
11
15
  .clear {clear: both;}
@@ -15,7 +19,7 @@
15
19
  #version
16
20
  .label= "#{app_name} Version"
17
21
  .value
18
- %a{:href => version_link}= version_or_branch
22
+ %a{:href => version_link(version_or_branch)}= version_or_branch
19
23
  .spacer
20
24
  #date
21
25
  .label Date Deployed
@@ -24,7 +28,7 @@
24
28
  #commit
25
29
  .label Last Commit
26
30
  .value
27
- %a{:href => last_commit_link}= last_commit
31
+ %a{:href => commit_link(last_commit)}= last_commit
28
32
  .spacer
29
33
  #host
30
34
  .label Host
@@ -34,6 +38,23 @@
34
38
  .label Environment
35
39
  .value= environment
36
40
  .spacer
41
+ #previous_versions
42
+ .label Previous Versions
43
+ .value
44
+ - unless previous_versions.empty?
45
+ %table
46
+ %tr.header
47
+ %td Time
48
+ %td Version
49
+ %td Commit
50
+ - previous_versions.each_with_index do |version, i|
51
+ %tr{ :class => i%2==0 ? 'even' : nil }
52
+ %td= version[:time].strftime('%x %X')
53
+ %td
54
+ %a{ :href => version_link(version[:version]) }= version[:version]
55
+ %td
56
+ %a{ :href => commit_link(version[:revision]) }= version[:revision]
57
+ .spacer
37
58
  #headers
38
59
  .label Headers
39
60
  .value
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,8 @@ require 'ops_routes/middleware'
6
6
 
7
7
  # Define app controller since we're not in a rails app
8
8
  class ApplicationController
9
+ def self.unloadable
10
+ end
9
11
  end
10
12
  require 'ops_controller'
11
13
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 4
9
+ version: 0.4.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Primedia Team
@@ -92,6 +92,7 @@ extra_rdoc_files:
92
92
  - LICENSE
93
93
  - README.rdoc
94
94
  files:
95
+ - .gitignore
95
96
  - LICENSE
96
97
  - README.rdoc
97
98
  - Rakefile