strobe 0.1.2 → 0.1.3
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/strobe/cli/deploy_progress.rb +42 -0
- data/lib/strobe/cli/main.rb +10 -53
- data/lib/strobe/cli/preview.rb +42 -0
- data/lib/strobe/cli/settings.rb +3 -3
- data/lib/strobe/cli/ticker.rb +44 -0
- data/lib/strobe/cli.rb +11 -6
- data/lib/strobe/resources/signup.rb +8 -5
- data/lib/strobe/resources.rb +13 -0
- data/lib/strobe.rb +1 -11
- metadata +29 -10
@@ -0,0 +1,42 @@
|
|
1
|
+
module Strobe
|
2
|
+
class CLI::DeployProgress
|
3
|
+
def initialize
|
4
|
+
@thread = nil
|
5
|
+
@width = 50
|
6
|
+
@current = 0
|
7
|
+
@ticker = CLI::Ticker.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def upload_progress(percentage)
|
11
|
+
width = 50
|
12
|
+
left = ( percentage * width ).round
|
13
|
+
|
14
|
+
return if @current == left
|
15
|
+
|
16
|
+
(@current..left).each do |i|
|
17
|
+
arrow = nil
|
18
|
+
right = width - i
|
19
|
+
|
20
|
+
if i < width
|
21
|
+
right -= 1
|
22
|
+
arrow = ">"
|
23
|
+
end
|
24
|
+
|
25
|
+
print "Uploading [#{ '=' * i }#{ arrow }#{' ' * right}]\r"
|
26
|
+
end
|
27
|
+
|
28
|
+
@current = left
|
29
|
+
end
|
30
|
+
|
31
|
+
def upload_complete
|
32
|
+
upload_progress(1.0)
|
33
|
+
print "\n"
|
34
|
+
|
35
|
+
@ticker.tick "Reticulating splines"
|
36
|
+
end
|
37
|
+
|
38
|
+
def deploy_complete
|
39
|
+
@ticker.stop
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/strobe/cli/main.rb
CHANGED
@@ -1,56 +1,5 @@
|
|
1
1
|
module Strobe
|
2
2
|
class CLI::Main < CLI
|
3
|
-
class DeployProgress
|
4
|
-
def initialize
|
5
|
-
@thread = nil
|
6
|
-
@width = 50
|
7
|
-
@current = 0
|
8
|
-
@read, @write = IO.pipe
|
9
|
-
end
|
10
|
-
|
11
|
-
def upload_progress(percentage)
|
12
|
-
width = 50
|
13
|
-
left = ( percentage * width ).round
|
14
|
-
|
15
|
-
return if @current == left
|
16
|
-
|
17
|
-
(@current..left).each do |i|
|
18
|
-
arrow = nil
|
19
|
-
right = width - i
|
20
|
-
|
21
|
-
if i < width
|
22
|
-
right -= 1
|
23
|
-
arrow = ">"
|
24
|
-
end
|
25
|
-
|
26
|
-
print "Uploading [#{ '=' * i }#{ arrow }#{' ' * right}]\r"
|
27
|
-
end
|
28
|
-
|
29
|
-
@current = left
|
30
|
-
end
|
31
|
-
|
32
|
-
def upload_complete
|
33
|
-
upload_progress(1.0)
|
34
|
-
print "\n"
|
35
|
-
|
36
|
-
@thread = Thread.new do
|
37
|
-
print "Reticulating splines..."
|
38
|
-
|
39
|
-
while true
|
40
|
-
break if IO.select( [ @read ], nil, nil, 0.5 )
|
41
|
-
print "."
|
42
|
-
end
|
43
|
-
|
44
|
-
puts
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def deploy_complete
|
49
|
-
@write << '1'
|
50
|
-
@thread.join
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
3
|
def help(*args)
|
55
4
|
if args.first == "users"
|
56
5
|
CLI::Users.start( [ "help" ] + args[1..-1] )
|
@@ -121,6 +70,14 @@ module Strobe
|
|
121
70
|
|
122
71
|
if application_id = config[:application_id]
|
123
72
|
resource Application.get! application_id, :lazy => true
|
73
|
+
|
74
|
+
host = resource[:url]
|
75
|
+
host = "staging.#{host}" if options[:staging]
|
76
|
+
|
77
|
+
unless agree "Deploying '#{resource[:name]}' to http://#{host}, continue? [Yn] "
|
78
|
+
say "exiting..."
|
79
|
+
exit
|
80
|
+
end
|
124
81
|
else
|
125
82
|
resource Account.first.applications.new
|
126
83
|
end
|
@@ -140,7 +97,7 @@ module Strobe
|
|
140
97
|
run_sc_build
|
141
98
|
|
142
99
|
host = resource.deploy! :environment => options[:staging] && 'staging',
|
143
|
-
:callback => DeployProgress.new
|
100
|
+
:callback => CLI::DeployProgress.new
|
144
101
|
|
145
102
|
say "The application has successfully been deployed and is available at #{host}"
|
146
103
|
end
|
@@ -217,7 +174,7 @@ module Strobe
|
|
217
174
|
return unless agree "Run `sc-build -c`? [Yn] "
|
218
175
|
end
|
219
176
|
|
220
|
-
unless system "sc-build", "-c"
|
177
|
+
unless CLI::Ticker.tick("Running `sc-build -c`", 2) { system "sc-build", "-c" }
|
221
178
|
error! "Something went wrong while running `sc-build -c`"
|
222
179
|
end
|
223
180
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module Strobe
|
4
|
+
module CLI::Preview
|
5
|
+
class Server < Rack::Server
|
6
|
+
def app
|
7
|
+
options[:app]
|
8
|
+
end
|
9
|
+
|
10
|
+
alias wrapped_app app
|
11
|
+
end
|
12
|
+
|
13
|
+
class MagicWrapper
|
14
|
+
def initialize(app)
|
15
|
+
@app = app
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
puts "ZOMGZOMG, calling: #{env['PATH_INFO']}"
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def sproutcore_app
|
27
|
+
gem "sproutcore", ">= 1.4.0"
|
28
|
+
require "sproutcore"
|
29
|
+
|
30
|
+
project = SC::Tools.new.requires_project!
|
31
|
+
SC::Rack::Service.new(*project)
|
32
|
+
end
|
33
|
+
|
34
|
+
def wrap(app)
|
35
|
+
MagicWrapper.new(app)
|
36
|
+
end
|
37
|
+
|
38
|
+
def preview_sproutcore_application
|
39
|
+
Server.start :app => wrap(sproutcore_app), :Port => 9292
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/strobe/cli/settings.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Strobe
|
2
|
+
class CLI::Ticker
|
3
|
+
def self.tick(msg, interval = 0.5)
|
4
|
+
ticker = new
|
5
|
+
ticker.tick(msg, interval)
|
6
|
+
return ticker unless block_given?
|
7
|
+
yield
|
8
|
+
ensure
|
9
|
+
ticker.stop
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@thread
|
14
|
+
@read, @write = IO.pipe
|
15
|
+
end
|
16
|
+
|
17
|
+
def tick(msg, interval = 0.5)
|
18
|
+
@thread = Thread.new do
|
19
|
+
print "#{msg}..."
|
20
|
+
|
21
|
+
while true
|
22
|
+
break if IO.select( [ @read ], nil, nil, interval )
|
23
|
+
print "."
|
24
|
+
end
|
25
|
+
|
26
|
+
@read.read
|
27
|
+
@read.close
|
28
|
+
|
29
|
+
puts
|
30
|
+
end
|
31
|
+
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def stop
|
36
|
+
raise "Ticker is not ticking" unless @thread
|
37
|
+
|
38
|
+
@write << '1'
|
39
|
+
@write.close
|
40
|
+
@thread.join
|
41
|
+
true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/strobe/cli.rb
CHANGED
@@ -5,14 +5,18 @@ require 'highline'
|
|
5
5
|
|
6
6
|
module Strobe
|
7
7
|
class CLI < Thor
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
11
|
-
autoload :
|
8
|
+
autoload :DeployProgress, 'strobe/cli/deploy_progress'
|
9
|
+
autoload :Main, 'strobe/cli/main'
|
10
|
+
autoload :Preview, 'strobe/cli/preview'
|
11
|
+
autoload :Settings, 'strobe/cli/settings'
|
12
|
+
autoload :Table, 'strobe/cli/table'
|
13
|
+
autoload :Ticker, 'strobe/cli/ticker'
|
14
|
+
autoload :Users, 'strobe/cli/users'
|
12
15
|
|
13
16
|
include Resources
|
14
17
|
|
15
18
|
class_option "backtrace", :type => :boolean
|
19
|
+
class_option "yes", :type => :boolean, :aliases => "-y", :banner => "answer yes to all confirmation questions"
|
16
20
|
|
17
21
|
def self.start(args)
|
18
22
|
$ARGV = args
|
@@ -112,8 +116,8 @@ module Strobe
|
|
112
116
|
end
|
113
117
|
end
|
114
118
|
|
115
|
-
def say(
|
116
|
-
puts
|
119
|
+
def say(*args)
|
120
|
+
puts(*args)
|
117
121
|
end
|
118
122
|
|
119
123
|
def error(what)
|
@@ -125,6 +129,7 @@ module Strobe
|
|
125
129
|
end
|
126
130
|
|
127
131
|
def agree(msg, *args)
|
132
|
+
return true if options[:yes]
|
128
133
|
@highline.agree(msg, *args) do |q|
|
129
134
|
next unless STDIN.tty? # For testing
|
130
135
|
q.readline = true
|
@@ -9,18 +9,21 @@ module Strobe
|
|
9
9
|
filter :password_confirmation
|
10
10
|
|
11
11
|
validates "user", "account", :presence => true
|
12
|
-
validates "user.password", :
|
13
|
-
:length => { :minimum => 5 }, :with => :password_confirmation
|
12
|
+
validates "user.password", :with => :validate_password
|
14
13
|
|
15
14
|
private
|
16
15
|
|
17
|
-
def
|
16
|
+
def validate_password
|
18
17
|
password = self["user.password"]
|
19
18
|
confirmation = self["password_confirmation"]
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
msg = case
|
21
|
+
when password.blank? then "can't be blank"
|
22
|
+
when password.length < 5 then "is too short (minimum is 5 characters)"
|
23
|
+
when password != confirmation then "and confirmation do not match"
|
23
24
|
end
|
25
|
+
|
26
|
+
errors.add "user.password", msg if msg
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Strobe
|
2
|
+
# Resources
|
3
|
+
module Resources
|
4
|
+
require 'strobe/resources/account'
|
5
|
+
require 'strobe/resources/application'
|
6
|
+
require 'strobe/resources/assignment'
|
7
|
+
require 'strobe/resources/me'
|
8
|
+
require 'strobe/resources/membership'
|
9
|
+
require 'strobe/resources/signup'
|
10
|
+
require 'strobe/resources/team'
|
11
|
+
require 'strobe/resources/user'
|
12
|
+
end
|
13
|
+
end
|
data/lib/strobe.rb
CHANGED
@@ -14,6 +14,7 @@ module Strobe
|
|
14
14
|
autoload :Connection, 'strobe/connection'
|
15
15
|
autoload :IdentityMap, 'strobe/identity_map'
|
16
16
|
autoload :Key, 'strobe/key'
|
17
|
+
autoload :Resources, 'strobe/resources'
|
17
18
|
autoload :Validations, 'strobe/validations'
|
18
19
|
|
19
20
|
module Resource
|
@@ -22,17 +23,6 @@ module Strobe
|
|
22
23
|
autoload :Singleton, 'strobe/resource/singleton'
|
23
24
|
end
|
24
25
|
|
25
|
-
# Resources
|
26
|
-
module Resources
|
27
|
-
autoload :Account, 'strobe/resources/account'
|
28
|
-
autoload :Application, 'strobe/resources/application'
|
29
|
-
autoload :Assignment, 'strobe/resources/assignment'
|
30
|
-
autoload :Me, 'strobe/resources/me'
|
31
|
-
autoload :Membership, 'strobe/resources/membership'
|
32
|
-
autoload :Signup, 'strobe/resources/signup'
|
33
|
-
autoload :Team, 'strobe/resources/team'
|
34
|
-
autoload :User, 'strobe/resources/user'
|
35
|
-
end
|
36
26
|
|
37
27
|
# Errors
|
38
28
|
class StrobeError < StandardError ; end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yehuda Katz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-05 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
type: :runtime
|
50
50
|
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
-
name:
|
52
|
+
name: mime-types
|
53
53
|
prerelease: false
|
54
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
- - ~>
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
segments:
|
60
|
+
- 1
|
61
|
+
- 16
|
60
62
|
- 0
|
61
|
-
|
62
|
-
- 0
|
63
|
-
version: 0.14.0
|
63
|
+
version: 1.16.0
|
64
64
|
type: :runtime
|
65
65
|
version_requirements: *id003
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
|
-
name:
|
67
|
+
name: rack
|
68
68
|
prerelease: false
|
69
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
70
|
none: false
|
@@ -73,11 +73,26 @@ dependencies:
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
segments:
|
75
75
|
- 1
|
76
|
-
-
|
76
|
+
- 2
|
77
77
|
- 0
|
78
|
-
version: 1.
|
78
|
+
version: 1.2.0
|
79
79
|
type: :runtime
|
80
80
|
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: thor
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
- 14
|
92
|
+
- 0
|
93
|
+
version: 0.14.0
|
94
|
+
type: :runtime
|
95
|
+
version_requirements: *id005
|
81
96
|
description: The client library for deploying applications to Strobe's HTML5 deployment platform
|
82
97
|
email:
|
83
98
|
- wycats@strobecorp.com
|
@@ -90,9 +105,12 @@ extra_rdoc_files: []
|
|
90
105
|
|
91
106
|
files:
|
92
107
|
- lib/strobe/association.rb
|
108
|
+
- lib/strobe/cli/deploy_progress.rb
|
93
109
|
- lib/strobe/cli/main.rb
|
110
|
+
- lib/strobe/cli/preview.rb
|
94
111
|
- lib/strobe/cli/settings.rb
|
95
112
|
- lib/strobe/cli/table.rb
|
113
|
+
- lib/strobe/cli/ticker.rb
|
96
114
|
- lib/strobe/cli/users.rb
|
97
115
|
- lib/strobe/cli.rb
|
98
116
|
- lib/strobe/collection.rb
|
@@ -110,6 +128,7 @@ files:
|
|
110
128
|
- lib/strobe/resources/signup.rb
|
111
129
|
- lib/strobe/resources/team.rb
|
112
130
|
- lib/strobe/resources/user.rb
|
131
|
+
- lib/strobe/resources.rb
|
113
132
|
- lib/strobe/validations.rb
|
114
133
|
- lib/strobe.rb
|
115
134
|
- bin/strobe
|