nimbu 0.8.4 → 0.9.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 632e1ce6c503da481ef978da3bb75c0d25c95783
4
- data.tar.gz: 74a79e1a486ca3ce6b25d693dcdb99239a5be973
3
+ metadata.gz: 7dbe608933863fe8ae8c081b13333a4c2a28232b
4
+ data.tar.gz: 0b1218097cfadb593d8489304a796f18713c52c2
5
5
  SHA512:
6
- metadata.gz: 7b7916b73d51d9f8bd9487c1133f333a22669dcee6cba3f1a2c54ac7979fde553fc457615cc135ecda96d973a62b064dc941035cd43e244663b785ccd95e8e02
7
- data.tar.gz: 91b6a26f7ef1746cba7dee9752c5cec9ec20cf900e33ee6bbfb1383884d5a213d2e0ce2d072bbd41ac13b60b62d6b91611816a838bafe19ed2958ce43e95b0e9
6
+ metadata.gz: b6916136b0247fb8095cec786c9d41a059d27c7a528ac25a816fe87e027326e5562bbea0cd7739e94c40815d0126bef0df685e7329b0221468db3832a2dc46ac
7
+ data.tar.gz: ee250cb7bae46aecea5d389c916500cb43a6bf844b0fd95a8a6e1d0f86f28ff09bda128480387706d78c6d576808aebad05f4f440eecccb96cee7c96ea02b799
data/lib/nimbu/auth.rb CHANGED
@@ -248,7 +248,7 @@ class Nimbu::Auth
248
248
  char = nil
249
249
  password = ''
250
250
 
251
- while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
251
+ while char = Win32API.new("msvcrt", "_getch", [ ], "L").Call do
252
252
  break if char == 10 || char == 13 # received carriage return or newline
253
253
  if char == 127 || char == 8 # backspace and delete
254
254
  password.slice!(-1, 1)
@@ -25,139 +25,196 @@ class Nimbu::Command::Server < Nimbu::Command::Base
25
25
  if !Nimbu::Auth.read_configuration || !Nimbu::Auth.read_credentials
26
26
  print red(bold("ERROR")), ": this directory does not seem to contain any Nimbu theme or your credentials are not set. \n ==> Run \"", bold { "nimbu init"}, "\" to initialize this directory."
27
27
  else
28
- no_compilation = true #! options[:'no-compile']
29
- with_haml = options[:haml]
30
- with_compass = options[:compass] || options[:c]
31
- no_cookies = options[:nocookies]
32
- webpack_resources = options[:webpack]
33
- webpack_url = options[:webpackurl]
34
-
35
- if no_cookies
28
+ @with_haml = options[:haml]
29
+ @with_compass = options[:compass] || options[:c]
30
+ @no_cookies = options[:nocookies]
31
+ @webpack_resources = options[:webpack]
32
+ @webpack_url = options[:webpackurl]
33
+
34
+ if @no_cookies
36
35
  Nimbu.cli_options[:nocookies] = true
37
36
  end
38
37
 
39
- if webpack_resources
40
- Nimbu.cli_options[:webpack_resources] = webpack_resources.split(",").map(&:strip)
41
- if webpack_url
42
- Nimbu.cli_options[:webpack_url] = webpack_url
38
+ if @webpack_resources
39
+ Nimbu.cli_options[:webpack_resources] = @webpack_resources.split(",").map(&:strip)
40
+ if @webpack_url
41
+ Nimbu.cli_options[:webpack_url] = @webpack_url
43
42
  else
44
43
  Nimbu.cli_options[:webpack_url] = "http://localhost:8080"
45
44
  end
46
45
  end
47
46
 
48
- if with_compass
47
+ if @with_compass
49
48
  require 'compass'
50
49
  require 'compass/exec'
51
50
  end
52
51
 
53
- if with_haml
52
+ if @with_haml
54
53
  require 'haml'
55
54
  end
56
55
 
57
56
  services = []
