mystro-volley 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/mystro-volley/application.js +99 -0
  5. data/app/assets/stylesheets/mystro-volley/application.css +13 -0
  6. data/app/assets/stylesheets/mystro-volley/home.css.scss +23 -0
  7. data/app/controllers/mystro_volley/application_controller.rb +3 -0
  8. data/app/controllers/mystro_volley/branches_controller.rb +87 -0
  9. data/app/controllers/mystro_volley/home_controller.rb +48 -0
  10. data/app/controllers/mystro_volley/projects_controller.rb +87 -0
  11. data/app/controllers/mystro_volley/versions_controller.rb +105 -0
  12. data/app/helpers/mystro_volley/application_helper.rb +15 -0
  13. data/app/helpers/mystro_volley/branches_helper.rb +4 -0
  14. data/app/helpers/mystro_volley/projects_helper.rb +4 -0
  15. data/app/helpers/mystro_volley/versions_helper.rb +4 -0
  16. data/app/models/jobs/volley/base.rb +14 -0
  17. data/app/models/jobs/volley/deploy.rb +38 -0
  18. data/app/models/jobs/volley/destroy/branch.rb +8 -0
  19. data/app/models/jobs/volley/destroy/project.rb +8 -0
  20. data/app/models/jobs/volley/destroy/version.rb +16 -0
  21. data/app/models/jobs/volley/mco.rb +8 -0
  22. data/app/models/jobs/volley/meta.rb +39 -0
  23. data/app/models/jobs/volley/update.rb +26 -0
  24. data/app/models/mystro_volley/branch.rb +15 -0
  25. data/app/models/mystro_volley/install.rb +9 -0
  26. data/app/models/mystro_volley/project.rb +14 -0
  27. data/app/models/mystro_volley/version.rb +37 -0
  28. data/app/views/mystro_volley/branches/_branch.html.erb +8 -0
  29. data/app/views/mystro_volley/branches/_form.html.erb +21 -0
  30. data/app/views/mystro_volley/branches/_list.html.erb +12 -0
  31. data/app/views/mystro_volley/branches/edit.html.erb +6 -0
  32. data/app/views/mystro_volley/branches/index.html.erb +23 -0
  33. data/app/views/mystro_volley/branches/new.html.erb +5 -0
  34. data/app/views/mystro_volley/branches/show.html.erb +5 -0
  35. data/app/views/mystro_volley/common/_breadcrumbs.html.erb +10 -0
  36. data/app/views/mystro_volley/home/index.html.erb +37 -0
  37. data/app/views/mystro_volley/home/show.html.erb +0 -0
  38. data/app/views/mystro_volley/projects/_form.html.erb +21 -0
  39. data/app/views/mystro_volley/projects/_list.html.erb +12 -0
  40. data/app/views/mystro_volley/projects/_project.html.erb +8 -0
  41. data/app/views/mystro_volley/projects/edit.html.erb +6 -0
  42. data/app/views/mystro_volley/projects/index.html.erb +1 -0
  43. data/app/views/mystro_volley/projects/new.html.erb +5 -0
  44. data/app/views/mystro_volley/projects/show.html.erb +5 -0
  45. data/app/views/mystro_volley/versions/_form.html.erb +33 -0
  46. data/app/views/mystro_volley/versions/_list.html.erb +15 -0
  47. data/app/views/mystro_volley/versions/_version.html.erb +14 -0
  48. data/app/views/mystro_volley/versions/deploy.html.erb +32 -0
  49. data/app/views/mystro_volley/versions/edit.html.erb +6 -0
  50. data/app/views/mystro_volley/versions/index.html.erb +7 -0
  51. data/app/views/mystro_volley/versions/new.html.erb +5 -0
  52. data/app/views/mystro_volley/versions/show.html.erb +17 -0
  53. data/app/workers/volley_worker.rb +16 -0
  54. data/config/routes.rb +22 -0
  55. data/lib/mystro-volley/engine.rb +17 -0
  56. data/lib/mystro-volley/plugin.rb +32 -0
  57. data/lib/mystro-volley/version.rb +11 -0
  58. data/lib/mystro-volley.rb +5 -0
  59. data/lib/tasks/mystro-volley_tasks.rake +4 -0
  60. data/test/dummy/README.rdoc +261 -0
  61. data/test/dummy/Rakefile +7 -0
  62. data/test/dummy/app/assets/javascripts/application.js +15 -0
  63. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  64. data/test/dummy/app/controllers/application_controller.rb +3 -0
  65. data/test/dummy/app/helpers/application_helper.rb +2 -0
  66. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  67. data/test/dummy/config/application.rb +59 -0
  68. data/test/dummy/config/boot.rb +10 -0
  69. data/test/dummy/config/database.yml +25 -0
  70. data/test/dummy/config/environment.rb +5 -0
  71. data/test/dummy/config/environments/development.rb +37 -0
  72. data/test/dummy/config/environments/production.rb +67 -0
  73. data/test/dummy/config/environments/test.rb +37 -0
  74. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  75. data/test/dummy/config/initializers/inflections.rb +15 -0
  76. data/test/dummy/config/initializers/mime_types.rb +5 -0
  77. data/test/dummy/config/initializers/secret_token.rb +7 -0
  78. data/test/dummy/config/initializers/session_store.rb +8 -0
  79. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  80. data/test/dummy/config/locales/en.yml +5 -0
  81. data/test/dummy/config/routes.rb +4 -0
  82. data/test/dummy/config.ru +4 -0
  83. data/test/dummy/public/404.html +26 -0
  84. data/test/dummy/public/422.html +26 -0
  85. data/test/dummy/public/500.html +25 -0
  86. data/test/dummy/public/favicon.ico +0 -0
  87. data/test/dummy/script/rails +6 -0
  88. data/test/fixtures/mystro_volley/projects.yml +7 -0
  89. data/test/functional/mystro_volley/branches_controller_test.rb +51 -0
  90. data/test/functional/mystro_volley/projects_controller_test.rb +51 -0
  91. data/test/functional/mystro_volley/versions_controller_test.rb +51 -0
  92. data/test/integration/navigation_test.rb +10 -0
  93. data/test/mystro-volley_test.rb +7 -0
  94. data/test/test_helper.rb +15 -0
  95. data/test/unit/helpers/mystro_volley/branches_helper_test.rb +6 -0
  96. data/test/unit/helpers/mystro_volley/projects_helper_test.rb +6 -0
  97. data/test/unit/helpers/mystro_volley/versions_helper_test.rb +6 -0
  98. data/test/unit/mystro_volley/project_test.rb +9 -0
  99. metadata +265 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = MystroVolley
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'MystroVolley'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,99 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
16
+
17
+ $(function () {
18
+ $(document).on("click", ".volley-deploy", function () {
19
+ console.log("deploy");
20
+ var u = $(this).data("url");
21
+ console.log("deploy: " + u);
22
+ $.get(u)
23
+ .done(function (d) {
24
+ $("#deploy_dialog_contents").html(d);
25
+ });
26
+ bootbox.dialog($("#deploy_dialog").html(), [
27
+ {
28
+ "Cancel": function () {
29
+ console.log("cancel");
30
+ }
31
+ },
32
+ {
33
+ "Create": function () {
34
+ console.log("deploy");
35
+ var f = $("#deploy_form:last");
36
+ var u = f.attr("action");
37
+ console.log("post " + u);
38
+ data = f.serialize();
39
+ console.log(data);
40
+ bootbox.modal("please wait", "queueing job");
41
+ $.post(u, data, function () {
42
+ console.log("post done");
43
+ bootbox.hideAll();
44
+ });
45
+ // console.log("create");
46
+ // var f = $(".compute_form:last"); // because bootbox makes a clone
47
+ // data = f.serialize();
48
+ // console.log("data");
49
+ // console.log(f.serializeArray());
50
+ // bootbox.modal("please wait", "creating");
51
+ // console.log("post");
52
+ // $.post("/computes.json", data, function () {
53
+ // console.log("success");
54
+ // bootbox.hideAll();
55
+ // });
56
+ }
57
+ }
58
+ ], {header: "Deploy"})
59
+ });
60
+ $(document).on("click", ".mv-tab-view", function () {
61
+ var id = $(this).attr("data-id");
62
+ var type = $(this).attr("data-type");
63
+ var kids = $(this).attr("data-kids");
64
+
65
+ var heir = {"projects": "branches", "branches": "versions", "versions": "files"};
66
+ var grandkids = heir[kids];
67
+
68
+ console.log("tab view click:" + id);
69
+
70
+ $("#mv-" + type + " .mv-tab-view").removeClass("active");
71
+ $(this).addClass("active");
72
+
73
+ var thatid = id;
74
+ var thattype = type;
75
+
76
+ $.get("/plugins/volley/" + type + "/" + id + ".json", function (d) {
77
+ console.log("recieved " + kids);
78
+ var h = "";
79
+ // if (!grandkids) {
80
+ // }
81
+ for (var i in d) {
82
+ var n = d[i]["name"];
83
+ var id = d[i]["_id"];
84
+ console.log(kids + ": " + n);
85
+ // %{<li id="branch-#{e.name}" data-id="#{e.id.to_s}" class="mv-tab-branch"><a href="#">#{e.name}</a></li>}
86
+ if(grandkids) {
87
+ h += "<li data-id='" + id + "' class='mv-tab-view' data-type='" + kids + "' data-kids='" + grandkids + "'><a href='#'>" + n + "</a></li>";
88
+ } else {
89
+ h += "<li><a href='#'>" + n + "</a></li>";
90
+ }
91
+ }
92
+ h += "<li></li>";
93
+ h += "<li><a href='/plugins/volley/"+thattype+"/"+thatid+"'>view</a></li>"
94
+ // h += "<li><a href='/plugins/volley/"+thattype+"/"+thatid+"'>destroy</a></li>"
95
+ $("#mv-" + kids + "-content").html(h);
96
+ $("#mv-"+kids+"-content li:first").click();
97
+ });
98
+ });
99
+ });
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,23 @@
1
+
2
+ div.mv-view.tabbable.tabs-left > ul.nav.nav-tabs {
3
+ width: 260px;
4
+ }
5
+
6
+
7
+ .mv-view {
8
+ ul {
9
+ li {
10
+ height: 24px;
11
+ line-height: 20px;
12
+ list-style-type: none;
13
+ list-style-position: outside;
14
+ }
15
+ li.active {
16
+ list-style-type: square;
17
+ color: black;
18
+ a {
19
+ color: inherit;
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,3 @@
1
+ class MystroVolley::ApplicationController < ApplicationController
2
+ include MystroVolley::ApplicationHelper
3
+ end
@@ -0,0 +1,87 @@
1
+ require_dependency "mystro_volley/application_controller"
2
+
3
+ module MystroVolley
4
+ class BranchesController < ApplicationController
5
+ # GET /branches
6
+ # GET /branches.json
7
+ def index
8
+ @branches = Branch.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render json: @branches }
13
+ end
14
+ end
15
+
16
+ # GET /branches/1
17
+ # GET /branches/1.json
18
+ def show
19
+ @branch = Branch.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @branch.versions }
24
+ end
25
+ end
26
+
27
+ ## GET /branches/new
28
+ ## GET /branches/new.json
29
+ #def new
30
+ # @branch = Branch.new
31
+ #
32
+ # respond_to do |format|
33
+ # format.html # new.html.erb
34
+ # format.json { render json: @branch }
35
+ # end
36
+ #end
37
+ #
38
+ ## GET /branches/1/edit
39
+ #def edit
40
+ # @branch = Branch.find(params[:id])
41
+ #end
42
+ #
43
+ ## POST /branches
44
+ ## POST /branches.json
45
+ #def create
46
+ # @branch = Branch.new(params[:branch])
47
+ #
48
+ # respond_to do |format|
49
+ # if @branch.save
50
+ # format.html { redirect_to @branch, notice: 'Branch was successfully created.' }
51
+ # format.json { render json: @branch, status: :created, location: @branch }
52
+ # else
53
+ # format.html { render action: "new" }
54
+ # format.json { render json: @branch.errors, status: :unprocessable_entity }
55
+ # end
56
+ # end
57
+ #end
58
+ #
59
+ ## PUT /branches/1
60
+ ## PUT /branches/1.json
61
+ #def update
62
+ # @branch = Branch.find(params[:id])
63
+ #
64
+ # respond_to do |format|
65
+ # if @branch.update_attributes(params[:branch])
66
+ # format.html { redirect_to @branch, notice: 'Branch was successfully updated.' }
67
+ # format.json { head :no_content }
68
+ # else
69
+ # format.html { render action: "edit" }
70
+ # format.json { render json: @branch.errors, status: :unprocessable_entity }
71
+ # end
72
+ # end
73
+ #end
74
+
75
+ # DELETE /branches/1
76
+ # DELETE /branches/1.json
77
+ def destroy
78
+ @branch = Branch.find(params[:id])
79
+ Jobs::Volley::Destroy::Branch.create(data: {id: @branch.id, class: "MystroVolley::Branch"}).enqueue
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to branches_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,48 @@
1
+ require_dependency "mystro_volley/application_controller"
2
+ class MystroVolley::HomeController < ApplicationController
3
+ include MystroVolley::ApplicationHelper
4
+
5
+ def index
6
+ @projects = MystroVolley::Project.all
7
+ @myversions = MystroVolley::Version.desc(:timestamp).where(latest: true)
8
+ #render "mystro_volley/versions/index"
9
+ end
10
+
11
+ def show
12
+ p = params[:project]
13
+ b = params[:branch]
14
+ v = params[:version]
15
+
16
+ if p
17
+ @project = MystroVolley::Project.where(name: p).first
18
+
19
+ if @project
20
+ if b
21
+ @branch = @project.branches.where(name: b).first
22
+ if @branch
23
+ if v
24
+ @version = @branch.versions.where(name: v).first
25
+ if @version
26
+ return render "mystro_volley/versions/show"
27
+ else
28
+ return render "mystro_volley/branches/show"
29
+ end
30
+ else
31
+ return render "mystro_volley/branches/show"
32
+ end
33
+ else
34
+ return render "mystro_volley/projects/show"
35
+ end
36
+ else
37
+ return render "mystro_volley/projects/show"
38
+ end
39
+ else
40
+ @myversions = MystroVolley::Version.desc(:timestamp).where(latest: true)
41
+ render "mystro_volley/versions/index"
42
+ end
43
+ else
44
+ @myversions = MystroVolley::Version.desc(:timestamp).where(latest: true)
45
+ render "mystro_volley/versions/index"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,87 @@
1
+ require_dependency "mystro_volley/application_controller"
2
+
3
+ module MystroVolley
4
+ class ProjectsController < ApplicationController
5
+ # GET /projects
6
+ # GET /projects.json
7
+ def index
8
+ @projects = Project.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render json: @projects }
13
+ end
14
+ end
15
+
16
+ # GET /projects/1
17
+ # GET /projects/1.json
18
+ def show
19
+ @project = Project.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @project.branches }
24
+ end
25
+ end
26
+
27
+ # GET /projects/new
28
+ ## GET /projects/new.json
29
+ #def new
30
+ # @project = Project.new
31
+ #
32
+ # respond_to do |format|
33
+ # format.html # new.html.erb
34
+ # format.json { render json: @project }
35
+ # end
36
+ #end
37
+ #
38
+ ## GET /projects/1/edit
39
+ #def edit
40
+ # @project = Project.find(params[:id])
41
+ #end
42
+ #
43
+ ## POST /projects
44
+ ## POST /projects.json
45
+ #def create
46
+ # @project = Project.new(params[:project])
47
+ #
48
+ # respond_to do |format|
49
+ # if @project.save
50
+ # format.html { redirect_to @project, notice: 'Project was successfully created.' }
51
+ # format.json { render json: @project, status: :created, location: @project }
52
+ # else
53
+ # format.html { render action: "new" }
54
+ # format.json { render json: @project.errors, status: :unprocessable_entity }
55
+ # end
56
+ # end
57
+ #end
58
+ #
59
+ ## PUT /projects/1
60
+ ## PUT /projects/1.json
61
+ #def update
62
+ # @project = Project.find(params[:id])
63
+ #
64
+ # respond_to do |format|
65
+ # if @project.update_attributes(params[:project])
66
+ # format.html { redirect_to @project, notice: 'Project was successfully updated.' }
67
+ # format.json { head :no_content }
68
+ # else
69
+ # format.html { render action: "edit" }
70
+ # format.json { render json: @project.errors, status: :unprocessable_entity }
71
+ # end
72
+ # end
73
+ #end
74
+
75
+ # DELETE /projects/1
76
+ # DELETE /projects/1.json
77
+ def destroy
78
+ @project = Project.find(params[:id])
79
+ Jobs::Volley::Destroy::Project.create(data: {id: @project.id, class: "MystroVolley::Project"}).enqueue
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to projects_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,105 @@
1
+ require_dependency "mystro_volley/application_controller"
2
+
3
+ module MystroVolley
4
+ class VersionsController < ApplicationController
5
+ # GET /versions
6
+ # GET /versions.json
7
+ def index
8
+ @versions = Version.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render json: @versions }
13
+ end
14
+ end
15
+
16
+ # GET /versions/1
17
+ # GET /versions/1.json
18
+ def show
19
+ @version = Version.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @version.files.map {|e| {name: e, _id:"blarg"}} }
24
+ end
25
+ end
26
+
27
+ # GET /versions/1/deploy
28
+ def deploy
29
+ @version = Version.find(params[:id])
30
+ render "deploy", layout: false
31
+ end
32
+
33
+ # POST /versions/1/queue
34
+ def queue
35
+ @version = Version.find(params[:id])
36
+ @environment = Environment.find(params[:environment])
37
+ @role = Role.find(params[:role])
38
+ j = Jobs::Volley::Deploy.create(data: {version: @version.to_s, environment: @environment.name, account: current_user.account, force: params[:force] == 1, role: @role.name})
39
+ j.enqueue
40
+ render status: :ok, json: {errors: false}
41
+ rescue => e
42
+ render status: :bad_request, json: {errors: true, message: e.message}
43
+ end
44
+
45
+ ## GET /versions/new
46
+ ## GET /versions/new.json
47
+ #def new
48
+ # @version = Version.new
49
+ #
50
+ # respond_to do |format|
51
+ # format.html # new.html.erb
52
+ # format.json { render json: @version }
53
+ # end
54
+ #end
55
+ #
56
+ ## GET /versions/1/edit
57
+ #def edit
58
+ # @version = Version.find(params[:id])
59
+ #end
60
+ #
61
+ ## POST /versions
62
+ ## POST /versions.json
63
+ #def create
64
+ # @version = Version.new(params[:version])
65
+ #
66
+ # respond_to do |format|
67
+ # if @version.save
68
+ # format.html { redirect_to @version, notice: 'Version was successfully created.' }
69
+ # format.json { render json: @version, status: :created, location: @version }
70
+ # else
71
+ # format.html { render action: "new" }
72
+ # format.json { render json: @version.errors, status: :unprocessable_entity }
73
+ # end
74
+ # end
75
+ #end
76
+ #
77
+ ## PUT /versions/1
78
+ ## PUT /versions/1.json
79
+ #def update
80
+ # @version = Version.find(params[:id])
81
+ #
82
+ # respond_to do |format|
83
+ # if @version.update_attributes(params[:version])
84
+ # format.html { redirect_to @version, notice: 'Version was successfully updated.' }
85
+ # format.json { head :no_content }
86
+ # else
87
+ # format.html { render action: "edit" }
88
+ # format.json { render json: @version.errors, status: :unprocessable_entity }
89
+ # end
90
+ # end
91
+ #end
92
+
93
+ # DELETE /versions/1
94
+ # DELETE /versions/1.json
95
+ def destroy
96
+ @version = Version.find(params[:id])
97
+ Jobs::Volley::Destroy::Version.create(data: {id: @version.id, class: "MystroVolley::Version"}).enqueue
98
+
99
+ respond_to do |format|
100
+ format.html { redirect_to versions_url }
101
+ format.json { head :no_content }
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,15 @@
1
+ module MystroVolley
2
+ module ApplicationHelper
3
+ def path_helper(o)
4
+ case o.class
5
+ when MystroVolley::Project then root_path + "#{o.name}"
6
+ when MystroVolley::Branch then root_path + "#{o.project.name}/#{o.name}"
7
+ when MystroVolley::Version then root_path + "#{o.project.name}/#{o.branch.name}/#{o.name}"
8
+ else root_path
9
+ end
10
+ rescue => e
11
+ flash.now[:error] = "could not find path for #{o}"
12
+ root_path
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ module MystroVolley
2
+ module BranchesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module MystroVolley
2
+ module ProjectsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module MystroVolley
2
+ module VersionsHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ require "volley"
2
+ require "volley/dsl"
3
+
4
+ class Jobs::Volley::Base < Job
5
+ def init
6
+ #::Volley::Dsl::VolleyFile.init
7
+ ::Volley::Dsl::VolleyFile.load("#{Rails.root}/config/volley/volleyfile", primary: true)
8
+ end
9
+
10
+ def publisher
11
+ init
12
+ ::Volley::Dsl.publisher
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ class Jobs::Volley::Deploy < Jobs::Volley::Mco
2
+ def work
3
+ init
4
+
5
+ info "DATA: #{data.inspect}"
6
+
7
+ version = data["version"]
8
+ environment = data["environment"]
9
+ account = data["account"]
10
+ role = data["role"]
11
+ force = data["force"]
12
+
13
+ r = rpcclient
14
+
15
+ ["mystro.environment=#{environment}", "mystro.account=#{account}", "mystro.role_#{role}=true"].each do |f|
16
+ puts "filter: #{f}"
17
+ info "filter: #{f}"
18
+ r.fact_filter f
19
+ end
20
+
21
+ list = r.run(descriptor: version)
22
+ #list = r.meta()
23
+ list.each do |o|
24
+ r = o.results
25
+ if r[:statuscode] == 0
26
+ info "#{r[:sender]}: '#{r[:data][:status]}' #{r[:data][:out]}"
27
+
28
+ #vs = r[:data][:out].split("\n")
29
+ #vs.each do |v|
30
+ # puts "-- #{r[:sender]}: #{v}"
31
+ # info "-- #{r[:sender]}: #{v}"
32
+ #end
33
+ end
34
+ end
35
+
36
+ true
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ class Jobs::Volley::Destroy::Branch < Jobs::Volley::Base
2
+ def work
3
+ info "destroy branch #{model.to_s}"
4
+ publisher.delete_branch(model.project.name, model.name)
5
+ ensure
6
+ model.destroy
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class Jobs::Volley::Destroy::Project < Jobs::Volley::Base
2
+ def work
3
+ info "destroy project #{model.to_s}"
4
+ publisher.delete_project(model.name)
5
+ ensure
6
+ model.destroy
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ class Jobs::Volley::Destroy::Version < Jobs::Volley::Base
2
+ def work
3
+ info "volley: #{Volley::Version::STRING}"
4
+ info "destroy version #{model.to_s}"
5
+ p = model.project
6
+ b = model.branch
7
+ v = model
8
+ info "project: #{p.name}"
9
+ info "branch: #{b.name}"
10
+ info "version: #{v.name}"
11
+ raise "something wrong with version heirarchy" unless p && b && v
12
+ publisher.delete_version(p.name, b.name, v.name)
13
+ ensure
14
+ model.destroy
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ require 'mcollective'
2
+
3
+ class Jobs::Volley::Mco < Jobs::Volley::Base
4
+ include ::MCollective::RPC
5
+ def rpcclient
6
+ MCollective::RPC::Client.new("volley", options: {config: "#{Rails.root}/config/mcollective/client.cfg"})
7
+ end
8
+ end