appril-cli 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/base/{bootstrap/api/callbacks.js → api.js} +3 -0
- data/app/base/bootstrap/components.js +4 -5
- data/app/base/bootstrap/router.js +10 -8
- data/app/base/bootstrap/rtcp.js +3 -3
- data/app/base/components/base_controller.rb +7 -5
- data/app/config/env/development.yml +1 -0
- data/app/core/generate_configs.rb +1 -0
- data/app/package.json +1 -1
- data/lib/appril-cli/version.rb +1 -1
- metadata +4 -8
- data/app/base/bootstrap/api/request-methods.js +0 -7
- data/app/base/bootstrap/api/rtcp.js +0 -28
- data/app/base/bootstrap/api/validate-arguments.js +0 -29
- data/app/base/bootstrap/api/xhr.js +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1dc24aad4f54cd214c7e2cf371da2dfaa73a585
|
4
|
+
data.tar.gz: 73a5ddff69205eac86f5c391030d3bb0e1219853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5fedc40fc4c6dd2fe67f8d90a2c548ac796eea2f324597a70b2b59b8a2877e94127b9d2bef1880312203589e2520c7087340ec03a80f2b32a503c7735869454
|
7
|
+
data.tar.gz: d76ea8aab153e7d1ea3c03b0f2eb74f1e536bd1794590b72e8e994f953550e7f89e5a8e4350db7c00b0b75ff1056bf4cf2bdea01535c9cf16dff84dd61dd46bd
|
@@ -1,15 +1,14 @@
|
|
1
1
|
import {reduce} from 'lodash'
|
2
2
|
import {urlify} from 'appril-utils'
|
3
|
-
import
|
4
|
-
import rtcp_api_builder from './api/rtcp'
|
5
|
-
import * as callbacks from './api/callbacks'
|
3
|
+
import xhr from 'appril-api/xhr'
|
6
4
|
import rtcp from './rtcp'
|
5
|
+
import * as callbacks_and_headers from 'base/api'
|
7
6
|
import {components, default_api} from 'app/appril.json'
|
8
7
|
|
9
8
|
export default reduce(components, function(map,component) {
|
10
9
|
component.url = urlify(component.url)
|
11
|
-
component.xhr =
|
12
|
-
component.rtcp =
|
10
|
+
component.xhr = xhr(component, callbacks_and_headers)
|
11
|
+
component.rtcp = rtcp.api(component)
|
13
12
|
Object.defineProperty(component, 'api', {get() {return component[default_api]}})
|
14
13
|
map[component.name] = component
|
15
14
|
return map
|
@@ -1,14 +1,16 @@
|
|
1
|
-
import {map, filter} from 'lodash'
|
1
|
+
import {map, filter, compact} from 'lodash'
|
2
2
|
import Vue from 'vue'
|
3
3
|
import VueRouter from 'vue-router'
|
4
4
|
|
5
5
|
import components from './components'
|
6
6
|
import store from './store'
|
7
7
|
import componentify from './component'
|
8
|
-
import {client_url} from 'app/appril.json'
|
8
|
+
import {dev_server_url, client_url} from 'app/appril.json'
|
9
9
|
|
10
10
|
Vue.use(VueRouter)
|
11
11
|
|
12
|
+
const BASEURL = compact([dev_server_url, client_url, APP_ENV]).join('')
|
13
|
+
|
12
14
|
export default new VueRouter({
|
13
15
|
mode: 'history',
|
14
16
|
base: __dirname,
|
@@ -16,7 +18,7 @@ export default new VueRouter({
|
|
16
18
|
return {
|
17
19
|
name: component.name,
|
18
20
|
path: component.url_pattern,
|
19
|
-
component: (resolve
|
21
|
+
component: (resolve) => load_component(component, resolve)
|
20
22
|
}
|
21
23
|
})
|
22
24
|
})
|
@@ -34,7 +36,7 @@ function resolve_component(component, constructor, resolve) {
|
|
34
36
|
}
|
35
37
|
}
|
36
38
|
|
37
|
-
function load_component(component, resolve
|
39
|
+
function load_component(component, resolve) {
|
38
40
|
const xhr = new XMLHttpRequest()
|
39
41
|
|
40
42
|
xhr.onreadystatechange = function() {
|
@@ -42,16 +44,16 @@ function load_component(component, resolve, reject) {
|
|
42
44
|
return
|
43
45
|
|
44
46
|
if (parseInt(xhr.status / 100) !== 2)
|
45
|
-
return
|
47
|
+
return console.error(xhr.responseText)
|
46
48
|
|
47
49
|
resolve_component(component, _eval(xhr.responseText), resolve)
|
48
50
|
}
|
49
51
|
|
50
|
-
xhr.onerror = function() {
|
51
|
-
|
52
|
+
xhr.onerror = function(error = 'Network error occurred') {
|
53
|
+
console.error(error)
|
52
54
|
}
|
53
55
|
|
54
|
-
xhr.open('GET', `${
|
56
|
+
xhr.open('GET', `${BASEURL}/${component.entry_path}.js`)
|
55
57
|
xhr.send()
|
56
58
|
}
|
57
59
|
|
data/app/base/bootstrap/rtcp.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import RTCP from 'appril-rtcp'
|
2
|
-
import * as
|
1
|
+
import RTCP from 'appril-api/rtcp'
|
2
|
+
import * as callbacks_and_headers from 'base/api'
|
3
3
|
import {server_url} from 'app/appril.json'
|
4
4
|
|
5
|
-
const rtcp = new RTCP(
|
5
|
+
const rtcp = new RTCP(callbacks_and_headers)
|
6
6
|
|
7
7
|
rtcp.connect({
|
8
8
|
// make sure this URL is matching RTCPController URL
|
@@ -2,15 +2,17 @@ class BaseController < Appril::BaseController
|
|
2
2
|
include Helpers
|
3
3
|
include UserHelpers
|
4
4
|
|
5
|
-
map
|
5
|
+
map(Cfg.server_url)
|
6
|
+
|
7
|
+
engine(:Liquid)
|
8
|
+
|
9
|
+
define_layout(:layout, {file: '../templates/layout'})
|
10
|
+
layout(:layout)
|
6
11
|
|
7
|
-
define_layout :layout, file: '../templates/layout'
|
8
|
-
layout :layout
|
9
|
-
engine :Liquid
|
10
12
|
define_template(:index) {''}
|
11
13
|
|
12
14
|
# highly important setup, do NOT remove
|
13
|
-
define_template_var(:client_url, File.join(Cfg.client_url, environment).freeze)
|
15
|
+
define_template_var(:client_url, File.join(Cfg.dev_server_url.to_s, Cfg.client_url, environment).freeze)
|
14
16
|
|
15
17
|
def index
|
16
18
|
render
|
@@ -0,0 +1 @@
|
|
1
|
+
# dev_server_url: http://localhost:8080
|
data/app/package.json
CHANGED
data/lib/appril-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appril-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-08-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Appril CLI
|
14
14
|
email:
|
@@ -24,14 +24,10 @@ files:
|
|
24
24
|
- app/.pryrc
|
25
25
|
- app/Gemfile
|
26
26
|
- app/Rakefile
|
27
|
+
- app/base/api.js
|
27
28
|
- app/base/app.js
|
28
29
|
- app/base/assets/app.css
|
29
30
|
- app/base/boot.rb
|
30
|
-
- app/base/bootstrap/api/callbacks.js
|
31
|
-
- app/base/bootstrap/api/request-methods.js
|
32
|
-
- app/base/bootstrap/api/rtcp.js
|
33
|
-
- app/base/bootstrap/api/validate-arguments.js
|
34
|
-
- app/base/bootstrap/api/xhr.js
|
35
31
|
- app/base/bootstrap/component.js
|
36
32
|
- app/base/bootstrap/components.js
|
37
33
|
- app/base/bootstrap/router.js
|
@@ -125,5 +121,5 @@ rubyforge_project:
|
|
125
121
|
rubygems_version: 2.5.1
|
126
122
|
signing_key:
|
127
123
|
specification_version: 4
|
128
|
-
summary: '["appril-cli-0.
|
124
|
+
summary: '["appril-cli-0.3.0", "Appril CLI"]'
|
129
125
|
test_files: []
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import {reduce} from 'lodash'
|
2
|
-
import validate_arguments from './validate-arguments'
|
3
|
-
import REQUEST_METHODS from './request-methods'
|
4
|
-
|
5
|
-
export default function(component, rtcp) {
|
6
|
-
|
7
|
-
return reduce(component.api || [], function(component_api, method) {
|
8
|
-
component_api[method] = function(...args) {
|
9
|
-
|
10
|
-
validate_arguments(args)
|
11
|
-
|
12
|
-
return reduce(REQUEST_METHODS, function(method_api, request_method) {
|
13
|
-
method_api[request_method.toLowerCase()] = function(callbacks) {
|
14
|
-
|
15
|
-
rtcp.call_server_method(
|
16
|
-
component.controller_name,
|
17
|
-
method,
|
18
|
-
args,
|
19
|
-
request_method,
|
20
|
-
callbacks
|
21
|
-
)
|
22
|
-
}
|
23
|
-
return method_api
|
24
|
-
}, {})
|
25
|
-
}
|
26
|
-
return component_api
|
27
|
-
}, {})
|
28
|
-
}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import {forEach} from 'lodash'
|
2
|
-
|
3
|
-
const STRING = '[object String]'
|
4
|
-
const NUMBER = '[object Number]'
|
5
|
-
const OBJECT = '[object Object]'
|
6
|
-
|
7
|
-
function get_type(arg) {
|
8
|
-
const type = Object.prototype.toString.call(arg)
|
9
|
-
return {
|
10
|
-
is_string: type === STRING,
|
11
|
-
is_number: type === NUMBER,
|
12
|
-
is_object: type === OBJECT,
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
export default function(args) {
|
17
|
-
forEach(args, function(arg,i) {
|
18
|
-
|
19
|
-
const {is_string, is_number, is_object} = get_type(arg)
|
20
|
-
|
21
|
-
if (!is_string && !is_number && !is_object) {
|
22
|
-
throw `Api methods accepts only Strings, Numbers and Objects as arguments. Argument #${i} is a ${type} instead.`
|
23
|
-
}
|
24
|
-
|
25
|
-
if (is_object && i + 1 !== args.length) {
|
26
|
-
throw `Only last argument can be a Object`
|
27
|
-
}
|
28
|
-
})
|
29
|
-
}
|
@@ -1,88 +0,0 @@
|
|
1
|
-
import {reduce, isObject, isArray, isFunction, last} from 'lodash'
|
2
|
-
import {url_builder} from 'appril-utils'
|
3
|
-
import validate_arguments from './validate-arguments'
|
4
|
-
import REQUEST_METHODS from './request-methods'
|
5
|
-
|
6
|
-
export default function(component, {on_request, on_response, on_error} = {}) {
|
7
|
-
|
8
|
-
return reduce(component.api || [], function(component_api, method) {
|
9
|
-
|
10
|
-
component_api[method] = function(...args) {
|
11
|
-
|
12
|
-
validate_arguments(args)
|
13
|
-
|
14
|
-
return reduce(REQUEST_METHODS, function(method_api, request_method) {
|
15
|
-
|
16
|
-
const is_post = request_method === 'POST'
|
17
|
-
|
18
|
-
method_api[request_method.toLowerCase()] = function(callbacks = {}) {
|
19
|
-
|
20
|
-
const error_reporter = function(error_message) {
|
21
|
-
if (callbacks.error)
|
22
|
-
return callbacks.error(error_message)
|
23
|
-
if (on_error)
|
24
|
-
return on_error(error_message)
|
25
|
-
throw error_message
|
26
|
-
}
|
27
|
-
|
28
|
-
const xhr = new XMLHttpRequest()
|
29
|
-
|
30
|
-
let params = last(args)
|
31
|
-
|
32
|
-
if (isObject(params)) {
|
33
|
-
if (is_post) {
|
34
|
-
args.pop()
|
35
|
-
}
|
36
|
-
} else {
|
37
|
-
params = {}
|
38
|
-
}
|
39
|
-
|
40
|
-
on_request && on_request(params)
|
41
|
-
|
42
|
-
xhr.onreadystatechange = function() {
|
43
|
-
if (xhr.readyState !== XMLHttpRequest.DONE)
|
44
|
-
return
|
45
|
-
|
46
|
-
callbacks.done && callbacks.done()
|
47
|
-
|
48
|
-
if (parseInt(xhr.status / 100) !== 2)
|
49
|
-
return error_reporter(xhr.responseText)
|
50
|
-
|
51
|
-
if (!callbacks.success)
|
52
|
-
return
|
53
|
-
|
54
|
-
let response = JSON.parse(xhr.responseText)
|
55
|
-
|
56
|
-
on_response && on_response(response)
|
57
|
-
|
58
|
-
callbacks.success(response)
|
59
|
-
}
|
60
|
-
|
61
|
-
xhr.onerror = function(error_message = 'Network error occurred') {
|
62
|
-
callbacks.done && callbacks.done()
|
63
|
-
error_reporter(error_message)
|
64
|
-
}
|
65
|
-
|
66
|
-
xhr.open(request_method, url_builder(component.url, method, ...args))
|
67
|
-
|
68
|
-
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
69
|
-
xhr.setRequestHeader('Accept', 'application/json')
|
70
|
-
|
71
|
-
if (is_post) {
|
72
|
-
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
|
73
|
-
xhr.send(JSON.stringify(params))
|
74
|
-
} else {
|
75
|
-
xhr.send()
|
76
|
-
}
|
77
|
-
}
|
78
|
-
|
79
|
-
return method_api
|
80
|
-
}, {})
|
81
|
-
|
82
|
-
}
|
83
|
-
|
84
|
-
return component_api
|
85
|
-
|
86
|
-
}, {})
|
87
|
-
|
88
|
-
}
|