visage-app 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ pkg/*
7
7
  webrat*
8
8
  visage-app.gemspec
9
9
  lib/visage/config/profiles.yaml
10
+ _site
data/AUTHORS CHANGED
@@ -7,3 +7,8 @@ Contributors include
7
7
  Jeffrey Lim <jfs.world@gmail.com>
8
8
  Andrew Harvey <andrew@mootpointer.com>
9
9
  Xavier Mehrenberger <xavier.mehrenberger@gmail.com>
10
+
11
+ Inspiration given by
12
+ --------------------
13
+ Gareth Stokes
14
+ Asdrubal Ibarra
data/README.md CHANGED
@@ -33,7 +33,7 @@ On Ubuntu, to install dependencies run:
33
33
 
34
34
  On CentOS, to install dependencies run:
35
35
 
36
- $ sudo yum install -y rrdtool ruby rubygems collectd
36
+ $ sudo yum install -y ruby-rrdtool ruby rubygems collectd
37
37
 
38
38
  Then install the app with:
39
39
 
data/Rakefile CHANGED
@@ -46,6 +46,7 @@ task :push => :lintian do
46
46
  system(command)
47
47
  end
48
48
 
49
+ desc "perform lintian checks on the JavaScript about to be shipped"
49
50
  task :lintian do
50
51
  require 'pathname'
51
52
  @root = Pathname.new(File.dirname(__FILE__)).expand_path
@@ -54,3 +55,11 @@ task :lintian do
54
55
  count = `grep -c 'console.log' #{javascripts_path.join('graph.js')}`.strip.to_i
55
56
  abort("#{count} instances of console.log found in graph.js!") if count > 0
56
57
  end
58
+
59
+ desc "clean up various generated files"
60
+ task :clean do
61
+ [ "webrat.log", "pkg/", "visage-app-*.spec", "_site/"].each do |filename|
62
+ puts "Removing #{filename}"
63
+ FileUtils.rm_rf(filename)
64
+ end
65
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -3,9 +3,16 @@ Feature: Visit site
3
3
  A user
4
4
  Must be able to visualise the data
5
5
 
6
- Scenario: Show available hosts
6
+ Scenario: Show graphs
7
7
  When I go to /profiles
8
8
  And I visit the first profile
9
9
  Then I should see a list of graphs
10
10
 
11
+ Scenario: List profiles
12
+ When I go to /profiles
13
+ Then I should see a list of profiles
14
+ When I follow "created"
15
+ Then I should see a list of profiles
16
+ When I follow "name"
17
+ Then I should see a list of profiles sorted alphabetically
11
18
 
@@ -9,3 +9,19 @@ Then /^I should see a list of graphs$/ do
9
9
  doc = Nokogiri::HTML(response_body)
10
10
  doc.search('div#profile div.graph').size.should > 1
11
11
  end
12
+
13
+ Then /^I should see a list of profiles$/ do
14
+ doc = Nokogiri::HTML(response_body)
15
+ doc.search('div#profiles ul li').size.should > 1
16
+ end
17
+
18
+ Then /^I should see a list of profiles sorted alphabetically$/ do
19
+ doc = Nokogiri::HTML(response_body)
20
+ profiles = doc.search('div#profiles ul li')
21
+ profiles.size.should > 1
22
+
23
+ unsorted = profiles.map { |p| p.text.strip }
24
+ sorted = profiles.map { |p| p.text.strip }.sort
25
+
26
+ unsorted.should == sorted
27
+ end
@@ -26,7 +26,12 @@ class SinatraWorld
26
26
  Webrat::Methods.delegate_to_session :response_code, :response_body, :response_headers, :response
27
27
 
28
28
  def app
29
- Visage::JSON
29
+ Rack::Builder.new do
30
+ use Visage::Profiles
31
+ use Visage::Builder
32
+ use Visage::JSON
33
+ run Sinatra::Application
34
+ end
30
35
  end
31
36
  end
32
37
 
data/lib/visage-app.rb CHANGED
@@ -38,7 +38,7 @@ module Visage
38
38
  end
39
39
 
40
40
  get '/profiles' do
41
- @profiles = Visage::Profile.all
41
+ @profiles = Visage::Profile.all(:sort => params[:sort])
42
42
  haml :profiles
43
43
  end
44
44
  end
data/lib/visage/config.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Visage
2
- class Config
2
+ class Config
3
3
 
4
4
  class << self
5
5
  def use
@@ -20,32 +20,5 @@ module Visage
20
20
  @configuration
21
21
  end
22
22
  end
23
-
24
- class Profiles
25
- class << self
26
- require 'ostruct'
27
-
28
- attr_accessor :profiles
29
-
30
- def get(id)
31
- id.gsub!(/\s+/, '+')
32
- if found = @profiles.find {|p| p[1]["splat"] == id }
33
- OpenStruct.new(found[1])
34
- else
35
- nil
36
- end
37
- end
38
-
39
- def all
40
- # here be ugliness
41
- profiles = @profiles.to_a.sort_by { |profile|
42
- profile[1]["order"]
43
- }.map { |profile|
44
- OpenStruct.new(profile[1].merge({'name' => profile[0]}))
45
- }
46
- end
47
- end
48
- end
49
-
50
23
  end
51
24
  end
@@ -20,9 +20,11 @@ module Visage
20
20
  profiles[url] ? self.new(profiles[url]) : nil
21
21
  end
22
22
 
23
- def self.all
23
+ def self.all(opts={})
24
+ sort = opts[:sort]
24
25
  profiles = YAML::load_file(@@profiles_filename) || {}
25
- profiles.values.map { |prof| self.new(prof) }
26
+ profiles = sort == "name" ? profiles.sort.map {|i| i.last } : profiles.values
27
+ profiles.map { |prof| self.new(prof) }
26
28
  end
27
29
 
28
30
  def initialize(opts={})
@@ -239,6 +239,12 @@ div#profiles {
239
239
  width: 450px;
240
240
  }
241
241
 
242
+ div#profiles div#sort {
243
+ text-align: right;
244
+ font-size: 85%;
245
+ color: #888;
246
+ }
247
+
242
248
  div#profiles ul li {
243
249
  margin-bottom: 8px;
244
250
  list-style-type: none;
@@ -2,6 +2,11 @@
2
2
 
3
3
  %div#profiles
4
4
  %h2 Profiles
5
+ %div#sort
6
+ Sort by:
7
+ %a{:href => link_to("/profiles?sort=name")} name
8
+ |
9
+ %a{:href => link_to("/profiles?sort=created")} created
5
10
 
6
11
  %ul
7
12
  - @profiles.each do |prof|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 5
9
- version: 0.2.5
8
+ - 6
9
+ version: 0.2.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lindsay Holmwood
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-11 00:00:00 +10:00
17
+ date: 2010-09-26 00:00:00 +10:00
18
18
  default_executable: visage
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -120,7 +120,6 @@ files:
120
120
  - lib/visage/config/fallback-colors.yaml
121
121
  - lib/visage/config/init.rb
122
122
  - lib/visage/config/plugin-colors.yaml
123
- - lib/visage/config/profiles.yaml.sample
124
123
  - lib/visage/graph.rb
125
124
  - lib/visage/helpers.rb
126
125
  - lib/visage/patches.rb
@@ -1,33 +0,0 @@
1
- ---
2
- profiles:
3
- cpu+load:
4
- plugins:
5
- - cpu-0
6
- - cpu-1
7
- - load/load
8
- - battery-0
9
- name: CPU + Load
10
- order: 1
11
- memory:
12
- plugins:
13
- - memory
14
- - swap
15
- name: Memory
16
- order: 2
17
- disk+usage:
18
- plugins:
19
- - df/df-root
20
- - disk-sda
21
- name: Disk Usage
22
- order: 3
23
- network:
24
- plugins:
25
- - tcpconns-9393-local
26
- - tcpconns-80-local
27
- name: Networking
28
- order: 4
29
- processes:
30
- plugins:
31
- - processes
32
- name: Processes
33
- order: 5