magi 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38a310270effb9fb28e7bb7d5305c49cf7ed12c3
4
- data.tar.gz: 68a7ca5195cce218b36f077d15842c01a6a9111e
3
+ metadata.gz: fd8670d413c9cc9a48fc8ab40a8a61bf7644df09
4
+ data.tar.gz: bdcde50c3ccb2bb39de71b4d706d36ceb59980a4
5
5
  SHA512:
6
- metadata.gz: 339609bedc33c6839fbd3ae33e7aa15268ef9f0585cbfadd7ca9f32ab4d0ad453ce5ce80b296e12ca78e88c6b9824946524ddb9d72b575fc09fd9083504c5952
7
- data.tar.gz: 3f2fd55ab271d85ec648d090079c3b1fa716d945f80d74c6480b5a7d931a2331a9904b8150183e9ccb6b98b220a3b562e6b1de7793806a8abed579566635a8ce
6
+ metadata.gz: 9d816fdc2a44c697af5bad160e83fc1e1dcf56eaee8b4270f560cc621372ed8d45966c874f19514563b36482533b8fbbe78ddd3eb6aeced1cf98f7cce5712878
7
+ data.tar.gz: 9fe5724e18f3063c5a800dedc4c6f3f5e076b40f6a82597d091351ca8768bebce04cb7095160062d509b81141bdc9a0fa18075938f0d7144ea2051d6254333f1
data/Gemfile CHANGED
@@ -7,12 +7,14 @@ gem "jquery-rails"
7
7
  gem "quiet_assets"
8
8
  gem "resque"
9
9
  gem "slim"
10
+ gem "weak_parameters"
10
11
 
11
12
  group :development, :test do
12
13
  gem "pry-rails"
13
14
  end
14
15
 
15
16
  group :test do
17
+ gem "autodoc"
16
18
  gem "factory_girl_rails"
17
19
  gem "response_code_matchers"
18
20
  gem "rspec-json_matcher"
