inesita 0.1.0 → 0.2.1
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/Gemfile +0 -2
- data/README.md +7 -30
- data/TODO.md +2 -0
- data/inesita.gemspec +2 -2
- data/lib/inesita/cli/template/app/components/description.rb.tt +8 -10
- data/lib/inesita/cli/template/app/components/home.rb.tt +7 -9
- data/lib/inesita/cli/template/app/components/layout.rb.tt +3 -5
- data/lib/inesita/cli/template/app/components/navbar.rb.tt +14 -16
- data/opal/inesita.rb +0 -1
- data/opal/inesita/application.rb +1 -3
- data/opal/inesita/component.rb +40 -13
- data/opal/inesita/router.rb +1 -3
- data/test.rb +27 -0
- metadata +5 -5
- data/opal/virtual_dom_extension.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d28277c2df0f1066c1ac4e90e1fa635818a6ac34
|
4
|
+
data.tar.gz: 3af7d67dd0c861446803d4456f953e9ff7314149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5020e2a1ff4ccfd32450a8a8c44fce5fc7f18f08afa413764ef3c24e1a81ffb643cc6835b5f5234ee91ee25f90ef1fa38966b14232d00151a09cd759ec8bbea1
|
7
|
+
data.tar.gz: 4828053c40152c0068e5420c19954190d3a7366419445fa99d7f97d4878267b6588c643092788f8fa73844439de0914bb578cac380cd6dd969dde738814a2dec
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,35 +1,12 @@
|
|
1
|
-
|
1
|
+
# Inesita [](http://badge.fury.io/rb/inesita) [](https://codeclimate.com/github/inesita-rb/inesita) [](https://gemnasium.com/inesita-rb/inesita)
|
2
2
|
|
3
|
-
|
3
|
+
Inesita is a web frontend framework for fast building browser application using Ruby. It uses Virtual DOM for page render.
|
4
4
|
|
5
|
-
|
5
|
+
## Description
|
6
6
|
|
7
|
-
|
7
|
+
More detailed description [here](https://inesita-rb.github.io).
|
8
8
|
|
9
|
-
|
9
|
+
## Examples
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
```
|
14
|
-
Generate Inesita new app
|
15
|
-
|
16
|
-
```sh
|
17
|
-
$ inesita new my_app
|
18
|
-
```
|
19
|
-
Launch Inesita server
|
20
|
-
|
21
|
-
```sh
|
22
|
-
$ cd my_app
|
23
|
-
$ bundle exec inesita server
|
24
|
-
```
|
25
|
-
Go to [http://localhost:9292/](http://localhost:9292/)
|
26
|
-
|
27
|
-
To build your application to `public` dir
|
28
|
-
|
29
|
-
```sh
|
30
|
-
$ bundle exec inesita build
|
31
|
-
```
|
32
|
-
## examples
|
33
|
-
|
34
|
-
- [My own playground](https://github.com/inesita-rb/playground)
|
35
|
-
- [TodoMVC example](https://github.com/inesita-rb/todomvc)
|
11
|
+
- [Example application](https://github.com/inesita-rb/playground)
|
12
|
+
- [TodoMVC application](https://github.com/inesita-rb/todomvc)
|
data/TODO.md
CHANGED
data/inesita.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'inesita'
|
3
|
-
s.version = '0.1
|
3
|
+
s.version = '0.2.1'
|
4
4
|
s.authors = [ 'Michał Kalbarczyk' ]
|
5
5
|
s.email = 'fazibear@gmail.com'
|
6
6
|
s.homepage = 'http://github.com/inesita-rb/inesita'
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.require_paths = ['lib']
|
14
14
|
|
15
15
|
s.add_dependency 'opal', '~> 0.8'
|
16
|
-
s.add_dependency 'opal-virtual-dom', '~> 0.0
|
16
|
+
s.add_dependency 'opal-virtual-dom', '~> 0.1.0'
|
17
17
|
s.add_dependency 'slim', '~> 3.0'
|
18
18
|
s.add_dependency 'sass', '~> 3.4'
|
19
19
|
s.add_dependency 'thor', '~> 0.19'
|
@@ -2,16 +2,14 @@ class Description
|
|
2
2
|
include Inesita::Component
|
3
3
|
|
4
4
|
def render
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
end
|
5
|
+
div class: 'jumbotron text-center' do
|
6
|
+
p do
|
7
|
+
text %{
|
8
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
9
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
10
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
11
|
+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
12
|
+
}
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -2,15 +2,13 @@ class Home
|
|
2
2
|
include Inesita::Component
|
3
3
|
|
4
4
|
def render
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
text 'This is a sample component'
|
13
|
-
end
|
5
|
+
div class: 'jumbotron text-center' do
|
6
|
+
img src: 'http://avatars.githubusercontent.com/inesita-rb'
|
7
|
+
h1 do
|
8
|
+
text "Hello I'm Inesita"
|
9
|
+
end
|
10
|
+
h4 do
|
11
|
+
text 'This is a sample component'
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -2,23 +2,21 @@ class NavBar
|
|
2
2
|
include Inesita::Component
|
3
3
|
|
4
4
|
def render
|
5
|
-
|
6
|
-
|
7
|
-
div class: '
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
text 'Home'
|
16
|
-
end
|
5
|
+
nav class: 'navbar navbar-default' do
|
6
|
+
div class: 'container' do
|
7
|
+
div class: 'navbar-header' do
|
8
|
+
span class: 'navbar-brand' do
|
9
|
+
text '<%= config[:project_name] %>'
|
10
|
+
end
|
11
|
+
ul class: 'nav navbar-nav' do
|
12
|
+
li class: "#{"active" if router.current_url?(:home)}" do
|
13
|
+
a href: router.url_for(:home) do
|
14
|
+
text 'Home'
|
17
15
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
end
|
17
|
+
li class: "#{"active" if router.current_url?(:description)}" do
|
18
|
+
a href: router.url_for(:description) do
|
19
|
+
text 'Description'
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
data/opal/inesita.rb
CHANGED
data/opal/inesita/application.rb
CHANGED
data/opal/inesita/component.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
module Inesita
|
2
2
|
module Component
|
3
|
-
include VirtualDOM
|
3
|
+
include VirtualDOM::DOM
|
4
4
|
include ComponentWiths
|
5
5
|
|
6
|
-
def dom(&block)
|
7
|
-
nodes = NodeFactory.new(block, self).nodes
|
8
|
-
@cache_component_counter = nil
|
9
|
-
if nodes.length == 1
|
10
|
-
nodes.first
|
11
|
-
else
|
12
|
-
VirtualNode.new('div', {}, nodes).vnode
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
6
|
def mount_to(element)
|
17
7
|
@root_component = self
|
18
|
-
@virtual_dom =
|
8
|
+
@virtual_dom = render_virtual_dom
|
19
9
|
@root_node = VirtualDOM.create(@virtual_dom)
|
20
10
|
element.inner_dom = @root_node
|
21
11
|
end
|
22
12
|
|
23
13
|
def render_if_root
|
24
14
|
if @virtual_dom && @root_node
|
25
|
-
new_virtual_dom =
|
15
|
+
new_virtual_dom = render_virtual_dom
|
26
16
|
diff = VirtualDOM.diff(@virtual_dom, new_virtual_dom)
|
27
17
|
VirtualDOM.patch(@root_node, diff)
|
28
18
|
@virtual_dom = new_virtual_dom
|
29
19
|
end
|
30
20
|
end
|
31
21
|
|
22
|
+
def render_virtual_dom
|
23
|
+
@__virtual_nodes__ = []
|
24
|
+
render
|
25
|
+
if @__virtual_nodes__.length == 0
|
26
|
+
@__virtual_nodes__.first
|
27
|
+
else
|
28
|
+
VirtualDOM::VirtualNode.new('div', {}, @__virtual_nodes__).vnode
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
32
|
def update_dom
|
33
33
|
@root_component.render_if_root
|
34
34
|
end
|
@@ -39,5 +39,32 @@ module Inesita
|
|
39
39
|
@cache_component_counter += 1
|
40
40
|
@cache_component["#{component}-#{@cache_component_counter}"] || @cache_component["#{component}-#{@cache_component_counter}"] = block.call
|
41
41
|
end
|
42
|
+
|
43
|
+
def a(params, &block)
|
44
|
+
params = { onclick: -> { @router.handle_link(params[:href]) } }.merge(params) if params[:href] && @router
|
45
|
+
@__virtual_nodes__ ||= []
|
46
|
+
if block
|
47
|
+
current = @__virtual_nodes__
|
48
|
+
@__virtual_nodes__ = []
|
49
|
+
result = block.call
|
50
|
+
vnode = VirtualDOM::VirtualNode.new('a', process_params(params), @__virtual_nodes__.count == 0 ? result : @__virtual_nodes__).vnode
|
51
|
+
@__virtual_nodes__ = current
|
52
|
+
else
|
53
|
+
vnode = VirtualDOM::VirtualNode.new('a', process_params(params), []).vnode
|
54
|
+
end
|
55
|
+
@__virtual_nodes__ << vnode
|
56
|
+
vnode
|
57
|
+
end
|
58
|
+
|
59
|
+
def component(comp, opts = {})
|
60
|
+
fail "Component is nil in #{self.class} class" if comp.nil?
|
61
|
+
@__virtual_nodes__ ||= []
|
62
|
+
@__virtual_nodes__ << cache_component(comp) do
|
63
|
+
(comp.is_a?(Class) ? comp.new : comp)
|
64
|
+
.with_root_component(@root_component)
|
65
|
+
.with_router(@router)
|
66
|
+
.with_store(@store)
|
67
|
+
end.with_props(opts[:props] || {}).render_virtual_dom
|
68
|
+
end
|
42
69
|
end
|
43
70
|
end
|
data/opal/inesita/router.rb
CHANGED
data/test.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module A
|
2
|
+
['test','cos'].each do |name|
|
3
|
+
define_method name do
|
4
|
+
puts name
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module B
|
10
|
+
include A
|
11
|
+
end
|
12
|
+
|
13
|
+
module C
|
14
|
+
include B
|
15
|
+
end
|
16
|
+
|
17
|
+
class X
|
18
|
+
include C
|
19
|
+
def initialize
|
20
|
+
test
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
X.new
|
25
|
+
|
26
|
+
|
27
|
+
|
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.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Kalbarczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0
|
33
|
+
version: 0.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0
|
40
|
+
version: 0.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: slim
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,7 +149,7 @@ files:
|
|
149
149
|
- opal/inesita/router.rb
|
150
150
|
- opal/inesita/routes.rb
|
151
151
|
- opal/inesita/store.rb
|
152
|
-
-
|
152
|
+
- test.rb
|
153
153
|
homepage: http://github.com/inesita-rb/inesita
|
154
154
|
licenses: []
|
155
155
|
metadata: {}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module VirtualDOM
|
2
|
-
class NodeFactory
|
3
|
-
def component(comp, opts = {})
|
4
|
-
fail "Component is nil in #{@parent.class} class" if comp.nil?
|
5
|
-
@nodes << @parent.cache_component(comp) do
|
6
|
-
(comp.is_a?(Class) ? comp.new : comp)
|
7
|
-
.with_root_component(@parent.root_component)
|
8
|
-
.with_router(@parent.router)
|
9
|
-
.with_store(@parent.store)
|
10
|
-
end.with_props(opts[:props] || {}).render
|
11
|
-
end
|
12
|
-
|
13
|
-
def a(params, &block)
|
14
|
-
params = { onclick: -> { @parent.router.handle_link(params[:href]) } }.merge(params) if params[:href] && @parent.router
|
15
|
-
@nodes << VirtualNode.new(
|
16
|
-
'a',
|
17
|
-
process_params(params),
|
18
|
-
block ? NodeFactory.new(block, @parent).nodes : []
|
19
|
-
).vnode
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|