mortar 0.12.6 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mortar/command/base.rb +2 -2
- data/lib/mortar/command/jobs.rb +1 -1
- data/lib/mortar/command/projects.rb +22 -4
- data/lib/mortar/version.rb +1 -1
- data/spec/mortar/command/projects_spec.rb +42 -6
- metadata +5 -5
data/lib/mortar/command/base.rb
CHANGED
@@ -133,10 +133,10 @@ class Mortar::Command::Base
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
def register_project(name)
|
136
|
+
def register_project(name, is_private)
|
137
137
|
project_id = nil
|
138
138
|
action("Sending request to register project: #{name}") do
|
139
|
-
project_id = api.post_project(name).body["project_id"]
|
139
|
+
project_id = api.post_project(name, is_private).body["project_id"]
|
140
140
|
end
|
141
141
|
|
142
142
|
project_result = nil
|
data/lib/mortar/command/jobs.rb
CHANGED
@@ -60,7 +60,7 @@ class Mortar::Command::Jobs < Mortar::Command::Base
|
|
60
60
|
#
|
61
61
|
# -c, --clusterid CLUSTERID # Run job on an existing cluster with ID of CLUSTERID (optional)
|
62
62
|
# -s, --clustersize NUMNODES # Run job on a new cluster, with NUMNODES nodes (optional; must be >= 2 if provided)
|
63
|
-
# -1, --singlejobcluster # Stop the cluster after job completes. (Default: false
|
63
|
+
# -1, --singlejobcluster # Stop the cluster after job completes. (Default: false--cluster can be used for other jobs, and will shut down after 1 hour of inactivity)
|
64
64
|
# -2, --permanentcluster # Don't automatically stop the cluster after it has been idle for an hour (Default: false--cluster will be shut down after 1 hour of inactivity)
|
65
65
|
# -3, --spot # Use spot instances for this cluster (Default: false, only applicable to new clusters)
|
66
66
|
# -p, --parameter NAME=VALUE # Set a pig parameter value in your script.
|
@@ -80,6 +80,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
80
80
|
# Used when you want to start a new Mortar project using Mortar generated code.
|
81
81
|
#
|
82
82
|
# --embedded # Create a Mortar project that is not its own git repo. Your code will still be synced with a git repo in the cloud.
|
83
|
+
# --public # Register a public project, which can be viewed and forked by anyone.
|
83
84
|
#
|
84
85
|
def create
|
85
86
|
name = shift_argument
|
@@ -90,13 +91,20 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
90
91
|
Mortar::Command::run("generate:project", [name])
|
91
92
|
|
92
93
|
FileUtils.cd(name)
|
94
|
+
|
95
|
+
args = [name,]
|
96
|
+
if options[:public]
|
97
|
+
args.push('--public')
|
98
|
+
end
|
99
|
+
|
93
100
|
if options[:embedded]
|
94
|
-
|
101
|
+
args.push("--embedded")
|
102
|
+
Mortar::Command::run("projects:register", args)
|
95
103
|
else
|
96
104
|
git.git_init
|
97
105
|
git.git("add .")
|
98
106
|
git.git("commit -m \"Mortar project scaffolding\"")
|
99
|
-
Mortar::Command::run("projects:register",
|
107
|
+
Mortar::Command::run("projects:register", args)
|
100
108
|
display "NOTE: You'll need to change to the new directory to use your project:\n cd #{name}\n\n"
|
101
109
|
end
|
102
110
|
end
|
@@ -107,6 +115,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
107
115
|
# Used when you want to start a new Mortar project using your existing code in the current directory.
|
108
116
|
#
|
109
117
|
# --embedded # Register code that is not its own git repo as a Mortar project. Your code will still be synced with a git repo in the cloud.
|
118
|
+
# --public # Register a public project, which can be viewed and forked by anyone.
|
110
119
|
#
|
111
120
|
def register
|
112
121
|
name = shift_argument
|
@@ -115,11 +124,20 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
115
124
|
end
|
116
125
|
validate_arguments!
|
117
126
|
|
127
|
+
if options[:public]
|
128
|
+
unless confirm("Public projects allow anyone to view and fork the code in this project\'s repository. Are you sure? (y/n)")
|
129
|
+
error("Mortar project was not registered")
|
130
|
+
end
|
131
|
+
is_private = false
|
132
|
+
else
|
133
|
+
is_private = true
|
134
|
+
end
|
135
|
+
|
118
136
|
if options[:embedded]
|
119
137
|
validate_project_name(name)
|
120
138
|
validate_project_structure()
|
121
139
|
|
122
|
-
register_project(name) do |project_result|
|
140
|
+
register_project(name, is_private) do |project_result|
|
123
141
|
initialize_embedded_project(project_result)
|
124
142
|
end
|
125
143
|
else
|
@@ -142,7 +160,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
142
160
|
end
|
143
161
|
end
|
144
162
|
|
145
|
-
register_project(name) do |project_result|
|
163
|
+
register_project(name, is_private) do |project_result|
|
146
164
|
git.remote_add("mortar", project_result['git_url'])
|
147
165
|
git.push_master
|
148
166
|
display "Your project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n\n"
|
data/lib/mortar/version.rb
CHANGED
@@ -98,7 +98,7 @@ STDOUT
|
|
98
98
|
project_id = "1234abcd1234abcd1234"
|
99
99
|
project_name = "some_new_project"
|
100
100
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
101
|
-
mock(Mortar::Auth.api).post_project("some_new_project") {Excon::Response.new(:body => {"project_id" => project_id})}
|
101
|
+
mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
|
102
102
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
|
103
103
|
"git_url" => project_git_url})).ordered
|
104
104
|
mock(@git).remotes.with_any_args.returns({})
|
@@ -171,7 +171,7 @@ STDOUT
|
|
171
171
|
project_id = "1234abcd1234abcd1234"
|
172
172
|
project_name = "some_new_project"
|
173
173
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
174
|
-
mock(Mortar::Auth.api).post_project("some_new_project") {Excon::Response.new(:body => {"project_id" => project_id})}
|
174
|
+
mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
|
175
175
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
|
176
176
|
"git_url" => project_git_url})).ordered
|
177
177
|
|
@@ -258,13 +258,49 @@ STDERR
|
|
258
258
|
STDERR
|
259
259
|
end
|
260
260
|
end
|
261
|
-
|
261
|
+
|
262
|
+
it "Confirms if user wants to create a public project, exits if not" do
|
263
|
+
project_name = "some_new_project"
|
264
|
+
any_instance_of(Mortar::Command::Projects) do |base|
|
265
|
+
mock(base).ask.with_any_args.times(1) { 'n' }
|
266
|
+
end
|
267
|
+
stderr, stdout = execute("projects:create #{project_name} --public", nil, @git)
|
268
|
+
stderr.should == <<-STDERR
|
269
|
+
! Mortar project was not registered
|
270
|
+
STDERR
|
271
|
+
end
|
272
|
+
|
273
|
+
it "Confirms if user wants to create a public project, creates it if so" do
|
274
|
+
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
275
|
+
project_id = "1234abcd1234abcd1234"
|
276
|
+
project_name = "some_new_project"
|
277
|
+
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
278
|
+
mock(Mortar::Auth.api).post_project("some_new_project", false) {Excon::Response.new(:body => {"project_id" => project_id})}
|
279
|
+
status = Mortar::API::Projects::STATUS_ACTIVE
|
280
|
+
response = Excon::Response.new(:body => {"status" => status, "git_url" => project_git_url})
|
281
|
+
mock(Mortar::Auth.api).get_project(project_id).returns(response).ordered
|
282
|
+
|
283
|
+
mock(@git).has_dot_git?().returns(true)
|
284
|
+
mock(@git).remotes.with_any_args.returns({})
|
285
|
+
mock(@git).remote_add("mortar", project_git_url)
|
286
|
+
mock(@git).push_master
|
287
|
+
any_instance_of(Mortar::Command::Projects) do |base|
|
288
|
+
mock(base).ask.with_any_args.times(1) { 'y' }
|
289
|
+
end
|
290
|
+
|
291
|
+
stderr, stdout = execute("projects:register #{project_name} --public", nil, @git)
|
292
|
+
stdout.should == <<-STDOUT
|
293
|
+
Public projects allow anyone to view and fork the code in this project's repository. Are you sure? (y/n) Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: ACTIVE \n\nYour project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n
|
294
|
+
STDOUT
|
295
|
+
end
|
296
|
+
|
297
|
+
|
262
298
|
it "register a new project successfully - with status" do
|
263
299
|
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
264
300
|
project_id = "1234abcd1234abcd1234"
|
265
301
|
project_name = "some_new_project"
|
266
302
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
267
|
-
mock(Mortar::Auth.api).post_project("some_new_project") {Excon::Response.new(:body => {"project_id" => project_id})}
|
303
|
+
mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
|
268
304
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_PENDING})).ordered
|
269
305
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_CREATING})).ordered
|
270
306
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
|
@@ -286,7 +322,7 @@ STDOUT
|
|
286
322
|
project_id = "1234abcd1234abcd1234"
|
287
323
|
project_name = "some_new_project"
|
288
324
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
289
|
-
mock(Mortar::Auth.api).post_project("some_new_project") {Excon::Response.new(:body => {"project_id" => project_id})}
|
325
|
+
mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
|
290
326
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Pending", "status_code" => Mortar::API::Projects::STATUS_PENDING})).ordered
|
291
327
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Creating", "status_code" => Mortar::API::Projects::STATUS_CREATING})).ordered
|
292
328
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Active", "status_code" => Mortar::API::Projects::STATUS_ACTIVE,
|
@@ -308,7 +344,7 @@ STDOUT
|
|
308
344
|
project_id = "1234abcd1234abcd1234"
|
309
345
|
project_name = "some_new_project"
|
310
346
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
311
|
-
mock(Mortar::Auth.api).post_project("some_new_project") {Excon::Response.new(:body => {"project_id" => project_id})}
|
347
|
+
mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
|
312
348
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Pending", "status_code" => Mortar::API::Projects::STATUS_PENDING})).ordered
|
313
349
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Creating", "status_code" => Mortar::API::Projects::STATUS_CREATING})).ordered
|
314
350
|
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Active", "status_code" => Mortar::API::Projects::STATUS_ACTIVE,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.8.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.8.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: netrc
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -337,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
337
337
|
version: '0'
|
338
338
|
requirements: []
|
339
339
|
rubyforge_project:
|
340
|
-
rubygems_version: 1.8.
|
340
|
+
rubygems_version: 1.8.24
|
341
341
|
signing_key:
|
342
342
|
specification_version: 3
|
343
343
|
summary: Client library and CLI to interact with the Mortar service.
|