sombrero 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/package.json +1 -1
  3. data/app/webpack.config.js +1 -2
  4. data/docker/base/build.sh +2 -4
  5. data/docker/{cleanup → skel/cleanup.sh} +0 -0
  6. data/lib/sombrero/cli/app/install.rb +21 -22
  7. data/lib/sombrero/cli/app/update.rb +12 -6
  8. data/lib/sombrero/cli/assertions.rb +60 -0
  9. data/lib/sombrero/cli/docker/build.rb +7 -27
  10. data/lib/sombrero/cli/docker/install.rb +7 -9
  11. data/lib/sombrero/cli/docker/update.rb +24 -0
  12. data/lib/sombrero/cli/docker.rb +2 -0
  13. data/lib/sombrero/cli/generator.rb +15 -0
  14. data/lib/sombrero/cli/helpers.rb +47 -0
  15. data/lib/sombrero/cli.rb +136 -70
  16. data/lib/sombrero/rtcp_controller.rb +0 -12
  17. data/sombrero.gemspec +1 -1
  18. metadata +8 -22
  19. data/.gitignore +0 -10
  20. data/LICENSE.txt +0 -21
  21. data/README.md +0 -41
  22. data/app/core/client/activity_observer.coffee +0 -37
  23. data/app/core/client/api.coffee +0 -248
  24. data/app/core/client/channels.coffee +0 -37
  25. data/app/core/client/load.coffee +0 -20
  26. data/app/core/client/page.coffee +0 -68
  27. data/app/core/client/polyfills/array.compact.coffee +0 -4
  28. data/app/core/client/polyfills/array.compact_join.coffee +0 -4
  29. data/app/core/client/polyfills/number.to_money.coffee +0 -3
  30. data/app/core/client/polyfills/string.capitalize.coffee +0 -4
  31. data/app/core/client/polyfills/string.strip.coffee +0 -5
  32. data/app/core/client/polyfills.coffee +0 -6
  33. data/app/core/client/render.coffee +0 -57
  34. data/app/core/client/util/alert.coffee +0 -50
  35. data/app/core/client/util/datetime.coffee +0 -47
  36. data/app/core/client/util.coffee +0 -38
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sombrero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slee Woo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rocketio
@@ -60,10 +60,7 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - ".gitignore"
64
63
  - Gemfile
65
- - LICENSE.txt
66
- - README.md
67
64
  - Rakefile
68
65
  - app/.gitignore
69
66
  - app/.pryrc
@@ -83,21 +80,6 @@ files:
83
80
  - app/config/env/test.yml
84
81
  - app/core/Gemfile
85
82
  - app/core/boot.rb
86
- - app/core/client/activity_observer.coffee
87
- - app/core/client/api.coffee
88
- - app/core/client/channels.coffee
89
- - app/core/client/load.coffee
90
- - app/core/client/page.coffee
91
- - app/core/client/polyfills.coffee
92
- - app/core/client/polyfills/array.compact.coffee
93
- - app/core/client/polyfills/array.compact_join.coffee
94
- - app/core/client/polyfills/number.to_money.coffee
95
- - app/core/client/polyfills/string.capitalize.coffee
96
- - app/core/client/polyfills/string.strip.coffee
97
- - app/core/client/render.coffee
98
- - app/core/client/util.coffee
99
- - app/core/client/util/alert.coffee
100
- - app/core/client/util/datetime.coffee
101
83
  - app/core/generate_controllers_map.rb
102
84
  - app/core/generate_webpack_setup.rb
103
85
  - app/core/load.rb
@@ -109,9 +91,9 @@ files:
109
91
  - docker/base/Dockerfile
110
92
  - docker/base/build
111
93
  - docker/base/build.sh
112
- - docker/cleanup
113
94
  - docker/run
114
95
  - docker/skel/build.sh
96
+ - docker/skel/cleanup.sh
115
97
  - docker/skel/config.yml
116
98
  - docker/skel/prepare_build.sh
117
99
  - docker/skel/start.sh
@@ -123,9 +105,13 @@ files:
123
105
  - lib/sombrero/cli/app.rb
124
106
  - lib/sombrero/cli/app/install.rb
