inesita 0.3.1 → 0.3.2

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: 4c0a64bb895728681f357fb737fedc3131c966ad
4
- data.tar.gz: 2c8b318940f34a93001956c590a90f05da36b882
3
+ metadata.gz: 128cb0e2fdec618eadbb291fe314c09e213a549a
4
+ data.tar.gz: c72d4643eb7034aa29802104c8aac1a250f5174a
5
5
  SHA512:
6
- metadata.gz: c655ef4d2cab0cc422c0dfc5d9e6a77d238c5634c2e047c064860614d8d2381c9c0bf8f7e88b9634b5c3f692c5761827f95c820c60284af53708d159473a40ac
7
- data.tar.gz: d1c65668cfe5e1112668a70b771f5279cd09f2decc67197fc45ba91313b1b5cd52d988dfa3b7fe095a2c476ce9ef49cd7f7df5a9fba5d6dd3c3aeb9a4c7e175d
6
+ metadata.gz: dd9a32e62454e2685c5772c7bb071351001447e951a99f9c01b77991f473804313051108a578c3a32c8a83266d66fab0174747fc7ee30922a7ee459bed839216
7
+ data.tar.gz: 266c547fef5472b0b867ef14aad998c7b6f66cee8d01e03559d94dca6fd69bb62eba2bc1b29481c6ad9918f8591d2aadcb7a6c4a64f9a9882d8fe0e9308bcb20
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## 0.3.1 (edge)
1
+ ## 0.3.2 (05.03.2016)
2
+ * add `app_dist` and `app_dev` directory support
3
+ * add `redirect_to` to route option
4
+
5
+ ## 0.3.1 (05.01.2016)
2
6
  * add params hash to `router.url_for`
3
7
  * fix `router.current_url?`
4
8
  * add `class_names` helper
data/Gemfile CHANGED
@@ -2,8 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'bundler', '~> 1.3'
5
+ gem 'bundler', '~> 1.0'
6
6
  gem 'rspec', '~> 3.0'
7
7
  gem 'opal-rspec', '~> 0.5.0'
8
- gem 'rake', '~> 10.4'
8
+ gem 'rake', '~> 10.0'
9
9
  gem 'opal-browser', '~> 0.2'
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.1'
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 env
22
- @env || :development
21
+ def dist!
22
+ @env = :dist
23
23
  end
24
24
 
25
- def env=(env)
26
- @env = 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
@@ -11,6 +11,7 @@ rescue Bundler::GemfileNotFound
11
11
  end
12
12
 
13
13
  require 'rack'
14
+ require 'inesita/config'
14
15
  require 'inesita/minify'
15
16
  require 'inesita/cli/build'
16
17
  require 'inesita/cli/server'
@@ -14,11 +14,11 @@ class InesitaCLI < Thor
14
14
 
15
15
  method_option :destination,
16
16
  aliases: ['-d', '-dir'],
17
- default: 'public',
17
+ default: Inesita::Config::BUILD_DIR,
18
18
  desc: 'build destination directory'
19
19
 
20
20
  def build
21
- Inesita.env = :production
21
+ Inesita.dist!
22
22
  assets = Inesita::Server.new.assets_app
23
23
 
24
24
  build_dir = options[:destination]
@@ -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] %>
@@ -2,7 +2,10 @@ module Inesita
2
2
  module Config
3
3
  SOURCE_MAP_PREFIX = '/__OPAL_MAPS__'
4
4
  ASSETS_PREFIX = '/__ASSETS__'
5
- APP_DIR = 'app'
6
5
  STATIC_DIR = '/static'
6
+ BUILD_DIR = 'dist'
7
+ APP_DIR = 'app'
8
+ APP_DEV_DIR = 'app_dev'
9
+ APP_DIST_DIR = 'app_dist'
7
10
  end
8
11
  end
@@ -18,10 +18,10 @@ module Inesita
18
18
  end
19
19
 
20
20
  def assets_code
21
- assets_prefix = Inesita.env == :development ? Config::ASSETS_PREFIX : nil
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.env == :development)}
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
@@ -22,19 +22,26 @@ module Inesita
22
22
  @routes.route(*params, &block)
23
23
  end
24
24
 
25
- def find_component
25
+ def find_route
26
26
  @routes.routes.each do |route|
27
- params = path.match(route[:regex])
28
- next unless params
29
- @params = @url_params.merge(Hash[route[:params].zip(params[1..-1])])
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
- component find_component, props: @component_props
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
@@ -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
- validate_component(component)
19
- add_route(name, path, component, component_props)
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.1
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-01-05 00:00:00.000000000 Z
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: []