mortar-api-ruby 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,16 +51,23 @@ module Mortar
51
51
  # POST /vX/describes
52
52
  def post_describe(project_name, pigscript, pigscript_alias, git_ref, options = {})
53
53
  parameters = options[:parameters] || {}
54
+ body = {"project_name" => project_name,
55
+ "pigscript_name" => pigscript,
56
+ "alias" => pigscript_alias,
57
+ "git_ref" => git_ref,
58
+ "parameters" => parameters
59
+ }
60
+
61
+ #If no pig_version is set, leave it to server to figure out version.
62
+ unless options[:pig_version].nil?
63
+ body["pig_version"] = options[:pig_version]
64
+ end
65
+
54
66
  request(
55
67
  :expects => 200,
56
68
  :method => :post,
57
69
  :path => versioned_path("/describes"),
58
- :body => json_encode({"project_name" => project_name,
59
- "pigscript_name" => pigscript,
60
- "alias" => pigscript_alias,
61
- "git_ref" => git_ref,
62
- "parameters" => parameters
63
- })
70
+ :body => json_encode(body)
64
71
  )
65
72
  end
66
73
  end
@@ -57,17 +57,24 @@ module Mortar
57
57
  # POST /vX/illustrates
58
58
  def post_illustrate(project_name, pigscript, pigscript_alias, skip_pruning, git_ref, options = {})
59
59
  parameters = options[:parameters] || {}
60
+ body = {"project_name" => project_name,
61
+ "pigscript_name" => pigscript,
62
+ "alias" => pigscript_alias,
63
+ "skip_pruning" => skip_pruning,
64
+ "git_ref" => git_ref,
65
+ "parameters" => parameters
66
+ }
67
+
68
+ #If no pig_version is set, leave it to server to figure out version.
69
+ unless options[:pig_version].nil?
70
+ body["pig_version"] = options[:pig_version]
71
+ end
72
+
60
73
  request(
61
74
  :expects => 200,
62
75
  :method => :post,
63
76
  :path => versioned_path("/illustrates"),
64
- :body => json_encode({"project_name" => project_name,
65
- "pigscript_name" => pigscript,
66
- "alias" => pigscript_alias,
67
- "skip_pruning" => skip_pruning,
68
- "git_ref" => git_ref,
69
- "parameters" => parameters
70
- })
77
+ :body => json_encode(body)
71
78
  )
72
79
  end
73
80
  end
@@ -72,6 +72,11 @@ module Mortar
72
72
  body["pigscript_name"] = script_name
73
73
  end
74
74
 
75
+ #If no pig_version is set, leave it to server to figure out version.
76
+ unless options[:pig_version].nil?
77
+ body["pig_version"] = options[:pig_version]
78
+ end
79
+
75
80
  request(
76
81
  :expects => 200,
77
82
  :method => :post,
@@ -100,6 +105,11 @@ module Mortar
100
105
  body["pigscript_name"] = script_name
101
106
  end
102
107
 
108
+ #If no pig_version is set, leave it to server to figure out version.
109
+ unless options[:pig_version].nil?
110
+ body["pig_version"] = options[:pig_version]
111
+ end
112
+
103
113
  request(
104
114
  :expects => 200,
105
115
  :method => :post,
@@ -51,15 +51,22 @@ module Mortar
51
51
  # POST /vX/validates
52
52
  def post_validate(project_name, pigscript, git_ref, options = {})
53
53
  parameters = options[:parameters] || {}
54
+ body = {"project_name" => project_name,
55
+ "pigscript_name" => pigscript,
56
+ "git_ref" => git_ref,
57
+ "parameters" => parameters
58
+ }
59
+
60
+ #If no pig_version is set, leave it to server to figure out version.
61
+ unless options[:pig_version].nil?
62
+ body["pig_version"] = options[:pig_version]
63
+ end
64
+
54
65
  request(
55
66
  :expects => 200,
56
67
  :method => :post,
57
68
  :path => versioned_path("/validates"),
58
- :body => json_encode({"project_name" => project_name,
59
- "pigscript_name" => pigscript,
60
- "git_ref" => git_ref,
61
- "parameters" => parameters
62
- })
69
+ :body => json_encode(body)
63
70
  )
64
71
  end
65
72
  end
@@ -18,7 +18,7 @@ module Mortar
18
18
  class API
19
19
  # client version
20
20
  # see http://semver.org/
21
- VERSION = "0.6.3"
21
+ VERSION = "0.7.0"
22
22
 
23
23
  SERVER_API_VERSION = "2"
24
24
  end
@@ -36,16 +36,17 @@ describe Mortar::API do
36
36
  pigscript_name = "my_pigscript"
37
37
  pigscript_alias = "my_alias"
38
38
  git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
39
- parameters = {"key" => "value"}
39
+ params = {"key" => "value"}
40
40
  body = Mortar::API::OkJson.encode({"project_name" => project_name,
41
41
  "pigscript_name" => pigscript_name,
42
42
  "alias" => pigscript_alias,
43
43
  "git_ref" => git_ref,
44
- "parameters" => parameters})
44
+ "parameters" => params
45
+ })
45
46
  Excon.stub({:method => :post, :path => "/v2/describes", :body => body}) do |params|
