inesita 0.1.0 → 0.2.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: 64d2e0eb42676d12536c5751ef8896a2b60ed123
4
- data.tar.gz: dc4a4619b78c7405d54a0a80383996c6df724433
3
+ metadata.gz: d28277c2df0f1066c1ac4e90e1fa635818a6ac34
4
+ data.tar.gz: 3af7d67dd0c861446803d4456f953e9ff7314149
5
5
  SHA512:
6
- metadata.gz: 1e008afb399d387e09fce2aaf3ca81503fd5618e4d9bb0949a3aa81993b930f43515acc12d5b0451030c1252c361703b22d4d1aaf2b3a3989dde70a66378addb
7
- data.tar.gz: 98301a71c7490a38f673ed625152379071b5cf31c4309b1051e1723ad7e416852798bec825faf9bf286c76d481d344ebae24a7abdda130110fe0fdb2d518f24e
6
+ metadata.gz: 5020e2a1ff4ccfd32450a8a8c44fce5fc7f18f08afa413764ef3c24e1a81ffb643cc6835b5f5234ee91ee25f90ef1fa38966b14232d00151a09cd759ec8bbea1
7
+ data.tar.gz: 4828053c40152c0068e5420c19954190d3a7366419445fa99d7f97d4878267b6588c643092788f8fa73844439de0914bb578cac380cd6dd969dde738814a2dec
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "opal", github: "opal/opal"
4
-
5
3
  gemspec
data/README.md CHANGED
@@ -1,35 +1,12 @@
1
- !!! WORK IN PROGRESS !!!
1
+ # Inesita [![Gem Version](https://badge.fury.io/rb/inesita.svg)](http://badge.fury.io/rb/inesita) [![Code Climate](https://codeclimate.com/github/inesita-rb/inesita/badges/gpa.svg)](https://codeclimate.com/github/inesita-rb/inesita) [![Gem Dependencies](https://gemnasium.com/inesita-rb/inesita.png)](https://gemnasium.com/inesita-rb/inesita)
2
2
 
3
- # Inesita [![Gem Version](https://badge.fury.io/rb/inesita.svg)](http://badge.fury.io/rb/inesita) [![Code Climate](https://codeclimate.com/github/inesita-rb/inesita/badges/gpa.svg)](https://codeclimate.com/github/inesita-rb/inesita)
3
+ Inesita is a web frontend framework for fast building browser application using Ruby. It uses Virtual DOM for page render.
4
4
 
5
- Frontend web framework for Opal
5
+ ## Description
6
6
 
7
- ## usage
7
+ More detailed description [here](https://inesita-rb.github.io).
8
8
 
9
- Install Inesita
9
+ ## Examples
10
10
 
11
- ```sh
12
- $ gem install inesita
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
@@ -4,3 +4,5 @@
4
4
 
5
5
  - [ ] `router.current_url?` should supports also path
6
6
  - [ ] helper for dom class
7
+ - [ ] add comments to new application template
8
+ - [x] remove `dom` block from render
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.0'
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.5'
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
- dom do
6
- div class: 'jumbotron text-center' do
7
- p do
8
- text %{
9
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
10
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
11
- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
12
- Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
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
- dom do
6
- div class: 'jumbotron text-center' do
7
- img src: 'http://avatars.githubusercontent.com/inesita-rb'
8
- h1 do
9
- text "Hello I'm Inesita"
10
- end
11
- h4 do
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,11 +2,9 @@ class Layout
2
2
  include Inesita::Layout
3
3
 
4
4
  def render
5
- dom do
6
- div class: 'container' do
7
- component NavBar
8
- component outlet
9
- end
5
+ div class: 'container' do
6
+ component NavBar
7
+ component outlet
10
8
  end
11
9
  end
12
10
  end
@@ -2,23 +2,21 @@ class NavBar
2
2
  include Inesita::Component
3
3
 
4
4
  def render
5
- dom do
6
- nav class: 'navbar navbar-default' do
7
- div class: 'container' do
8
- div class: 'navbar-header' do
9
- span class: 'navbar-brand' do
10
- text '<%= config[:project_name] %>'
11
- end
12
- ul class: 'nav navbar-nav' do
13
- li class: "#{"active" if router.current_url?(:home)}" do
14
- a href: router.url_for(:home) do
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
- li class: "#{"active" if router.current_url?(:description)}" do
19
- a href: router.url_for(:description) do
20
- text 'Description'
21
- end
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
@@ -1,5 +1,4 @@
1
1
  require 'virtual_dom'
2
- require 'virtual_dom_extension'
3
2
  require 'inesita/js_helpers'
4
3
  require 'inesita/component_withs'
5
4
  require 'inesita/component'
@@ -22,9 +22,7 @@ module Inesita
22
22
  end
23
23
 
24
24
  def render
25
- dom do
26
- component root
27
- end
25
+ component root
28
26
  end
29
27
  end
30
28
  end
@@ -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 = render
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 = render
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
@@ -31,9 +31,7 @@ module Inesita
31
31
  end
32
32
 
33
33
  def render
34
- dom do
35
- component find_component, props: @component_props
36
- end
34
+ component find_component, props: @component_props
37
35
  end
38
36
 
39
37
  def handle_link(path)
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.0
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 00:00:00.000000000 Z
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.5
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.5
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
- - opal/virtual_dom_extension.rb
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