58
- services << "HAML" if with_haml
59
- services << "Compass" if with_compass
57
+ services << "HAML" if @with_haml
58
+ services << "Compass" if @with_compass
60
59
  title = "Starting up Nimbu Server"
61
- title << " (with local #{services.join(' and ')} watcher)" if with_compass || with_haml
62
- title << " (skipping cookies check)" if no_cookies
63
- title << " (proxying webpack resources to #{Nimbu.cli_options[:webpack_url]})" if webpack_resources
60
+ title << " (with local #{services.join(' and ')} watcher)" if @with_compass || @with_haml
61
+ title << " (skipping cookies check)" if @no_cookies
62
+ title << " (proxying webpack resources to #{Nimbu.cli_options[:webpack_url]})" if @webpack_resources
64
63
  title << " ..."
65
64
  puts white("\n#{title}")
66
65
  puts green(nimbu_header)
67
66
  puts green("\nConnnected to '#{Nimbu::Auth.site}.#{Nimbu::Auth.admin_host}', using '#{Nimbu::Auth.theme}' theme#{Nimbu.debug ? ' (in debug mode)'.red : nil}.\n")
68
67
 
69
- server_read, server_write = IO::pipe
70
- haml_read, haml_write = IO::pipe
71
- compass_read, compass_write = IO::pipe
72
- compiler_read, compiler_write = IO::pipe
73
-
74
- server_pid = Process.fork do
75
- $stdout.reopen(server_write)
76
- server_read.close
77
- puts "Starting server..."
78
- server_options = {
79
- :Port => options[:port] || 4567,
80
- :DocumentRoot => Dir.pwd
81
- }
82
- Rack::Handler::Thin.run Nimbu::Server::Base, server_options do |server|
83
- [:INT, :TERM].each { |sig| trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop } }
84
- end
68
+ if Nimbu::Helpers.running_on_windows?
69
+ run_on_windows!
70
+ else
71
+ run_on_unix!
85
72
  end
73
+ end
74
+ end
86
75
 
87
- # assets_pid = Process.fork do
88
- # $stdout.reopen(compiler_write)
89
- # compiler_read.close
90
- # puts "Starting watcher..."
91
- # HamlWatcher.watch
92
- # end unless no_compilation
93
-
94
- haml_pid = Process.fork do
95
- $stdout.reopen(haml_write)
96
- haml_read.close
97
- puts "Starting..."
98
- haml_listener = HamlWatcher.watch
99
- [:INT, :TERM].each do |sig|
100
- Signal.trap(sig) do
101
- puts green("== Stopping HAML watcher\n")
102
- Thread.new { haml_listener.stop }
103
- end
104
- end
76
+ def bare
77
+ puts "Starting server..."
78
+ server_options = {
79
+ :Port => options[:port] || 4567,
80
+ :DocumentRoot => Dir.pwd
81
+ }
82
+ Rack::Handler::Thin.run Nimbu::Server::Base, server_options do |server|
83
+ [:INT, :TERM].each { |sig| trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop } }
84
+ end
85
+ end
86
+
87
+ def haml
88
+ require 'haml'
89
+ puts "Starting..."
90
+ haml_listener = HamlWatcher.watch
91
+ sleep
92
+ end
93
+
94
+ def compass
95
+ require 'compass'
96
+ require 'compass/exec'
97
+ Compass::Exec::SubCommandUI.new(["watch","."]).run!
98
+ end
99
+
100
+ protected
101
+
102
+ def run_on_windows!
103
+ server_thread = Thread.new do
104
+ Thread.current[:stdout] = StringIO.new
105
+ puts "Starting server..."
106
+ server_options = {
107
+ :Port => options[:port] || 4567,
108
+ :DocumentRoot => Dir.pwd
109
+ }
110
+ Rack::Handler::Thin.run Nimbu::Server::Base, server_options do |server|
111
+ [:INT, :TERM].each { |sig| trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop } }
112
+ end
113
+ end
114
+
115
+ haml_thread = Thread.new do
116
+ # $stdout.reopen(compiler_write)
117
+ # compiler_read.close
118
+ puts "Starting watcher..."
119
+ HamlWatcher.watch
120
+ end if @with_haml
121
+
122
+ if @with_compass
123
+ puts "Starting..."
124
+ cmd = "bundle exec nimbu server:compass"
125
+ compass_pid = Process.spawn(cmd, out: $stdout, err: [:child, :out])
126
+ end
127
+
128
+ server_thread.join
129
+ haml_thread.join if @with_haml
130
+
131
+ [:INT, :TERM].each do |sig|
132
+ trap(sig) do
133
+ puts yellow("\n== Waiting for all processes to finish...")
134
+ Process.kill('INT', compass_pid) if compass_pid && running?(compass_pid)
105
135
  Process.waitall