125
107
  - lib/sombrero/cli/app/update.rb
108
+ - lib/sombrero/cli/assertions.rb
126
109
  - lib/sombrero/cli/docker.rb
127
110
  - lib/sombrero/cli/docker/build.rb
128
111
  - lib/sombrero/cli/docker/install.rb
112
+ - lib/sombrero/cli/docker/update.rb
113
+ - lib/sombrero/cli/generator.rb
114
+ - lib/sombrero/cli/helpers.rb
129
115
  - lib/sombrero/rtcp_controller.rb
130
116
  - sombrero.gemspec
131
117
  homepage: https://github.com/sleewoo/sombrero
@@ -151,5 +137,5 @@ rubyforge_project:
151
137
  rubygems_version: 2.5.1
152
138
  signing_key:
153
139
  specification_version: 4
154
- summary: '["sombrero-0.0.3", "Opinionated stack for building opinionated web applications"]'
140
+ summary: '["sombrero-0.0.5", "Opinionated stack for building opinionated web applications"]'
155
141
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- .DS_Store
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Slee Woo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,41 +0,0 @@
1
- # Sombrero
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sombrero`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'sombrero'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install sombrero
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sombrero.
36
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -1,37 +0,0 @@
1
- _ =
2
- debounce: require('lodash/debounce')
3
- isFunction: require('lodash/isFunction')
4
- #end
5
-
6
- ONLINE = 'online'
7
- AWAY = 'away'
8
- OFFLINE = 'offline'
9
-
10
- module.exports = (consider_idle_after, report_status = ->) ->
11
- is_idle = false
12
- idle_time = 0
13
-
14
- if report_status && !_.isFunction(report_status)
15
- throw new Error('activity_observer expects second argument to be a function')
16
-
17
- activity_detected = ->
18
- report_status(ONLINE) if is_idle
19
- is_idle = false
20
- idle_time = 0
21
- true
22
- #end
23
-
24
-
25
- tictac = ->
26
- return if is_idle
27
- idle_time += 1
28
- is_idle = idle_time >= consider_idle_after
29
- if is_idle
30
- report_status(AWAY)
31
- #end
32
-
33
-
34
- window.onload = document.onmousemove = document.onkeypress = _.debounce(activity_detected, 500)
35
- window.onunload = -> report_status(OFFLINE)
36
- window.setInterval(tictac, 1000)
37
- #end
@@ -1,248 +0,0 @@
1
- _ =
2
- isObject: require('lodash/isObject')
3
- last: require('lodash/last')
4
- has: require('lodash/has')
5
- isFunction: require('lodash/isFunction')
6
- isArray: require('lodash/isArray')
7
- forEach: require('lodash/forEach')
8
- #end
9
-
10
- ReconnectingWebSocket = require('reconnectingwebsocket')
11
- QueryString = require('qs')
12
-
13
- Page = require('./page')
14
- Load = require('./load')
15
- Channels = require('./channels')
16
- Controllers = require('../../controllers.json')
17
-
18
- App =
19
- connected: false
20
- listeners: {}
21
- call_on_reconnect: []
22
- rtcp_serial: 0
23
- #end
24
-
25
- App.urlify = (url) ->
26
- fn = (args...) ->
27
- args.unshift(url)
28
- q = ''
29
- if _.isObject(_.last(args))
30
- q = '?' + QueryString.stringify(args.pop())
31
- '/' + args.join('/').replace(/^\/+/, '') + q
32
- fn.toString = -> url
33
- fn
34
- #end
35
-
36
-
37
- App.controller_loader = (controller) ->
38
- ->
39
-
40
- url = [App.app_url, controller.path].join('/') + '.js'
41
- window.exports = {}
42
- window.module = {url: url, exports: window.exports}
43
-
44
- done = ->
45
- unless api = window.module.exports
46
- throw new Error("Looks like #{url} does not contain a CommonJS module")
47
-
48
- unless window.module && window.module.url == url
49
- throw new Error("Looks like #{url} exports was overridden while downloading the script")
50
-
51
- Core.on_controller_loaded(controller, api)
52
- #end
53
-
54
- failed = ->
55
- console.log("Error loading #{controller.name}")
56
- #end
57
-
58
- Load.script(url, done, failed)
59
- #end
60
-
61
-
62
- App.controllers = ->
63
- controllers = {}
64
-
65
- Controllers.forEach (controller) ->
66
-
67
- controller.url = App.urlify(controller.url)
68
- controller.load = App.controller_loader(controller)
69
-
70
- if _.isArray(controller.api)
71
- api = {}
72
-
73
- _.forEach controller.api, (meth) ->
74
- api[meth] = (args...) ->
75
- cb = if _.isFunction(_.last(args)) then args.pop() else null
76
- App.send_rtcp_message(controller.url, meth, args, cb)
77
- #end
78
-
79
- controller.api = api
80
- #end
81
-
82
- Page.Api controller.url_pattern, (context, next) ->
83
- controller.load()
84
- #end
85
-
86
- if controller.name
87
- controllers[controller.name] = controller
88
- #end
89
-
90
- controllers
91
- #end
92
-
93
-
94
- App.onmessage = (evt) ->
95
- msg = JSON.parse(evt.data)
96
-
97
- unless typeof msg == 'object'
98
- throw new Error("Wrong message format, #{typeof msg} given, Object expected")
99
-
100
- if msg.error
101
- throw new Error(msg.error)
102
-
103
- if msg.channel
104
- return Core.on_channel_message(msg)
105
-
106
- if msg.controller
107
- return App.handle_rpc_message(msg)
108
-
109
- unless typeof msg.serial == 'number'
110
- throw new Error('Received a message without or with a wrong serial')
111
-
112
- if msg.serial < 0
113
- throw new Error('A subzero serial received')
114
-
115
- unless _.has(msg, 'data')
116
- throw new Error('Received a message without data')
117
-
118
- if msg.data.__rtcp_error__
119
- return App.handle_standard_message(msg)
120
-
121
- if msg.serial == 0
122
- return App.handle_initialization_message(msg)
123
-
124
- return App.handle_standard_message(msg)
125
- #end
126
-
127
-
128
- App.handle_initialization_message = (msg) ->
129
-
130
- # avoid repetitive bootstraping on reconnects
131
- return if App.initialized
132
- App.initialized = true
133
- App.app_url = msg.data.app_url
134
-
135
- Core.on_initialize(msg)
136
-
137
- Page.Api.start()
138
- #end
139
-
140
-
141
- App.handle_standard_message = (msg) ->
142
- return unless listener = App.listeners[msg.serial]
143
-
144
- delete App.listeners[msg.serial]
145
-
146
- return unless _.isFunction(listener)
147
-
148
- return listener(msg.data.__rtcp_error__) if msg.data.__rtcp_error__
149
-
150
- if _.isArray(msg.data)
151
- listener(null, msg.data...)
152
- else
153
- listener(null, msg.data)
154
- #end
155
- #end
156
-
157
-
158
- App.handle_rpc_message = (msg) ->
159
- unless Core.controllers[msg.controller]
160
- throw new Error('Unknown controller called')
161
-
162
- Core.controllers[msg.controller].load (api) ->
163
-
164
- unless method = api[msg.method]
165
- throw new Error('Unknown method called')
166
-
167
- if args = msg.arguments
168
- args = [args] unless _.isArray(args)
169
- else
170
- args = []
171
-
172
- method.apply(api, args)
173
- #end
174
-
175
-
176
- App.send_rtcp_message = (controller, method, args, callback) ->
177
- unless App.connected
178
- App.call_on_reconnect.push(-> App.send_rtcp_message(controller, method, args, callback))
179
- Core.connect() if App.explicitly_disconnected
180
- return
181
- #end
182
-
183
- if _.isFunction(controller)
184
- controller = controller()
185
- #end
186
-
187
- App.rtcp_serial += 1
188
- data =
189
- controller: controller
190
- method: method
191
- arguments: args
192
- serial: App.rtcp_serial
193
- #end
194
-
195
- if callback
196
- App.listeners[App.rtcp_serial] = callback
197
- data.reply = true
198
- #end
199
-
200
- App.socket.send(JSON.stringify(data), binary: true)
201
- #end
202
-
203
-
204
- Core =
205
- on_socket_open: ->
206
- on_socket_close: ->
207
- on_initialize: ->
208
- on_controller_loaded: ->
209
-
210
- on_channel_message: Channels.on_message
211
- subscribe: Channels.subscribe
212
- unsubscribe: Channels.unsubscribe
213
-
214
- controllers: App.controllers()
215
- send_rtcp_message: App.send_rtcp_message
216
-
217
- connect: (url = '__rtcp__')->
218
-
219
- return if typeof window.WebSocket == 'undefined'
220
- protocol = if window.location.protocol.toLowerCase() == 'https:' then 'wss' else 'ws'
221
- App.socket = new ReconnectingWebSocket("#{protocol}://#{window.location.host}/#{url}")
222
-
223
- App.socket.onopen = ->
224
- App.connected = true
225
- _.forEach App.call_on_reconnect, (fn) ->
226
- try
227
- fn()
228
- #end
229
- App.call_on_reconnect = []
230
- Core.on_socket_open(App.socket)
231
- #end
232
-
233
- App.socket.onerror = App.socket.onclose = ->
234
- App.connected = false
235
- Core.on_socket_close()
236
- #end
237
-
238
- App.socket.onmessage = App.onmessage
239
- #end
240
-
241
- disconnect: ->
242
- App.explicitly_disconnected = true
243
- App.socket.close()
244
- #end
245
-
246
- #end
247
-
248
- module.exports = Core
@@ -1,37 +0,0 @@
1
- _ =
2
- isRegExp: require('lodash/isRegExp')
3
- #end
4
-
5
- subscriptions = {}
6
- awaiting_subscriptions = {}
7
-
8
- module.exports =
9
- on_message: (msg) ->
10
- # if there is a handler, call it
11
- if handler = subscriptions[msg.channel]
12
- delete subscriptions[msg.channel] if msg.unsubscribe
13
- handler(msg.data) if msg.data
14
- else
15
- # otherwise store message for when handler defined to handle it straight away
16
- awaiting_subscriptions[msg.channel] = msg.data
17
- #end
18
-
19
-
20
- subscribe: (channel, handler) ->
21
- # if there is a awaiting subscription handle it right away
22
- if msg = awaiting_subscriptions[channel]
23
- delete awaiting_subscriptions[channel]
24
- return handler(msg)
25
- # otherwise subscribe
26
- subscriptions[channel] = handler
27
- #end
28
-
29
-
30
- unsubscribe: (channel) ->
31
- if _.isRegExp(channel)
32
- for c in Object.keys(subscriptions).filter((c) -> channel.text(c))
33
- delete subscriptions[c]
34
- else
35
- delete subscriptions[channel]
36
- #end
37
- #end
@@ -1,20 +0,0 @@
1
- module.exports =
2
-
3
- script: (url, done, failed) ->
4
- script = document.createElement('script')
5
- script.async = true
6
- script.onload = done
7
- script.onerror = failed
8
- script.src = url
9
- document.getElementsByTagName('head')[0].appendChild(script)
10
- #end
11
-
12
-
13
- stylesheet: (url, done) ->
14
- link = document.createElement('link')
15
- link.onload = done
16
- link.type = 'text/css'
17
- link.rel = 'stylesheet'
18
- link.href = url
19
- document.getElementsByTagName('head')[0].appendChild(link)
20
- #end
@@ -1,68 +0,0 @@
1
- _ =
2
- isFunction: require('lodash/isFunction')
3
- isObject: require('lodash/isObject')
4
- isArray: require('lodash/isArray')
5
- has: require('lodash/has')
6
- #end
7
-
8
- QueryString = require('qs')
9
- Api = require('page')
10
-
11
- page = ->
12
-
13
- this.navigate = (path, options) ->
14
- if _.isFunction(path)
15
- path = path()
16
-
17
- if !path || _.isObject(path)
18
- options = path
19
- path = window.location.pathname
20
-
21
- options = {} unless _.isObject(options)
22
-
23
- if _.isArray(options.path)
24
- path = '/' + options.path
25
- .filter((x) -> x)
26
- .map((x) -> String(x))
27
- .join('/')
28
- .replace(/\/+/, '/')
29
- .replace(/^\//, '')
30
-
31
- if _.isObject(options.params)
32
- path = path + '?' + QueryString.stringify(options.params)
33
-
34
- if options.reload
35
- Api.stop()
36
- window.location = path
37
-
38
- parser = document.createElement('a')
39
- parser.href = path
40
- if parser.hostname
41
- unless parser.hostname == location.hostname
42
- throw new Error('Guess what! Someone tries to navigate out!')
43
-
44
- args = [
45
- path,
46
- (if _.has(options, 'state') then options.state else {}),
47
- (if _.has(options, 'dispatch') then options.dispatch else true),
48
- (if _.has(options, 'push') then options.push else true)
49
- ]
50
- Api.show.apply(this, args)
51
-
52
- this.update_params()
53
- #end
54
-
55
-
56
- this.update_params = ->
57
- this.params = QueryString.parse(window.location.search.slice(1))
58
- this.path_params = window.location.pathname.replace(/^\/+|\/+$/g, '').split(/\/+/).filter((x) -> x.length > 0)
59
- #end
60
-
61
- this.update_params()
62
-
63
- this
64
- #end
65
-
66
- page.Api = Api
67
-
68
- module.exports = page
@@ -1,4 +0,0 @@
1
-
2
- Array.prototype.compact = ->
3
- this.filter (x) -> x
4
- #end
@@ -1,4 +0,0 @@
1
-
2
- Array.prototype.compact_join = (glue) ->
3
- (this.filter (x) -> x).join(glue)
4
- #end
@@ -1,3 +0,0 @@
1
- Number.prototype.to_money = (n = 2, x = 3) ->
2
- re = '(\\d)(?=(\\d{' + x + '})+' + (n > 0 ? '\\.' : '$') + ')'
3
- this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$1,')
@@ -1,4 +0,0 @@
1
-
2
- String.prototype.capitalize = ->
3
- this.charAt(0).toUpperCase() + this.slice(1)
4
- #end
@@ -1,5 +0,0 @@
1
-
2
-
3
- String.prototype.strip = ->
4
- this.replace(/^\s+|\s+$/g, '')
5
- #end
@@ -1,6 +0,0 @@
1
-
2
- require './polyfills/array.compact.coffee'
3
- require './polyfills/array.compact_join.coffee'
4
- require './polyfills/number.to_money.coffee'
5
- require './polyfills/string.capitalize.coffee'
6
- require './polyfills/string.strip.coffee'
@@ -1,57 +0,0 @@
1
- _ =
2
- extend: require('lodash/extend')
3
- has: require('lodash/has')
4
- isFunction: require('lodash/isFunction')
5
- #end
6
-
7
- extend = (data) ->
8
- _.extend({}, data || {}, api.global_data || {})
9
- #end
10
-
11
- api = (opts) ->
12
- api.default_el || throw new Error('Render.default_el not set')
13
- opts.data = extend(opts.data)
14
- opts.el = opts.el || api.default_el
15
- opts.magic = if _.has(opts, 'magic') then opts.magic else true
16
-
17
- ractive = new api.Ractive(opts)
18
-
19
- for h,f of api.global_handlers || {}
20
- ractive.on(h, f)
21
-
22
- ractive
23
- #end
24
-
25
- api.Ractive = require('ractive')
26
-
27
- api.global_data = {}
28
- api.global_handlers = {}
29
- api.default_el = null
30
-
31
- api.component = (opts) ->
32
- data = opts.data
33
- opts.data = ->
34
- if _.isFunction(data)
35
- extend(data())
36
- else
37
- extend(data)
38
- #end
39
-
40
- opts.magic = if _.has(opts, 'magic') then opts.magic else true
41
-
42
- oninit = opts.oninit
43
- opts.oninit = ->
44
- for h,f of api.global_handlers || {}
45
- this.on(h, f)
46
- oninit?()
47
- #end
48
- api.Ractive.extend(opts)
49
- #end
50
-
51
-
52
- api.string = (opts = {}) ->
53
- opts.data = extend(opts.data)
54
- new api.Ractive(opts).toHTML()
55
- #end
56
-
57
- module.exports = api