strobe 0.1.1 → 0.1.2

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.
@@ -1,5 +1,55 @@
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
3
53
 
4
54
  def help(*args)
5
55
  if args.first == "users"
@@ -89,51 +139,13 @@ module Strobe
89
139
 
90
140
  run_sc_build
91
141
 
92
- if STDOUT.tty?
93
- thread = nil
94
- read, write = IO.pipe
95
-
96
- upload_callback = lambda do |percentage|
97
- if percentage
98
- width = 50
99
- left = ( percentage * width ).round
100
- right = ( ( 1.0 - percentage ) * width ).round
101
-
102
- if left < width
103
- right -= 1
104
- arrow = ">"
105
- end
106
-
107
- print "Uploading [#{'=' * left}#{arrow}#{' ' * right}]\r"
108
- else
109
- puts
110
- thread = Thread.new do
111
- print "Reticulating splines..."
112
-
113
- while true
114
- break if IO.select( [read ], nil, nil, 0.5 )
115
- print "."
116
- end
117
-
118
- puts
119
- end
120
- end
121
- end
122
- else
123
- upload_callback = nil
124
- end
125
-
126
142
  host = resource.deploy! :environment => options[:staging] && 'staging',
127
- :upload_callback => upload_callback
128
-
129
- if STDOUT.tty?
130
- write << '1'
131
- thread.join
132
- end
143
+ :callback => DeployProgress.new
133
144
 
134
145
  say "The application has successfully been deployed and is available at #{host}"
135
146
  end
136
147
 
148
+
137
149
  action "applications", "list all of your applications" do
138
150
  empty = "You do not have any applications. Try deploying one with `strobe deploy`."
139
151
  list_applications :empty => empty
@@ -211,7 +223,7 @@ module Strobe
211
223
  end
212
224
 
213
225
  def is_sproutcore?
214
- File.exist?("#{path}/tmp/build")
226
+ File.exist?("#{path}/Buildfile")
215
227
  end
216
228
 
217
229
  def determine_application_root
@@ -18,13 +18,16 @@ module Strobe
18
18
  def deploy!(opts = {})
19
19
  self['path'] = opts[:path] if opts[:path]
20
20
  environment = opts[:environment]
21
+ callback = opts[:callback]
21
22
 
22
23
  validate_for_deploy or return
23
24
 
24
25
  request do
25
26
  qs = "?environment=#{environment}" if environment
26
27
  packfile = build_packfile(opts)
27
- connection.put("#{http_uri}/deploy#{qs}", packfile, packfile.headers)
28
+ response = connection.put("#{http_uri}/deploy#{qs}", packfile, packfile.headers)
29
+ callback.deploy_complete if callback
30
+ response
28
31
  end
29
32
 
30
33
  [ environment, self['url'] ].compact.join('.')
@@ -101,6 +104,7 @@ module Strobe
101
104
  def initialize(opts)
102
105
  @opts = opts
103
106
  @files = []
107
+ @callback = opts[:callback]
104
108
  end
105
109
 
106
110
  def file(path, content_type, body)
@@ -120,8 +124,10 @@ module Strobe
120
124
  def read(*args)
121
125
  ret = to_io.read(*args)
122
126
 
123
- if callback = @opts[:upload_callback]
124
- ret ? callback.call(pos.to_f / size.to_f) : callback.call(nil)
127
+ if @callback && ret
128
+ @callback.upload_progress(pos.to_f / size.to_f)
129
+ elsif @callback
130
+ @callback.upload_complete
125
131
  end
126
132
 
127
133
  ret
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Yehuda Katz