46
47
  {:body => Mortar::API::OkJson.encode({'describe_id' => describe_id}), :status => 200}
47
48
  end
48
- response = @api.post_describe(project_name, pigscript_name, pigscript_alias, git_ref, :parameters => parameters)
49
+ response = @api.post_describe(project_name, pigscript_name, pigscript_alias, git_ref, :parameters => params)
49
50
  response.body['describe_id'].should == describe_id
50
51
  end
51
52
 
@@ -42,7 +42,8 @@ describe Mortar::API do
42
42
  "alias" => pigscript_alias,
43
43
  "skip_pruning" => skip_pruning,
44
44
  "git_ref" => git_ref,
45
- "parameters" => parameters})
45
+ "parameters" => parameters
46
+ })
46
47
  redirect_url = "some_redirect_url"
47
48
  redirect_message = "some_redirect_message"
48
49
  Excon.stub({:method => :post, :path => "/v2/illustrates", :body => body}) do |params|
@@ -43,7 +43,8 @@ describe Mortar::API do
43
43
  "alias" => pigscript_alias,
44
44
  "skip_pruning" => skip_pruning,
45
45
  "git_ref" => git_ref,
46
- "parameters" => parameters})
46
+ "parameters" => parameters
47
+ })
47
48
  Excon.stub({:method => :post, :path => "/v2/illustrates", :body => body}) do |params|
48
49
  {:body => Mortar::API::OkJson.encode({'illustrate_id' => illustrate_id}), :status => 200}
49
50
  end
@@ -108,7 +108,7 @@ describe Mortar::API do
108
108
  "cluster_type" => cluster_type,
109
109
  "parameters" => {},
110
110
  "notify_on_job_finish" => false,
111
- "pigscript_name" => pigscript_name
111
+ "pigscript_name" => pigscript_name,
112
112
  })
113
113
  Excon.stub({:method => :post, :path => "/v2/jobs", :body => body}) do |params|
114
114
  {:body => Mortar::API::OkJson.encode({'job_id' => job_id}), :status => 200}
@@ -152,7 +152,7 @@ describe Mortar::API do
152
152
  "cluster_type" => cluster_type,
153
153
  "parameters" => {},
154
154
  "notify_on_job_finish" => true,
155
- "pigscript_name" => pigscript_name
155
+ "pigscript_name" => pigscript_name,
156
156
  })
157
157
  Excon.stub({:method => :post, :path => "/v2/jobs", :body => body}) do |params|
158
158
  {:body => Mortar::API::OkJson.encode({'job_id' => job_id}), :status => 200}
@@ -38,14 +38,35 @@ describe Mortar::API do
38
38
  parameters = {"key" => "value"}
39
39
  body = Mortar::API::OkJson.encode({"project_name" => project_name,
40
40
  "pigscript_name" => pigscript_name,
41
- "git_ref" => git_ref,
42
- "parameters" => parameters})
41
+ "git_ref" => git_ref,
42
+ "parameters" => parameters
43
+ })
43
44
  Excon.stub({:method => :post, :path => "/v2/validates", :body => body}) do |params|
44
45
  {:body => Mortar::API::OkJson.encode({'validate_id' => validate_id}), :status => 200}
45
46
  end
46
47
  response = @api.post_validate(project_name, pigscript_name, git_ref, :parameters => parameters)
47
48
  response.body['validate_id'].should == validate_id
48
49
  end
50
+
51
+ it "posts a validate with set pig version" do
52
+ validate_id = "7b93e4d3ab034188a0c2be418d3d24ee"
53
+ project_name = "my_project"
54
+ pigscript_name = "my_pigscript"
55
+ git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
56
+ parameters = {"key" => "value"}
57
+ pig_version = "0.12"
58
+ body = Mortar::API::OkJson.encode({"project_name" => project_name,
59
+ "pigscript_name" => pigscript_name,
60
+ "git_ref" => git_ref,
61
+ "parameters" => parameters,
62
+ "pig_version" => pig_version
63
+ })
64
+ Excon.stub({:method => :post, :path => "/v2/validates", :body => body}) do |params|
65
+ {:body => Mortar::API::OkJson.encode({'validate_id' => validate_id}), :status => 200}
66
+ end
67
+ response = @api.post_validate(project_name, pigscript_name, git_ref, :parameters => parameters, :pig_version => pig_version)
68
+ response.body['validate_id'].should == validate_id
69
+ end
49
70
 
50
71
  it "gets a validate" do
51
72
  validate_id = "7b93e4d3ab034188a0c2be418d3d24ed"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortar-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 3
10
- version: 0.6.3
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mortar Data
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-03-29 00:00:00 Z
18
+ date: 2013-10-22 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: excon