inesita 0.3.0 → 0.3.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: e75bb45e13cde077690f59ac0196e2b630f9d40f
4
- data.tar.gz: 16e95d9a8c923eff86a7d6f84800807cbc2dd0d7
3
+ metadata.gz: 4c0a64bb895728681f357fb737fedc3131c966ad
4
+ data.tar.gz: 2c8b318940f34a93001956c590a90f05da36b882
5
5
  SHA512:
6
- metadata.gz: 935deea53673ada2f81a43202c1e75bfa86242f501ec9ee7241713b49a60479017a7dcf30eea5806a3d1b3fdf1255bc6bc58a18d3d56a4ccb0a6ae5323c8dc68
7
- data.tar.gz: ab86e398eaa70c544249753da02e07ddaaabce585879343f163d7cb04b8119ab655c0974aa45a56b8a7dfc282e348bae70297e37897446a59610035883c2e228
6
+ metadata.gz: c655ef4d2cab0cc422c0dfc5d9e6a77d238c5634c2e047c064860614d8d2381c9c0bf8f7e88b9634b5c3f692c5761827f95c820c60284af53708d159473a40ac
7
+ data.tar.gz: d1c65668cfe5e1112668a70b771f5279cd09f2decc67197fc45ba91313b1b5cd52d988dfa3b7fe095a2c476ce9ef49cd7f7df5a9fba5d6dd3c3aeb9a4c7e175d
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## 0.3.0 (edge)
1
+ ## 0.3.1 (edge)
2
+ * add params hash to `router.url_for`
3
+ * fix `router.current_url?`
4
+ * add `class_names` helper
5
+
6
+ ## 0.3.0 (20.12.2015)
2
7
 
3
8
  * live-reload
4
9
  * rename `update_dom` to `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.3.0'
3
+ s.version = '0.3.1'
4
4
  s.authors = ['Michał Kalbarczyk']
5
5
  s.email = 'fazibear@gmail.com'
6
6
  s.homepage = 'http://github.com/inesita-rb/inesita'
@@ -10,3 +10,8 @@ gem 'inesita', '~> 0.3.0'
10
10
 
11
11
  # bootsrap assets
12
12
  gem 'bootstrap-sass'
13
+
14
+ # rails-assets are also supported
15
+ # source 'https://rails-assets.org' do
16
+ # gem 'rails-assets-bootstrap'
17
+ # end
@@ -1 +1,8 @@
1
1
  # <%= config[:project_name] %>
2
+
3
+ ```sh
4
+ $ bundle install
5
+ $ bundle exec inesita server
6
+ ```
7
+
8
+ Go to [http://localhost:9292/](http://localhost:9292/)
@@ -1,13 +1,18 @@
1
+ # require Inesita
1
2
  require 'inesita'
2
3
 
4
+ # require main parts of application
3
5
  require 'router'
4
6
  require 'store'
5
7
  require 'layout'
6
8
 
9
+ # require all components
7
10
  require_tree './components'
8
11
 
12
+ # when document is ready render application to <body>
9
13
  $document.ready do
10
- App = Inesita::Application.new(
14
+ # setup Inesita application
15
+ Inesita::Application.new(
11
16
  router: Router,
12
17
  store: Store,
13
18
  layout: Layout
@@ -3,7 +3,7 @@ class Home
3
3
 
4
4
  def render
5
5
  div class: 'jumbotron text-center' do
6
- img src: '/static/inesita-rb.jpg'
6
+ img src: '/static/inesita-rb.png'
7
7
  h1 do
8
8
  text "Hello I'm Inesita"
9
9
  end
data/opal/inesita.rb CHANGED
@@ -11,6 +11,7 @@ require 'virtual_dom'
11
11
  require 'inesita/error'
12
12
  require 'inesita/component_virtual_dom_extension'
13
13
  require 'inesita/component_properties'
14
+ require 'inesita/component_helpers'
14
15
  require 'inesita/component'
15
16
  require 'inesita/routes'
16
17
  require 'inesita/router'
@@ -1,6 +1,7 @@
1
1
  module Inesita
2
2
  module Component
3
3
  include VirtualDOM::DOM
4
+ include ComponentHelpers
4
5
  include ComponentProperties
5
6
  include ComponentVirtualDomExtension
6
7
 
@@ -0,0 +1,11 @@
1
+ module Inesita
2
+ module ComponentHelpers
3
+ def class_names(hash)
4
+ class_names = []
5
+ hash.each do |key, value|
6
+ class_names << key if value
7
+ end
8
+ class_names.join(' ')
9
+ end
10
+ end
11
+ end
@@ -10,10 +10,10 @@ module Inesita
10
10
  fail Error, 'Add #routes method to router!' unless respond_to?(:routes)
11
11
  routes
12
12
  fail Error, 'Add #route to your #routes method!' if @routes.routes.empty?
13
- add_js_listeners
13
+ add_listeners
14
14
  end
15
15
 
16
- def add_js_listeners
16
+ def add_listeners
17
17
  $window.on(:popstate) { render! }
18
18
  $window.on(:hashchange) { render! }
19
19
  end
@@ -53,14 +53,18 @@ module Inesita
53
53
  params
54
54
  end
55
55
 
56
- def url_for(name)
57
- route = case name
58
- when String
59
- @routes.routes.find { |r| r[:name] == name }
60
- when Object
61
- @routes.routes.find { |r| r[:component] == name }
62
- end
63
- route ? route[:path] : fail(Error, "Route '#{name}' not found.")
56
+ def url_for(name, params = nil)
57
+ route = @routes.routes.find do |r|
58
+ case name
59
+ when String
60
+ r[:name] == name
61
+ when Object
62
+ r[:component] == name
63
+ else
64
+ false
65
+ end
66
+ end
67
+ route ? url_with_params(route, params) : fail(Error, "Route '#{name}' not found.")
64
68
  end
65
69
 
66
70
  def path
@@ -68,7 +72,15 @@ module Inesita
68
72
  end
69
73
 
70
74
  def current_url?(name)
71
- path == url_for(name)
75
+ path == url_for(name, params)
76
+ end
77
+
78
+ def url_with_params(route, params)
79
+ path = route[:path]
80
+ params.each do |key, value|
81
+ path = path.gsub(":#{key}", "#{value}")
82
+ end if params
83
+ path
72
84
  end
73
85
  end
74
86
  end
@@ -1,6 +1,6 @@
1
1
  module Inesita
2
2
  class Routes
3
- attr_reader :routes, :route_names
3
+ attr_reader :routes
4
4
 
5
5
  def initialize(parent = nil)
6
6
  @parent = parent
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.0
4
+ version: 0.3.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-12-20 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -179,6 +179,7 @@ files:
179
179
  - opal/inesita.rb
180
180
  - opal/inesita/application.rb
181
181
  - opal/inesita/component.rb
182
+ - opal/inesita/component_helpers.rb
182
183
  - opal/inesita/component_properties.rb
183
184
  - opal/inesita/component_virtual_dom_extension.rb
184
185
  - opal/inesita/error.rb
@@ -214,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
215
  version: '0'
215
216
  requirements: []
216
217
  rubyforge_project:
217
- rubygems_version: 2.4.8
218
+ rubygems_version: 2.5.1
218
219
  signing_key:
219
220
  specification_version: 4
220
221
  summary: Frontend web framework for Opal