puppet-herald 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +15 -7
  2. data/.rubocop.yml +31 -0
  3. data/.rubocop_todo.yml +6 -0
  4. data/.travis.yml +7 -7
  5. data/Gemfile +5 -9
  6. data/README.md +152 -16
  7. data/Rakefile +67 -6
  8. data/bin/puppet-herald +1 -1
  9. data/config.ru +2 -2
  10. data/db/migrate/20141211165540_create_nodes.rb +5 -3
  11. data/db/migrate/20141211171305_create_reports.rb +12 -10
  12. data/db/migrate/20141211171326_create_log_entries.rb +9 -7
  13. data/db/schema.rb +24 -26
  14. data/lib/puppet-herald.rb +59 -21
  15. data/lib/puppet-herald/app/api.rb +111 -0
  16. data/lib/puppet-herald/app/configuration.rb +70 -0
  17. data/lib/puppet-herald/app/frontend.rb +61 -0
  18. data/lib/puppet-herald/{views → app/views}/app.erb +5 -8
  19. data/lib/puppet-herald/{views → app/views}/err500.erb +1 -4
  20. data/lib/puppet-herald/application.rb +27 -0
  21. data/lib/puppet-herald/cli.rb +66 -45
  22. data/lib/puppet-herald/client.rb +33 -0
  23. data/lib/puppet-herald/database.rb +84 -40
  24. data/lib/puppet-herald/javascript.rb +23 -17
  25. data/lib/puppet-herald/models/log-entry.rb +10 -3
  26. data/lib/puppet-herald/models/node.rb +15 -5
  27. data/lib/puppet-herald/models/report.rb +70 -63
  28. data/lib/puppet-herald/public/app.js +9 -8
  29. data/lib/puppet-herald/public/components/directives/status-button.html +1 -1
  30. data/lib/puppet-herald/public/components/directives/status-button.js +5 -3
  31. data/lib/puppet-herald/public/components/filters/filters.js +9 -4
  32. data/lib/puppet-herald/public/components/page.js +34 -0
  33. data/lib/puppet-herald/public/node/node.html +3 -1
  34. data/lib/puppet-herald/public/node/node.js +7 -4
  35. data/lib/puppet-herald/public/nodes/nodes.js +3 -2
  36. data/lib/puppet-herald/public/report/report.html +4 -1
  37. data/lib/puppet-herald/public/report/report.js +5 -3
  38. data/lib/puppet-herald/stubs/puppet.rb +20 -9
  39. data/lib/puppet-herald/version.rb +17 -7
  40. data/package.json +8 -3
  41. data/puppet-herald.gemspec +3 -6
  42. data/spec/integration/application_spec.rb +175 -0
  43. data/spec/integration/models/node_spec.rb +4 -4
  44. data/spec/integration/models/report_spec.rb +7 -7
  45. data/spec/spec_helper.rb +12 -7
  46. data/spec/support/active_record.rb +6 -10
  47. data/spec/support/reconnectdb.rb +13 -0
  48. data/spec/unit/puppet-herald/cli_spec.rb +45 -13
  49. data/spec/unit/puppet-herald/client_spec.rb +23 -0
  50. data/spec/unit/puppet-herald/database_spec.rb +8 -9
  51. data/spec/unit/puppet-herald/javascript_spec.rb +8 -13
  52. data/spec/unit/puppet-herald_spec.rb +4 -4
  53. data/test/javascript/karma.conf.js +43 -5
  54. data/test/javascript/src/app_test.js +90 -0
  55. data/test/javascript/src/components/artifact/artifact-directive_test.js +36 -0
  56. data/test/javascript/src/components/artifact/artifact_test.js +64 -0
  57. data/test/javascript/src/components/directives/status-button_test.js +159 -0
  58. data/test/javascript/src/components/filters/filters_test.js +35 -0
  59. data/test/javascript/src/node/node_test.js +87 -0
  60. data/test/javascript/src/nodes/nodes_test.js +56 -0
  61. data/test/javascript/src/report/report_test.js +94 -0
  62. metadata +98 -68
  63. data/lib/puppet-herald/app.rb +0 -103
  64. data/lib/puppet-herald/public/components/artifact/artifact-directive_test.js +0 -17
  65. data/spec/integration/app_spec.rb +0 -21
