strobe 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +69 -0
- data/Rakefile +36 -0
- data/bin/strobe +14 -0
- data/features/1_sign_up.feature +16 -0
- data/features/2_deploying.feature +35 -0
- data/features/3_deploying_sproutcore_apps.feature +19 -0
- data/features/step_definitions/cli_steps.rb +8 -0
- data/features/step_definitions/deploying_steps.rb +58 -0
- data/features/step_definitions/sign_up.rb +74 -0
- data/features/support/helpers.rb +104 -0
- data/features/support/strobe.rb +57 -0
- data/lib/strobe.rb +118 -0
- data/lib/strobe/account.rb +67 -0
- data/lib/strobe/cli.rb +78 -0
- data/lib/strobe/deploy.rb +131 -0
- data/lib/strobe/errors.rb +12 -0
- data/lib/strobe/http.rb +94 -0
- data/lib/strobe/server.rb +13 -0
- data/lib/strobe/settings.rb +56 -0
- data/lib/strobe/ui.rb +81 -0
- data/lib/strobe/user.rb +9 -0
- data/lib/strobe/version.rb +3 -0
- data/strobe.gemspec +35 -0
- metadata +250 -0
data/lib/strobe/http.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
class Strobe
|
2
|
+
class HTTP
|
3
|
+
def signup(email, pass)
|
4
|
+
body = {
|
5
|
+
:account => {:name => "default"},
|
6
|
+
:user => {:email => email, :password => pass}
|
7
|
+
}.to_json
|
8
|
+
|
9
|
+
response = http_request(
|
10
|
+
"POST",
|
11
|
+
Strobe.settings.url("accounts"),
|
12
|
+
{"Content-Type" => "application/json"},
|
13
|
+
body
|
14
|
+
)
|
15
|
+
|
16
|
+
# user, account, error
|
17
|
+
|
18
|
+
json = JSON.parse(response.body)
|
19
|
+
|
20
|
+
if error = json["error"]
|
21
|
+
return nil, nil, error_messages(error)
|
22
|
+
else
|
23
|
+
user = json["user"] && User.new(json["user"])
|
24
|
+
account = json["account"] ? Account.new(json["account"]) : true
|
25
|
+
errors = json["errors"] && error_messages(json["errors"])
|
26
|
+
return user, account, errors
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def login(email, pass)
|
31
|
+
response = http_request(
|
32
|
+
"GET",
|
33
|
+
Strobe.settings.url("account"),
|
34
|
+
{"Content-Type" => "application/json"}.merge(auth_header(email, pass))
|
35
|
+
)
|
36
|
+
|
37
|
+
json = JSON.parse(response.body)
|
38
|
+
|
39
|
+
if error = json["error"]
|
40
|
+
return nil, nil, "The email and password were invalid"
|
41
|
+
else
|
42
|
+
user = json["user"] && User.new(json["user"])
|
43
|
+
errors = json["errors"] && error_messages(json["errors"])
|
44
|
+
return user, nil, errors
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def deploy(deployment)
|
49
|
+
connection, method = Strobe.settings.app_connection_and_method
|
50
|
+
|
51
|
+
response = connection.request(
|
52
|
+
:method => method,
|
53
|
+
:headers => auth_header.merge(deployment.headers),
|
54
|
+
:body => deployment.body.force_encoding("BINARY")
|
55
|
+
)
|
56
|
+
|
57
|
+
json = JSON.parse(response.body)
|
58
|
+
|
59
|
+
if error = json["error"]
|
60
|
+
return nil, error
|
61
|
+
else
|
62
|
+
application = json["application"]
|
63
|
+
errors = json["errors"] && error_messages(json["errors"])
|
64
|
+
return application, errors
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def http_request(method, uri, headers = {}, body = nil)
|
70
|
+
connection = Excon::Connection.new(uri)
|
71
|
+
connection.request(:method => method, :headers => headers, :body => body)
|
72
|
+
end
|
73
|
+
|
74
|
+
def auth_header(username=Strobe.settings[:token], password=nil)
|
75
|
+
header = "Basic " << ["#{username}:#{password}"].pack("m")
|
76
|
+
header.gsub!(/\n/, '')
|
77
|
+
{"Authorization" => header}
|
78
|
+
end
|
79
|
+
|
80
|
+
def error_messages(errors)
|
81
|
+
messages = []
|
82
|
+
errors.each do |k, v|
|
83
|
+
if v
|
84
|
+
v.each do |field, error|
|
85
|
+
messages << " * #{field} #{error}"
|
86
|
+
end
|
87
|
+
else
|
88
|
+
messages << " * #{k}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
messages.join("\n")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "excon"
|
2
|
+
|
3
|
+
class Strobe
|
4
|
+
class Settings
|
5
|
+
def initialize
|
6
|
+
@location = ENV["STROBE_SETTINGS"] || Strobe.config_dir.join("config")
|
7
|
+
@local = ENV["STROBE_APP_CONFIG"] || Strobe.local_config_dir.join("config")
|
8
|
+
@hash = File.file?(@location) ? YAML.load(@location) : {}
|
9
|
+
@local_hash = File.file?(@local) ? YAML.load(@local) : {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](key)
|
13
|
+
ENV[key_for(key)] || @local_hash[key_for(key)] || @hash[key_for(key)]
|
14
|
+
end
|
15
|
+
|
16
|
+
def []=(key, value)
|
17
|
+
@hash[key_for(key)] = value
|
18
|
+
File.open(@location, "wb") { |file| file.puts @hash.to_yaml }
|
19
|
+
value
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_local(key, value)
|
23
|
+
@local_hash[key_for(key)] = value
|
24
|
+
File.open(@local, "wb") { |file| file.puts @local_hash.to_yaml }
|
25
|
+
end
|
26
|
+
|
27
|
+
def url(path)
|
28
|
+
self["url"] ||= "http://api.strobeapp.com/"
|
29
|
+
self["url"] + path
|
30
|
+
end
|
31
|
+
|
32
|
+
def auth_header(username=self[:token], password=nil)
|
33
|
+
header = "Basic " << ["#{username}:#{password}"].pack("m")
|
34
|
+
header.gsub!(/\n/, '')
|
35
|
+
{"Authorization" => header}
|
36
|
+
end
|
37
|
+
|
38
|
+
def app_connection_and_method
|
39
|
+
app_url = url("applications")
|
40
|
+
|
41
|
+
if application = self[:application]
|
42
|
+
app_url << "/#{application["id"]}"
|
43
|
+
method = "PUT"
|
44
|
+
else
|
45
|
+
method = "POST"
|
46
|
+
end
|
47
|
+
|
48
|
+
return Excon::Connection.new(app_url), method
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def key_for(key)
|
53
|
+
"STROBE_#{key.to_s.upcase}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/strobe/ui.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require "highline"
|
2
|
+
|
3
|
+
class Strobe
|
4
|
+
module UI
|
5
|
+
class Basic
|
6
|
+
def debug(msg)
|
7
|
+
puts msg
|
8
|
+
end
|
9
|
+
|
10
|
+
def info(msg)
|
11
|
+
puts msg
|
12
|
+
end
|
13
|
+
|
14
|
+
def confirm(msg)
|
15
|
+
puts msg
|
16
|
+
end
|
17
|
+
|
18
|
+
def warn(msg)
|
19
|
+
puts msg
|
20
|
+
end
|
21
|
+
|
22
|
+
def error(msg)
|
23
|
+
puts msg
|
24
|
+
end
|
25
|
+
|
26
|
+
def highline
|
27
|
+
@highline ||= HighLine.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def password(message)
|
31
|
+
highline.ask(message) do |q|
|
32
|
+
next unless STDIN.tty?
|
33
|
+
q.echo = "*"
|
34
|
+
end
|
35
|
+
rescue EOFError
|
36
|
+
''
|
37
|
+
end
|
38
|
+
|
39
|
+
def ask(message)
|
40
|
+
highline.ask(message) do |q|
|
41
|
+
next unless STDIN.tty?
|
42
|
+
q.readline = true
|
43
|
+
end
|
44
|
+
rescue EOFError
|
45
|
+
''
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Shell < Basic
|
50
|
+
def initialize(shell)
|
51
|
+
@shell = shell
|
52
|
+
@quiet = false
|
53
|
+
end
|
54
|
+
|
55
|
+
def debug(msg)
|
56
|
+
@shell.say(msg) if ENV['DEBUG'] && !@quiet
|
57
|
+
end
|
58
|
+
|
59
|
+
def info(msg)
|
60
|
+
@shell.say(msg) if !@quiet
|
61
|
+
end
|
62
|
+
|
63
|
+
def confirm(msg)
|
64
|
+
@shell.say(msg, :green) if !@quiet
|
65
|
+
end
|
66
|
+
|
67
|
+
def warn(msg)
|
68
|
+
@shell.say(msg, :yellow)
|
69
|
+
end
|
70
|
+
|
71
|
+
def error(msg)
|
72
|
+
@shell.say(msg, :red)
|
73
|
+
end
|
74
|
+
|
75
|
+
def be_quiet!
|
76
|
+
@quiet = true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
data/lib/strobe/user.rb
ADDED
data/strobe.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "strobe/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "strobe"
|
7
|
+
s.version = Strobe::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Yehuda Katz", "Carl Lerche"]
|
10
|
+
s.email = ["wycats@strobecorp.com", "carllerche@strobecorp.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/strobe"
|
12
|
+
s.summary = "A deployment tool for HTML5 applications"
|
13
|
+
s.description = "The client library for deploying applications to Strobe's HTML5 deployment platform"
|
14
|
+
|
15
|
+
s.required_rubygems_version = ">= 1.3.6"
|
16
|
+
s.rubyforge_project = "strobe"
|
17
|
+
|
18
|
+
s.add_runtime_dependency "thor", "~> 0.14.1"
|
19
|
+
s.add_runtime_dependency "rack", "~> 1.2.1"
|
20
|
+
s.add_runtime_dependency "highline", "~> 1.6.1"
|
21
|
+
s.add_runtime_dependency "excon", "~> 0.2.2"
|
22
|
+
s.add_runtime_dependency "mime-types", "= 1.16"
|
23
|
+
s.add_runtime_dependency "activesupport", "~> 3.0.0"
|
24
|
+
|
25
|
+
s.add_development_dependency "rake"
|
26
|
+
s.add_development_dependency "rspec", "~> 2.0.0"
|
27
|
+
s.add_development_dependency "childlabor", "0.0.3"
|
28
|
+
s.add_development_dependency "cucumber"
|
29
|
+
s.add_development_dependency "prawn"
|
30
|
+
|
31
|
+
s.files = `git ls-files`.split("\n")
|
32
|
+
s.executables = `git ls-files bin`.split("\n").map{ |file| File.basename(file) }
|
33
|
+
s.require_path = 'lib'
|
34
|
+
end
|
35
|
+
|
metadata
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: strobe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Yehuda Katz
|
13
|
+
- Carl Lerche
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-14 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thor
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 14
|
32
|
+
- 1
|
33
|
+
version: 0.14.1
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rack
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 2
|
47
|
+
- 1
|
48
|
+
version: 1.2.1
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: highline
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 6
|
62
|
+
- 1
|
63
|
+
version: 1.6.1
|
64
|
+
type: :runtime
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: excon
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 2
|
77
|
+
- 2
|
78
|
+
version: 0.2.2
|
79
|
+
type: :runtime
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: mime-types
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - "="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 1
|
91
|
+
- 16
|
92
|
+
version: "1.16"
|
93
|
+
type: :runtime
|
94
|
+
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: activesupport
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
segments:
|
104
|
+
- 3
|
105
|
+
- 0
|
106
|
+
- 0
|
107
|
+
version: 3.0.0
|
108
|
+
type: :runtime
|
109
|
+
version_requirements: *id006
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
prerelease: false
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
type: :development
|
122
|
+
version_requirements: *id007
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: rspec
|
125
|
+
prerelease: false
|
126
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 2
|
133
|
+
- 0
|
134
|
+
- 0
|
135
|
+
version: 2.0.0
|
136
|
+
type: :development
|
137
|
+
version_requirements: *id008
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: childlabor
|
140
|
+
prerelease: false
|
141
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - "="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
- 0
|
149
|
+
- 3
|
150
|
+
version: 0.0.3
|
151
|
+
type: :development
|
152
|
+
version_requirements: *id009
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: cucumber
|
155
|
+
prerelease: false
|
156
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
version: "0"
|
164
|
+
type: :development
|
165
|
+
version_requirements: *id010
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
name: prawn
|
168
|
+
prerelease: false
|
169
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
segments:
|
175
|
+
- 0
|
176
|
+
version: "0"
|
177
|
+
type: :development
|
178
|
+
version_requirements: *id011
|
179
|
+
description: The client library for deploying applications to Strobe's HTML5 deployment platform
|
180
|
+
email:
|
181
|
+
- wycats@strobecorp.com
|
182
|
+
- carllerche@strobecorp.com
|
183
|
+
executables:
|
184
|
+
- strobe
|
185
|
+
extensions: []
|
186
|
+
|
187
|
+
extra_rdoc_files: []
|
188
|
+
|
189
|
+
files:
|
190
|
+
- .gitignore
|
191
|
+
- Gemfile
|
192
|
+
- Gemfile.lock
|
193
|
+
- Rakefile
|
194
|
+
- bin/strobe
|
195
|
+
- features/1_sign_up.feature
|
196
|
+
- features/2_deploying.feature
|
197
|
+
- features/3_deploying_sproutcore_apps.feature
|
198
|
+
- features/step_definitions/cli_steps.rb
|
199
|
+
- features/step_definitions/deploying_steps.rb
|
200
|
+
- features/step_definitions/sign_up.rb
|
201
|
+
- features/support/helpers.rb
|
202
|
+
- features/support/strobe.rb
|
203
|
+
- lib/strobe.rb
|
204
|
+
- lib/strobe/account.rb
|
205
|
+
- lib/strobe/cli.rb
|
206
|
+
- lib/strobe/deploy.rb
|
207
|
+
- lib/strobe/errors.rb
|
208
|
+
- lib/strobe/http.rb
|
209
|
+
- lib/strobe/server.rb
|
210
|
+
- lib/strobe/settings.rb
|
211
|
+
- lib/strobe/ui.rb
|
212
|
+
- lib/strobe/user.rb
|
213
|
+
- lib/strobe/version.rb
|
214
|
+
- strobe.gemspec
|
215
|
+
has_rdoc: true
|
216
|
+
homepage: http://rubygems.org/gems/strobe
|
217
|
+
licenses: []
|
218
|
+
|
219
|
+
post_install_message:
|
220
|
+
rdoc_options: []
|
221
|
+
|
222
|
+
require_paths:
|
223
|
+
- lib
|
224
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
segments:
|
230
|
+
- 0
|
231
|
+
version: "0"
|
232
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
segments:
|
238
|
+
- 1
|
239
|
+
- 3
|
240
|
+
- 6
|
241
|
+
version: 1.3.6
|
242
|
+
requirements: []
|
243
|
+
|
244
|
+
rubyforge_project: strobe
|
245
|
+
rubygems_version: 1.3.7
|
246
|
+
signing_key:
|
247
|
+
specification_version: 3
|
248
|
+
summary: A deployment tool for HTML5 applications
|
249
|
+
test_files: []
|
250
|
+
|