inesita 0.3.1 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -2
- data/inesita.gemspec +2 -1
- data/lib/inesita.rb +8 -4
- data/lib/inesita/cli.rb +1 -0
- data/lib/inesita/cli/build.rb +2 -2
- data/lib/inesita/cli/new.rb +1 -1
- data/lib/inesita/cli/template/.gitignore.tt +1 -0
- data/lib/inesita/config.rb +4 -1
- data/lib/inesita/server.rb +4 -2
- data/opal/inesita/router.rb +15 -8
- data/opal/inesita/routes.rb +14 -5
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 128cb0e2fdec618eadbb291fe314c09e213a549a
|
4
|
+
data.tar.gz: c72d4643eb7034aa29802104c8aac1a250f5174a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9a32e62454e2685c5772c7bb071351001447e951a99f9c01b77991f473804313051108a578c3a32c8a83266d66fab0174747fc7ee30922a7ee459bed839216
|
7
|
+
data.tar.gz: 266c547fef5472b0b867ef14aad998c7b6f66cee8d01e03559d94dca6fd69bb62eba2bc1b29481c6ad9918f8591d2aadcb7a6c4a64f9a9882d8fe0e9308bcb20
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/inesita.gemspec
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'inesita'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.2'
|
4
4
|
s.authors = ['Michał Kalbarczyk']
|
5
5
|
s.email = 'fazibear@gmail.com'
|
6
6
|
s.homepage = 'http://github.com/inesita-rb/inesita'
|
7
7
|
s.summary = 'Frontend web framework for Opal'
|
8
8
|
s.description = 'Frontent web framework for Opal'
|
9
|
+
s.license = 'MIT'
|
9
10
|
|
10
11
|
s.files = `git ls-files`.split("\n")
|
11
12
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
data/lib/inesita.rb
CHANGED
@@ -18,12 +18,16 @@ require 'inesita/server'
|
|
18
18
|
module Inesita
|
19
19
|
module_function
|
20
20
|
|
21
|
-
def
|
22
|
-
@env
|
21
|
+
def dist!
|
22
|
+
@env = :dist
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
@env
|
25
|
+
def dev?
|
26
|
+
(@env || :dev) == :dev
|
27
|
+
end
|
28
|
+
|
29
|
+
def dist?
|
30
|
+
@env == :dist
|
27
31
|
end
|
28
32
|
|
29
33
|
def assets_code
|
data/lib/inesita/cli.rb
CHANGED
data/lib/inesita/cli/build.rb
CHANGED
@@ -14,11 +14,11 @@ class InesitaCLI < Thor
|
|
14
14
|
|
15
15
|
method_option :destination,
|
16
16
|
aliases: ['-d', '-dir'],
|
17
|
-
default:
|
17
|
+
default: Inesita::Config::BUILD_DIR,
|
18
18
|
desc: 'build destination directory'
|
19
19
|
|
20
20
|
def build
|
21
|
-
Inesita.
|
21
|
+
Inesita.dist!
|
22
22
|
assets = Inesita::Server.new.assets_app
|
23
23
|
|
24
24
|
build_dir = options[:destination]
|
data/lib/inesita/cli/new.rb
CHANGED
@@ -13,7 +13,7 @@ class InesitaCLI < Thor
|
|
13
13
|
desc: 'force overwrite'
|
14
14
|
|
15
15
|
def new(project_dir)
|
16
|
-
directory('template', project_dir, project_name: project_dir)
|
16
|
+
directory('template', project_dir, project_name: project_dir, build_dir: Inesita::Config::BUILD_DIR)
|
17
17
|
|
18
18
|
inside project_dir do
|
19
19
|
run 'bundle install'
|
@@ -0,0 +1 @@
|
|
1
|
+
/<%= config[:build_dir] %>
|
data/lib/inesita/config.rb
CHANGED
data/lib/inesita/server.rb
CHANGED
@@ -18,10 +18,10 @@ module Inesita
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def assets_code
|
21
|
-
assets_prefix = Inesita.
|
21
|
+
assets_prefix = Inesita.dev? ? Config::ASSETS_PREFIX : nil
|
22
22
|
%(
|
23
23
|
<link rel="stylesheet" type="text/css" href="#{assets_prefix}/stylesheet.css">
|
24
|
-
#{Opal::Sprockets.javascript_include_tag('application', sprockets: @assets_app, prefix: assets_prefix, debug: Inesita.
|
24
|
+
#{Opal::Sprockets.javascript_include_tag('application', sprockets: @assets_app, prefix: assets_prefix, debug: Inesita.dev?)}
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
@@ -49,6 +49,8 @@ module Inesita
|
|
49
49
|
def create_assets_app
|
50
50
|
Opal::Server.new do |s|
|
51
51
|
s.append_path Config::APP_DIR
|
52
|
+
s.append_path Config::APP_DIST_DIR if Inesita.dist?
|
53
|
+
s.append_path Config::APP_DEV_DIR if Inesita.dev?
|
52
54
|
|
53
55
|
Opal.paths.each do |p|
|
54
56
|
s.append_path p
|
data/opal/inesita/router.rb
CHANGED
@@ -22,19 +22,26 @@ module Inesita
|
|
22
22
|
@routes.route(*params, &block)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def find_route
|
26
26
|
@routes.routes.each do |route|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@component_props = route[:component_props]
|
31
|
-
return route[:component]
|
27
|
+
next unless path.match(route[:regex])
|
28
|
+
return handle_link(url_for(route[:redirect_to])) if route[:redirect_to]
|
29
|
+
return route
|
32
30
|
end
|
33
31
|
fail Error, "Can't find route for url"
|
34
32
|
end
|
35
33
|
|
34
|
+
def find_component(route)
|
35
|
+
params = path.match(route[:regex])
|
36
|
+
@params = @url_params.merge(Hash[route[:params].zip(params[1..-1])])
|
37
|
+
@component_props = route[:component_props]
|
38
|
+
route[:component]
|
39
|
+
end
|
40
|
+
|
36
41
|
def render
|
37
|
-
|
42
|
+
if route = find_route
|
43
|
+
component find_component(route), props: @component_props
|
44
|
+
end
|
38
45
|
end
|
39
46
|
|
40
47
|
def handle_link(path)
|
@@ -57,7 +64,7 @@ module Inesita
|
|
57
64
|
route = @routes.routes.find do |r|
|
58
65
|
case name
|
59
66
|
when String
|
60
|
-
r[:name] == name
|
67
|
+
r[:name] == name || r[:path] == name
|
61
68
|
when Object
|
62
69
|
r[:component] == name
|
63
70
|
else
|
data/opal/inesita/routes.rb
CHANGED
@@ -10,13 +10,14 @@ module Inesita
|
|
10
10
|
def route(*params, &block)
|
11
11
|
path = params.first.delete('/')
|
12
12
|
path = @parent ? "#{@parent}/#{path}" : "/#{path}"
|
13
|
-
component = params.last[:to]
|
14
|
-
name = params.last[:as]
|
15
|
-
component_props = params.last[:props]
|
16
13
|
|
17
14
|
add_subroutes(path, &block) if block_given?
|
18
|
-
|
19
|
-
|
15
|
+
|
16
|
+
if params.last[:redirect_to]
|
17
|
+
add_redirect(path, params.last[:redirect_to])
|
18
|
+
else
|
19
|
+
add_route(params.last[:as], path, params.last[:to], params.last[:props])
|
20
|
+
end
|
20
21
|
end
|
21
22
|
|
22
23
|
def validate_component(component)
|
@@ -24,7 +25,15 @@ module Inesita
|
|
24
25
|
fail Error, "Invalid #{component} class, should mixin Inesita::Component" unless component.include?(Inesita::Component)
|
25
26
|
end
|
26
27
|
|
28
|
+
def add_redirect(path, redirect_to)
|
29
|
+
@routes << {
|
30
|
+
path: path,
|
31
|
+
redirect_to: redirect_to
|
32
|
+
}.merge(params_and_regex(path))
|
33
|
+
end
|
34
|
+
|
27
35
|
def add_route(name, path, component, component_props)
|
36
|
+
validate_component(component)
|
28
37
|
@routes << {
|
29
38
|
path: path,
|
30
39
|
component: component,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inesita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Kalbarczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/inesita/cli/build.rb
|
159
159
|
- lib/inesita/cli/new.rb
|
160
160
|
- lib/inesita/cli/server.rb
|
161
|
+
- lib/inesita/cli/template/.gitignore.tt
|
161
162
|
- lib/inesita/cli/template/Gemfile.tt
|
162
163
|
- lib/inesita/cli/template/README.md.tt
|
163
164
|
- lib/inesita/cli/template/app/application.js.rb.tt
|
@@ -197,7 +198,8 @@ files:
|
|
197
198
|
- spec/opal/spec_helper.rb
|
198
199
|
- spec/opal/store_spec.rb
|
199
200
|
homepage: http://github.com/inesita-rb/inesita
|
200
|
-
licenses:
|
201
|
+
licenses:
|
202
|
+
- MIT
|
201
203
|
metadata: {}
|
202
204
|
post_install_message:
|
203
205
|
rdoc_options: []
|