@@ -1,103 +0,0 @@
1
- require 'sinatra/base'
2
- require 'sinatra/namespace'
3
- require 'sinatra/activerecord'
4
- require 'puppet-herald'
5
- require 'puppet-herald/javascript'
6
- require 'puppet-herald/models/node'
7
- require 'puppet-herald/models/report'
8
-
9
- module PuppetHerald
10
- class App < Sinatra::Base
11
- register Sinatra::Namespace
12
- register Sinatra::ActiveRecordExtension
13
-
14
- set :database, PuppetHerald::Database.spec unless PuppetHerald::Database.spec.nil?
15
- if PuppetHerald::is_in_dev?
16
- set :environment, :development
17
- else
18
- set :environment, :production
19
- end
20
-
21
- def self.run! options = {}, &block
22
- ActiveRecord::Base.establish_connection(PuppetHerald::Database.spec)
23
- ActiveRecord::Migrator.up "db/migrate"
24
- super options, *block
25
- end
26
-
27
- error do
28
- @bug = PuppetHerald::bug(env['sinatra.error'])
29
- if response.content_type == 'application/json'
30
- @bug.to_json
31
- else
32
- erb :err500
33
- end
34
- end
35
-
36
- get %r{/app\.min\.(js\.map|js)} do |ext|
37
- content_type 'application/javascript'
38
- ugly = PuppetHerald::Javascript::uglify '/app.min.js.map'
39
- ugly[ext]
40
- end
41
-
42
- get '/' do
43
- redirect "/app.html", 301
44
- end
45
-
46
- get '/index.html' do
47
- redirect "/app.html", 301
48
- end
49
-
50
- get '/app.html' do
51
- if PuppetHerald::is_in_prod?
52
- @minified = '.min'
53
- @files = ['/app.min.js']
54
- else
55
- @minified = ''
56
- @files = PuppetHerald::Javascript::files
57
- end
58
- erb :app
59
- end
60
-
61
- get '/version.json' do
62
- content_type 'application/json'
63
- ver = {}
64
- [:VERSION, :LICENSE, :NAME, :PACKAGE, :SUMMARY, :DESCRIPTION, :HOMEPAGE].each do |const|
65
- ver[const.downcase] = PuppetHerald::const_get const
66
- end
67
- ver.to_json
68
- end
69
-
70
- namespace '/api' do
71
- namespace '/v1' do
72
-
73
- put '/provide-log' do
74
- content_type 'application/json'
75
- yaml = request.body.read
76
- report = Report.create_from_yaml yaml
77
-
78
- {:status => :ok}.to_json
79
- end
80
-
81
- get '/nodes' do
82
- content_type 'application/json'
83
- nodes = Node.all
84
- nodes.to_json
85
- end
86
-
87
- get '/node/:id' do
88
- content_type 'application/json'
89
- id = params[:id]
90
- Node.get_with_reports(id).
91
- to_json(:include => :reports)
92
- end
93
-
94
- get '/report/:id' do
95
- content_type 'application/json'
96
- id = params[:id]
97
- Report.get_with_log_entries(id).
98
- to_json(:include => :log_entries)
99
- end
100
- end
101
- end
102
- end
103
- end
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- describe('herald.artifact module', function() {
4
- beforeEach(module('herald.artifact'));
5
-
6
- describe('app-version directive', function() {
7
- it('should print current version', function() {
8
- module(function($provide) {
9
- $provide.value('artifact', { version: 'TEST_VER' });
10
- });
11
- inject(function($compile, $rootScope) {
12
- var element = $compile('<span app-version></span>')($rootScope);
13
- expect(element.text()).toEqual('TEST_VER');
14
- });
15
- });
16
- });
17
- });
@@ -1,21 +0,0 @@
1
- ENV['RACK_ENV'] = 'test'
2
-
3
- require 'model_helper'
4
- require 'rspec'
5
- require 'rack/test'
6
-
7
- xdescribe 'The Herald App', :rollback => true do
8
- include Rack::Test::Methods
9
-
10
- def app
11
- require 'puppet-herald/app'
12
- PuppetHerald::App
13
- end
14
-
15
- it "on '/' redirects to '/app.html'" do
16
- get '/'
17
- expect(last_response).not_to be_ok
18
- expect(last_response.status).to eq(301)
19
- expect(last_response.header['Location']).to eq('http://example.org/app.html')
20
- end
21
- end