data/README.md CHANGED
@@ -16,15 +16,18 @@ $ magi start # open http://localhost:3000
16
16
  ```
17
17
 
18
18
  ## Hack
19
- Magi is just a rails application.
20
- Feel free to do what you want.
19
+ Magi is just a rails application with some middlewares.
21
20
 
22
- ### tools
23
- * Rails: HTTP server
24
- * Sidekiq: background worker
25
- * Redis: worker queue
26
- * MySQL: store jobs & builds
21
+ * clockwork: scheduler
22
+ * foreman: process manager
23
+ * mysql: store jobs & builds
24
+ * resque: background worker using redis
27
25
 
28
- ### todo
26
+ ## Todo
27
+ * async update by ajax
29
28
  * plugin system
30
- * cli options (e.g. http port, rails env, redis conf)
29
+ * git integration
30
+ * command-line options
31
+
32
+ ## API
33
+ [API documents](https://github.com/r7kamura/magi/blob/master/doc)
@@ -3,6 +3,10 @@ class ApplicationController < ActionController::Base
3
3
 
4
4
  respond_to :html, :json
5
5
 
6
+ rescue_from WeakParameters::ValidationError do
7
+ head 400
8
+ end
9
+
6
10
  private
7
11
 
8
12
  def require_resource_params
@@ -2,7 +2,10 @@ class BuildsController < ApplicationController
2
2
  before_filter :require_job
3
3
  before_filter :require_resources, only: :index
4
4
  before_filter :require_resource, only: [:show, :update, :destroy]
5
- before_filter :require_resource_params, only: :update
5
+
6
+ validates :update do
7
+ integer :status
8
+ end
6
9
 
7
10
  def index
8
11
  respond_with @resources
@@ -18,7 +21,7 @@ class BuildsController < ApplicationController
18
21
  end
19
22
 
20
23
  def update
21
- respond_with @resource.update_attributes(resource_params.slice(:status))
24
+ respond_with @resource.update_attributes(params.slice(:status))
22
25
  end
23
26
 
24
27
  def destroy
@@ -1,8 +1,17 @@
1
1
  class JobsController < ApplicationController
2
- before_filter :require_resource_params, only: [:create, :update]
3
2
  before_filter :require_resources, only: :index
4
3
  before_filter :require_resource, only: [:show, :edit, :update, :destroy]
5
4
 
5
+ validates :create do
6
+ string :name, required: true
7
+ hash :config
8
+ end
9
+
10
+ validates :update do
11
+ string :name
12
+ hash :config
13
+ end
14
+
6
15
  def index
7
16
  respond_with @resources
8
17
  end
@@ -16,11 +25,11 @@ class JobsController < ApplicationController
16
25
  end
17
26
 
18
27
  def create
19
- respond_with @resource = scope.create_with_properties(resource_params)
28
+ respond_with @resource = scope.create_with_properties(params.slice(:config, :name))
20
29
  end
21
30
 
22
31
  def update
23
- respond_with @resource.update_attributes_with_properties(resource_params)
32
+ respond_with @resource.update_attributes_with_properties(params.slice(:config, :name))
24
33
  end
25
34
 
26
35
  def destroy
data/lib/magi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Magi
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/magi.gemspec CHANGED
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency "sass-rails", "~> 3.2.3"
40
40
  spec.add_dependency "slim"
41
41
  spec.add_dependency "uglifier", ">= 1.0.3"
42
+ spec.add_dependency "weak_parameters", ">= 0.0.2"
42
43
  spec.add_development_dependency "bundler", "~> 1.3"
43
44
  spec.add_development_dependency "pry-rails"
44
45
  spec.add_development_dependency "thin"
@@ -22,7 +22,7 @@ describe "Builds" do
22
22
  build
23
23
  end
24
24
 
25
- it "returns builds of the job" do
25
+ it "returns builds of the job", :autodoc do
26
26
  get "/jobs/#{job.id}/builds", params, env
27
27
  response.status.should == 200
28
28
  response.body.should be_json([Hash])
@@ -30,7 +30,7 @@ describe "Builds" do
30
30
  end
31
31
 
32
32
  describe "GET /jobs/:job_id/builds/:id" do
33
- it "returns the build" do
33
+ it "returns the build", :autodoc do
34
34
  get "/jobs/#{job.id}/builds/#{build.id}", params, env
35
35
  response.status.should == 200
36
36
  response.body.should be_json(Hash)
@@ -38,7 +38,7 @@ describe "Builds" do
38
38
  end
39
39
 
40
40
  describe "POST /jobs/:job_id/builds" do
41
- it "creates a new build and queue it" do
41
+ it "creates a new build and queue it", :autodoc do
42
42
  post "/jobs/#{job.id}/builds", params, env
43
43
  response.status.should == 201
44
44
  response.body.should be_json(Hash)
@@ -48,10 +48,10 @@ describe "Builds" do
48
48
 
49
49
  describe "PUT /jobs/:job_id/builds/:id" do
50
50
  before do
51
- params[:build] = { status: true }
51
+ params[:status] = 1
52
52
  end
53
53
 
54
- it "updates the build" do
54
+ it "updates the build", :autodoc do
55
55
  put "/jobs/#{job.id}/builds/#{build.id}", params, env
56
56
  response.status.should == 204
57
57
  build.reload.status.should == true
@@ -59,7 +59,7 @@ describe "Builds" do
59
59
  end
60
60
 
61
61
  describe "DELETE /jobs/:job_id/builds/:id" do
62
- it "deletes the build" do
62
+ it "deletes the build", :autodoc do
63
63
  delete "/jobs/#{job.id}/builds/#{build.id}", params, env
64
64
  response.status.should == 204
65
65
  Build.should have(0).build
@@ -18,7 +18,7 @@ describe "Jobs" do
18
18
  job
19
19
  end
20
20
 
21
- it "returns jobs" do
21
+ it "returns jobs", :autodoc do
22
22
  get "/jobs", params, env
23
23
  response.status.should == 200
24
24
  response.body.should be_json([Hash])
@@ -26,7 +26,7 @@ describe "Jobs" do
26
26
  end
27
27
 
28
28
  describe "GET /jobs/:id" do
29
- it "returns the job" do
29
+ it "returns the job", :autodoc do
30
30
  get "/jobs/#{job.id}", params, env
31
31
  response.status.should == 200
32
32
  response.body.should be_json(Hash)
@@ -35,12 +35,12 @@ describe "Jobs" do
35
35
 
36
36
  describe "POST /jobs" do
37
37
  before do
38
- params[:job] = { name: "name" }
38
+ params[:name] = "name"
39
39
  end
40
40
 
41
41
  context "with invalid params" do
42
42
  before do
43
- params.delete(:job)
43
+ params.delete(:name)
44
44
  end
45
45
 
46
46
  it "returns 400" do
@@ -50,7 +50,7 @@ describe "Jobs" do
50
50
  end
51
51
 
52
52
  context "with valid condition" do
53
- it "creates a new job" do
53
+ it "creates a new job", :autodoc do
54
54
  post "/jobs", params, env
55
55
  response.status.should == 201
56
56
  Job.should have(1).job
@@ -60,12 +60,12 @@ describe "Jobs" do
60
60
 
61
61
  describe "PUT /jobs/:id" do
62
62
  before do
63
- params[:job] = { name: "name" }
63
+ params[:name] = "name"
64
64
  end
65
65
 
66
66
  context "with invalid params" do
67
67
  before do
68
- params.delete(:job)
68
+ params[:config] = "invalid"
69
69
  end
70
70
 
71
71
  it "returns 400" do
@@ -75,7 +75,7 @@ describe "Jobs" do
75
75
  end
76
76
 
77
77
  context "with valid condition" do
78
- it "updates the job" do
78
+ it "updates the job", :autodoc do
79
79
  put "/jobs/#{job.id}", params, env
80
80
  response.status.should == 204
81
81
  job.reload.name.should == "name"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-07 00:00:00.000000000 Z
11
+ date: 2013-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clockwork
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - '>='
193
193
  - !ruby/object:Gem::Version
194
194
  version: 1.0.3
195
+ - !ruby/object:Gem::Dependency
196
+ name: weak_parameters
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '>='
200
+ - !ruby/object:Gem::Version
201
+ version: 0.0.2
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '>='
207
+ - !ruby/object:Gem::Version
208
+ version: 0.0.2
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: bundler
197
211
  requirement: !ruby/object:Gem::Requirement