106
- end if with_haml
107
-
108
- compass_pid = Process.fork do
109
- $stdout.reopen(compass_write)
110
- compass_read.close
111
- puts "Starting..."
112
- Compass::Exec::SubCommandUI.new(["watch","."]).run!
113
- end if with_compass
114
-
115
- watch_server_pid = Process.fork do
116
- trap('INT') { exit }
117
- server_write.close
118
- server_read.each do |line|
119
- print cyan("SERVER: ") + white(line) + ""
120
- end
136
+ puts green("== Nimbu has ended its work " + bold("(crowd applauds!)\n"))
121
137
  end
138
+ end
122
139
 
123
- # watch_assets_pid = Process.fork do
124
- # trap('INT') { exit }
125
- # compiler_write.close
126
- # compiler_read.each do |line|
127
- # print magenta("ASSETS: ") + white(line) + ""
128
- # end
129
- # end unless no_compilation
130
-
131
- watch_haml_pid = Process.fork do
132
- trap('INT') { exit }
133
- haml_write.close
134
- haml_read.each do |line|
135
- print magenta("HAML: ") + white(line) + ""
136
- end
137
- end if with_haml
140
+ Process.waitall
141
+ end
138
142
 
139
- watch_compass_pid = Process.fork do
140
- trap('INT') { exit }
141
- compass_write.close
142
- compass_read.each do |line|
143
- print yellow("COMPASS: ") + white(line) + ""
144
- end
145
- end if with_compass
143
+ def run_on_unix!
144
+ server_read, server_write = IO::pipe
145
+ haml_read, haml_write = IO::pipe
146
+ compass_read, compass_write = IO::pipe
147
+ compiler_read, compiler_write = IO::pipe
148
+
149
+ server_pid = Process.fork do
150
+ $stdout.reopen(server_write)
151
+ server_read.close
152
+ puts "Starting server..."
153
+ server_options = {
154
+ :Port => options[:port] || 4567,
155
+ :DocumentRoot => Dir.pwd
156
+ }
157
+ Rack::Handler::Thin.run Nimbu::Server::Base, server_options do |server|
158
+ [:INT, :TERM].each { |sig| trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop } }
159
+ end
160
+ end
146
161
 
162
+ haml_pid = Process.fork do
163
+ $stdout.reopen(haml_write)
164
+ haml_read.close
165
+ puts "Starting..."
166
+ haml_listener = HamlWatcher.watch
147
167
  [:INT, :TERM].each do |sig|
148
- trap(sig) do
149
- puts yellow("\n== Waiting for all processes to finish...")
150
- Process.kill('INT', haml_pid) if haml_pid && running?(haml_pid)
151
- Process.waitall
152
- puts green("== Nimbu has ended its work " + bold("(crowd applauds!)\n"))
168
+ Signal.trap(sig) do
169
+ puts green("== Stopping HAML watcher\n")
170
+ Thread.new { haml_listener.stop }
153
171
  end
154
172
  end
155
-
156
173
  Process.waitall
