inesita 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -71
- data/bin/inesita +5 -0
- data/inesita.gemspec +4 -1
- data/lib/inesita.rb +6 -1
- data/lib/inesita/cli.rb +6 -0
- data/lib/inesita/cli/build.rb +12 -0
- data/lib/inesita/cli/new.rb +31 -0
- data/lib/inesita/cli/server.rb +21 -0
- data/lib/inesita/cli/template/Gemfile +10 -0
- data/lib/inesita/cli/template/app/application.css.sass +1 -0
- data/lib/inesita/cli/template/app/application.js.rb +10 -0
- data/lib/inesita/cli/template/app/components/welcome_component.rb +13 -0
- data/lib/inesita/cli/template/app/index.html.slim +15 -0
- data/lib/inesita/cli/template/config.ru +4 -0
- data/lib/inesita/server.rb +49 -0
- data/opal/inesita/component.rb +28 -5
- metadata +58 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d3909fa440874cd1f0df998382f07bb79399344
|
4
|
+
data.tar.gz: 231bf829dcdc7d2316133b94c146513ee04369d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1e291ba6e0fa81c9616001debbd19c79f26e0152f5a9564c0440644002b8a1c96594a940e8e58f717e7aca90d815838ae49a4de8b5878753f5ea3be14254361
|
7
|
+
data.tar.gz: 00e5ac2d3da8824231421ea9feddc1c188ed81b03bb3dd9941adffbe5d0a5cb597e86446627926316edaf1d53c6f3a938b887e85181ab3980212d9161632493d
|
data/README.md
CHANGED
@@ -1,86 +1,32 @@
|
|
1
|
+
!!! WORK IN PROGRESS !!!
|
2
|
+
|
1
3
|
# Inesita [![Gem Version](https://badge.fury.io/rb/inesita.svg)](http://badge.fury.io/rb/inesita) [![Code Climate](https://codeclimate.com/github/fazibear/opal-virtual-dom/badges/gpa.svg)](https://codeclimate.com/github/fazibear/inesita)
|
2
4
|
|
3
5
|
Frontend web framework for Opal
|
4
6
|
|
5
|
-
## requiments
|
6
|
-
|
7
|
-
This wrapper require to load [virtual-dom](https://github.com/Matt-Esch/virtual-dom) first. For example you can use rails assets.
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
source 'https://rails-assets.org' do
|
11
|
-
gem 'rails-assets-virtual-dom'
|
12
|
-
end
|
13
|
-
```
|
14
|
-
|
15
7
|
## usage
|
16
8
|
|
17
|
-
|
9
|
+
Install Inesita
|
18
10
|
|
19
|
-
```
|
20
|
-
|
11
|
+
```sh
|
12
|
+
$ gem install inesita
|
21
13
|
```
|
22
14
|
|
23
|
-
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
require 'opal'
|
27
|
-
require 'virtual-dom' # required by opal-virtual-dom javascript library
|
28
|
-
require 'browser' # not required
|
29
|
-
require 'inesita'
|
30
|
-
|
31
|
-
class CounterNumber
|
32
|
-
include Inesita::Component
|
33
|
-
attr_reader :number
|
15
|
+
Generate Inesita new app
|
34
16
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def random_style
|
40
|
-
{
|
41
|
-
color: %w(red green blue).sample
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def render
|
46
|
-
span style: random_style do
|
47
|
-
text number
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class Counter
|
53
|
-
include Inesita::Component
|
54
|
-
attr_reader :count
|
17
|
+
```sh
|
18
|
+
$ inesita new my_app
|
19
|
+
```
|
55
20
|
|
56
|
-
|
57
|
-
@count = count
|
58
|
-
end
|
21
|
+
Launch Inesita server
|
59
22
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
23
|
+
```sh
|
24
|
+
$ cd my_app
|
25
|
+
$ bundle exec inesita server
|
26
|
+
```
|
64
27
|
|
65
|
-
|
66
|
-
@count -= 1
|
67
|
-
update
|
68
|
-
end
|
28
|
+
Go to [http://localhost:9292/](http://localhost:9292/)
|
69
29
|
|
70
|
-
|
71
|
-
div do
|
72
|
-
button onclick: -> { dec } do
|
73
|
-
text '-'
|
74
|
-
end
|
75
|
-
component CounterNumber.new(count)
|
76
|
-
button onclick: -> { inc } do
|
77
|
-
text '+'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
30
|
+
## example
|
82
31
|
|
83
|
-
|
84
|
-
Counter.new.mount($document.body)
|
85
|
-
end
|
86
|
-
```
|
32
|
+
[More detailed example Inesita app](https://github.com/fazibear/inesita-example)
|
data/bin/inesita
ADDED
data/inesita.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'inesita'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.3'
|
4
4
|
s.authors = [ 'Michał Kalbarczyk' ]
|
5
5
|
s.email = 'fazibear@gmail.com'
|
6
6
|
s.homepage = 'http://github.com/fazibear/inesita'
|
@@ -14,5 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_dependency 'opal'
|
16
16
|
s.add_dependency 'opal-virtual-dom'
|
17
|
+
s.add_dependency 'slim'
|
18
|
+
s.add_dependency 'sass'
|
19
|
+
s.add_dependency 'thor'
|
17
20
|
s.add_development_dependency 'rake'
|
18
21
|
end
|
data/lib/inesita.rb
CHANGED
data/lib/inesita/cli.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class InesitaCLI < Thor
|
2
|
+
include Thor::Actions
|
3
|
+
|
4
|
+
check_unknown_options!
|
5
|
+
|
6
|
+
namespace :new
|
7
|
+
|
8
|
+
desc "new PROJECT_NAME", "Create Inesita app"
|
9
|
+
|
10
|
+
def new(project_dir)
|
11
|
+
empty_directory project_dir
|
12
|
+
copy_file 'template/config.ru', File.join(project_dir, 'config.ru'), force: options[:force]
|
13
|
+
copy_file 'template/Gemfile', File.join(project_dir, 'Gemfile'), force: options[:force]
|
14
|
+
|
15
|
+
empty_directory File.join(project_dir, 'app')
|
16
|
+
copy_file 'template/app/index.html.slim', File.join(project_dir, 'app', 'index.html.slim')
|
17
|
+
copy_file 'template/app/application.js.rb', File.join(project_dir, 'app', 'application.js.rb')
|
18
|
+
copy_file 'template/app/application.css.sass', File.join(project_dir, 'app', 'application.css.sass')
|
19
|
+
|
20
|
+
empty_directory File.join(project_dir, 'app', 'components')
|
21
|
+
copy_file 'template/app/components/welcome_component.rb', File.join(project_dir, 'app', 'components', 'welcome_controller.rb')
|
22
|
+
|
23
|
+
inside project_dir do
|
24
|
+
run 'bundle install'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.source_root
|
29
|
+
File.dirname(__FILE__)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class InesitaCLI < Thor
|
2
|
+
|
3
|
+
check_unknown_options!
|
4
|
+
|
5
|
+
namespace :server
|
6
|
+
|
7
|
+
desc "server [OPTIONS]", "Starts Inesita server"
|
8
|
+
method_option :port,
|
9
|
+
aliases: '-p',
|
10
|
+
default: 9292,
|
11
|
+
desc: 'The port Inesita will listen on'
|
12
|
+
|
13
|
+
method_option :host,
|
14
|
+
aliases: '-h',
|
15
|
+
default: '127.0.0.1',
|
16
|
+
desc: 'The host address Inesita will bind to'
|
17
|
+
|
18
|
+
def server
|
19
|
+
Rack::Server.start config: 'config.ru', Port: options['port'], Host: options['host']
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "bootstrap"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
title Inesita
|
5
|
+
link href='application.css' rel='stylesheet' type='text/css'
|
6
|
+
- $SCRIPT_FILES.each do |file|
|
7
|
+
script src=file
|
8
|
+
javascript:
|
9
|
+
#{{$LOAD_ASSETS_CODE}}
|
10
|
+
body
|
11
|
+
nav.navbar.navbar-inverse
|
12
|
+
.container
|
13
|
+
.navbar-header
|
14
|
+
a.navbar-brand Project Name
|
15
|
+
#app.container
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Inesita
|
2
|
+
module_function
|
3
|
+
|
4
|
+
def server
|
5
|
+
Rack::Builder.new do
|
6
|
+
sprockets = Sprockets::Environment.new.tap do |s|
|
7
|
+
# register engines
|
8
|
+
s.register_engine '.slim', Slim::Template
|
9
|
+
s.register_engine '.rb', Opal::Processor
|
10
|
+
|
11
|
+
# add folders
|
12
|
+
s.append_path 'app'
|
13
|
+
|
14
|
+
# add paths from opal
|
15
|
+
Opal.paths.each do |p|
|
16
|
+
s.append_path p
|
17
|
+
end
|
18
|
+
|
19
|
+
# add paths from rails-assets
|
20
|
+
RailsAssets.load_paths.each do |p|
|
21
|
+
s.append_path p
|
22
|
+
end
|
23
|
+
|
24
|
+
s.context_class.class_eval do
|
25
|
+
def asset_path(path, options = {})
|
26
|
+
"#{path}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if Opal::Processor.source_map_enabled
|
32
|
+
source_maps_prefix = '/__OPAL_MAPS__'
|
33
|
+
source_maps = Opal::SourceMapServer.new(sprockets, source_maps_prefix)
|
34
|
+
::Opal::Sprockets::SourceMapHeaderPatch.inject!(source_maps_prefix)
|
35
|
+
|
36
|
+
map source_maps_prefix do
|
37
|
+
run source_maps
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
$LOAD_ASSETS_CODE = Opal::Processor.load_asset_code(sprockets, 'application.js')
|
42
|
+
$SCRIPT_FILES = (sprockets['application.js'].dependencies + [sprockets['application.self.js']]).map(&:logical_path)
|
43
|
+
|
44
|
+
map '/' do
|
45
|
+
run sprockets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/opal/inesita/component.rb
CHANGED
@@ -2,6 +2,10 @@ module Inesita
|
|
2
2
|
module Component
|
3
3
|
include VirtualDOM
|
4
4
|
|
5
|
+
def parent(component)
|
6
|
+
@parent = component
|
7
|
+
end
|
8
|
+
|
5
9
|
def mount(element)
|
6
10
|
@virtual_dom = NodeFactory.new(method(:render), self).nodes.first
|
7
11
|
@mount_point = VirtualDOM.create(@virtual_dom)
|
@@ -9,11 +13,30 @@ module Inesita
|
|
9
13
|
end
|
10
14
|
|
11
15
|
def update
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
if @virtual_dom && @mount_point
|
17
|
+
new_virtual_dom = NodeFactory.new(method(:render), self).nodes.first
|
18
|
+
diff = VirtualDOM.diff(@virtual_dom, new_virtual_dom)
|
19
|
+
VirtualDOM.patch(@mount_point, diff)
|
20
|
+
@virtual_dom = new_virtual_dom
|
21
|
+
else
|
22
|
+
@parent.update
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.included(base)
|
27
|
+
base.extend(ClassMethods)
|
28
|
+
end
|
29
|
+
|
30
|
+
module ClassMethods
|
31
|
+
def component(name, instance)
|
32
|
+
define_method name do
|
33
|
+
unless instance_variable_get(:"@#{name}")
|
34
|
+
instance_variable_set(:"@#{name}", instance)
|
35
|
+
instance_variable_get(:"@#{name}").parent(self)
|
36
|
+
end
|
37
|
+
instance_variable_get(:"@#{name}")
|
38
|
+
end
|
39
|
+
end
|
17
40
|
end
|
18
41
|
end
|
19
42
|
end
|
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.0.
|
4
|
+
version: 0.0.3
|
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-07-
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
84
|
name: rake
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +96,8 @@ dependencies:
|
|
54
96
|
version: '0'
|
55
97
|
description: Frontent web framework for Opal
|
56
98
|
email: fazibear@gmail.com
|
57
|
-
executables:
|
99
|
+
executables:
|
100
|
+
- inesita
|
58
101
|
extensions: []
|
59
102
|
extra_rdoc_files: []
|
60
103
|
files:
|
@@ -62,8 +105,20 @@ files:
|
|
62
105
|
- Gemfile
|
63
106
|
- README.md
|
64
107
|
- Rakefile
|
108
|
+
- bin/inesita
|
65
109
|
- inesita.gemspec
|
66
110
|
- lib/inesita.rb
|
111
|
+
- lib/inesita/cli.rb
|
112
|
+
- lib/inesita/cli/build.rb
|
113
|
+
- lib/inesita/cli/new.rb
|
114
|
+
- lib/inesita/cli/server.rb
|
115
|
+
- lib/inesita/cli/template/Gemfile
|
116
|
+
- lib/inesita/cli/template/app/application.css.sass
|
117
|
+
- lib/inesita/cli/template/app/application.js.rb
|
118
|
+
- lib/inesita/cli/template/app/components/welcome_component.rb
|
119
|
+
- lib/inesita/cli/template/app/index.html.slim
|
120
|
+
- lib/inesita/cli/template/config.ru
|
121
|
+
- lib/inesita/server.rb
|
67
122
|
- opal/inesita.rb
|
68
123
|
- opal/inesita/component.rb
|
69
124
|
- opal/virtual_dom_extension.rb
|