174
+ end if @with_haml
175
+
176
+ compass_pid = Process.fork do
177
+ $stdout.reopen(compass_write)
178
+ compass_read.close
179
+ puts "Starting..."
180
+ Compass::Exec::SubCommandUI.new(["watch","."]).run!
181
+ end if @with_compass
182
+
183
+ watch_server_pid = Process.fork do
184
+ trap('INT') { exit }
185
+ server_write.close
186
+ server_read.each do |line|
187
+ print cyan("SERVER: ") + white(line) + ""
188
+ end
157
189
  end
158
- end
159
190
 
160
- protected
191
+ watch_haml_pid = Process.fork do
192
+ trap('INT') { exit }
193
+ haml_write.close
194
+ haml_read.each do |line|
195
+ print magenta("HAML: ") + white(line) + ""
196
+ end
197
+ end if @with_haml
198
+
199
+ watch_compass_pid = Process.fork do
200
+ trap('INT') { exit }
201
+ compass_write.close
202
+ compass_read.each do |line|
203
+ print yellow("COMPASS: ") + white(line) + ""
204
+ end
205
+ end if @with_compass
206
+
207
+ [:INT, :TERM].each do |sig|
208
+ trap(sig) do
209
+ puts yellow("\n== Waiting for all processes to finish...")
210
+ Process.kill('INT', haml_pid) if haml_pid && running?(haml_pid)
211
+ Process.waitall
212
+ puts green("== Nimbu has ended its work " + bold("(crowd applauds!)\n"))
213
+ end
214
+ end
215
+
216
+ Process.waitall
217
+ end
161
218
 
162
219
  def nimbu_header
163
220
  h = ""
@@ -182,7 +239,6 @@ end
182
239
 
183
240
  require 'rubygems'
184
241
  require 'listen'
185
- require 'haml'
186
242
 
187
243
  class HamlWatcher
188
244
  class << self
@@ -26,15 +26,17 @@ module Nimbu
26
26
  set :views, File.expand_path('../views', __FILE__) # set up the views dir
27
27
  set :haml, { format: :html5 } # if you use haml
28
28
 
29
- use Rack::StreamingProxy::Proxy do |request|
30
- if request.path.start_with?('/favicon.ico')
31
- "http://#{Nimbu::Auth.site}.#{Nimbu::Auth.admin_host}/favicon.ico"
32
- elsif Nimbu.cli_options[:webpack_url] && webpack_resource?(request.path)
33
- "#{Nimbu.cli_options[:webpack_url]}#{request.path}"
29
+ unless Nimbu::Helpers.running_on_windows?
30
+ use Rack::StreamingProxy::Proxy do |request|
31
+ if request.path.start_with?('/favicon.ico')
32
+ "http://#{Nimbu::Auth.site}.#{Nimbu::Auth.admin_host}/favicon.ico"
33
+ elsif Nimbu.cli_options[:webpack_url] && webpack_resource?(request.path)
34
+ "#{Nimbu.cli_options[:webpack_url]}#{request.path}"
35
+ end
34
36
  end
35
- end
36
37
 
37
- Rack::StreamingProxy::Proxy.logger = Logger.new(File::NULL)
38
+ Rack::StreamingProxy::Proxy.logger = Logger.new(File::NULL)
39
+ end
38
40
 
39
41
  # Your "actions" go here…
40
42
  #
data/lib/nimbu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Nimbu
3
- VERSION = "0.8.4"
3
+ VERSION = "0.9.alpha.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimbu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zenjoy BVBA
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: wdm
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: bundler
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -306,9 +320,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
320
  version: '0'
307
321
  required_rubygems_version: !ruby/object:Gem::Requirement
308
322
  requirements:
309
- - - ">="
323
+ - - ">"
310
324
  - !ruby/object:Gem::Version
311
- version: '0'
325
+ version: 1.3.1
312
326
  requirements: []
313
327
  rubyforge_project:
314
328
  rubygems_version: 2.6.7