inesita 0.3.2 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/inesita.gemspec +1 -1
- data/lib/inesita.rb +0 -12
- data/lib/inesita/cli.rb +1 -0
- data/lib/inesita/cli/build.rb +45 -28
- data/lib/inesita/cli/new.rb +1 -1
- data/lib/inesita/cli/server.rb +2 -2
- data/lib/inesita/cli/template/app/index.html.slim.tt +1 -0
- data/lib/inesita/cli/watch.rb +46 -0
- data/lib/inesita/server.rb +24 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f91a4d1e673a6b2193f21bc02f314badc654850a
|
4
|
+
data.tar.gz: dcc841d257a207e7a1d7f7fd7395ab9a4617ff88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 636404d836f94c733888575ed7660e4d80764b4c0d4d532309bee232f888c871b5d70f67e73eb7db48139c13bafbd5229257bcd5d0b4ebd62610268182239352
|
7
|
+
data.tar.gz: 7e9b6bec1ab7f51753b67c267afbcc53b16cddd4d9c9c67cf6f29e37b0457cd16ec89bc8a19e83dd945ad8dab96f4d8e3fed73bd0f452517019637c192b64775
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
## 0.3.5 (10.03.2016)
|
2
|
+
* add `inesita watch`
|
3
|
+
* add `inesita build` dir parameters
|
4
|
+
|
1
5
|
## 0.3.2 (05.03.2016)
|
2
6
|
* add `app_dist` and `app_dev` directory support
|
3
|
-
* add `redirect_to` to route
|
7
|
+
* add `redirect_to` to `route` options
|
4
8
|
|
5
9
|
## 0.3.1 (05.01.2016)
|
6
10
|
* add params hash to `router.url_for`
|
data/inesita.gemspec
CHANGED
data/lib/inesita.rb
CHANGED
data/lib/inesita/cli.rb
CHANGED
data/lib/inesita/cli/build.rb
CHANGED
@@ -8,51 +8,68 @@ class InesitaCLI < Thor
|
|
8
8
|
desc 'build [OPTIONS]', 'Build Inesita app'
|
9
9
|
|
10
10
|
method_option :force,
|
11
|
-
aliases:
|
11
|
+
aliases: :f,
|
12
12
|
default: false,
|
13
13
|
desc: 'force overwrite'
|
14
14
|
|
15
|
-
method_option :
|
16
|
-
aliases:
|
15
|
+
method_option :destination_dir,
|
16
|
+
aliases: :d,
|
17
17
|
default: Inesita::Config::BUILD_DIR,
|
18
|
-
desc: '
|
18
|
+
desc: 'destination directory'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
method_option :source_dir,
|
21
|
+
aliases: :s,
|
22
|
+
default: Inesita::Config::APP_DIR,
|
23
|
+
desc: 'source (app) dir'
|
24
|
+
|
25
|
+
method_option :static_dir,
|
26
|
+
aliases: :t,
|
27
|
+
default: Inesita::Config::STATIC_DIR,
|
28
|
+
desc: 'static dir'
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
method_option :dist_source_dir,
|
31
|
+
aliases: :b,
|
32
|
+
default: Inesita::Config::APP_DIST_DIR,
|
33
|
+
desc: 'source (app) dir for dist build'
|
26
34
|
|
27
|
-
|
35
|
+
def build
|
36
|
+
assets = assets_server
|
37
|
+
empty_directory options[:destination_dir], force: options[:force]
|
28
38
|
|
29
|
-
copy_static
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
copy_static
|
40
|
+
create_asset(assets, 'index.html', ->(s) { Inesita::Minify.html(s) })
|
41
|
+
create_asset(assets, 'application.js', ->(s) { Inesita::Minify.js(s) })
|
42
|
+
create_asset(assets, 'stylesheet.css', ->(s) { Inesita::Minify.css(s) })
|
33
43
|
end
|
34
44
|
|
35
45
|
no_commands do
|
36
|
-
def
|
37
|
-
|
46
|
+
def assets_server
|
47
|
+
Inesita::Server.new({
|
48
|
+
dist: true,
|
49
|
+
static_dir: options[:static_dir],
|
50
|
+
app_dir: options[:source_dir],
|
51
|
+
app_dist_dir: options[:app_dist_dir]
|
52
|
+
}).assets_app
|
53
|
+
end
|
54
|
+
|
55
|
+
def copy_static
|
56
|
+
destination_dir = options[:destination_dir]
|
57
|
+
force = options[:force]
|
58
|
+
static_dir = options[:static_dir]
|
59
|
+
|
60
|
+
Dir.glob("./#{static_dir}/**/*").each do |file|
|
38
61
|
if File.directory?(file)
|
39
|
-
empty_directory File.join(
|
62
|
+
empty_directory File.join(destination_dir, file), force: force
|
40
63
|
else
|
41
|
-
copy_file File.absolute_path(file), File.join(
|
64
|
+
copy_file File.absolute_path(file), File.join(destination_dir, file.gsub(static_dir, 'static')), force: force
|
42
65
|
end
|
43
66
|
end
|
44
67
|
end
|
45
68
|
|
46
|
-
def
|
47
|
-
create_file File.join(
|
48
|
-
|
49
|
-
|
50
|
-
def create_js(build_dir, javascript, force)
|
51
|
-
create_file File.join(build_dir, 'application.js'), Inesita::Minify.js(javascript), force: force
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_css(build_dir, stylesheet, force)
|
55
|
-
create_file File.join(build_dir, 'stylesheet.css'), Inesita::Minify.css(stylesheet), force: force
|
69
|
+
def create_asset(assets, name, minify_proc)
|
70
|
+
create_file File.join(options[:destination_dir], name),
|
71
|
+
minify_proc.call(assets[name].source),
|
72
|
+
force: options[:force]
|
56
73
|
end
|
57
74
|
end
|
58
75
|
end
|
data/lib/inesita/cli/new.rb
CHANGED
data/lib/inesita/cli/server.rb
CHANGED
@@ -5,12 +5,12 @@ class InesitaCLI < Thor
|
|
5
5
|
|
6
6
|
desc 'server [OPTIONS]', 'Starts Inesita server'
|
7
7
|
method_option :port,
|
8
|
-
aliases:
|
8
|
+
aliases: :p,
|
9
9
|
default: 9292,
|
10
10
|
desc: 'The port Inesita will listen on'
|
11
11
|
|
12
12
|
method_option :host,
|
13
|
-
aliases:
|
13
|
+
aliases: :h,
|
14
14
|
default: '127.0.0.1',
|
15
15
|
desc: 'The host address Inesita will bind to'
|
16
16
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class InesitaCLI < Thor
|
2
|
+
include Thor::Actions
|
3
|
+
|
4
|
+
check_unknown_options!
|
5
|
+
|
6
|
+
namespace :watch
|
7
|
+
|
8
|
+
desc 'watch [OPTIONS]', 'Watch files and build Inesita app'
|
9
|
+
|
10
|
+
method_option :force,
|
11
|
+
aliases: :f,
|
12
|
+
default: true,
|
13
|
+
desc: 'force overwrite'
|
14
|
+
|
15
|
+
method_option :destination_dir,
|
16
|
+
aliases: :d,
|
17
|
+
default: Inesita::Config::BUILD_DIR,
|
18
|
+
desc: 'destination directory'
|
19
|
+
|
20
|
+
method_option :source_dir,
|
21
|
+
aliases: :s,
|
22
|
+
default: Inesita::Config::APP_DIR,
|
23
|
+
desc: 'source (app) dir'
|
24
|
+
|
25
|
+
method_option :static_dir,
|
26
|
+
aliases: :t,
|
27
|
+
default: Inesita::Config::STATIC_DIR,
|
28
|
+
desc: 'static dir'
|
29
|
+
|
30
|
+
method_option :dist_source_dir,
|
31
|
+
aliases: :b,
|
32
|
+
default: Inesita::Config::APP_DIST_DIR,
|
33
|
+
desc: 'source (app) dir for dist build'
|
34
|
+
|
35
|
+
def watch
|
36
|
+
puts 'building...'
|
37
|
+
build
|
38
|
+
puts 'done.'
|
39
|
+
listener = Listen.to(options[:source_dir]) do |_modified, _added, _removed|
|
40
|
+
puts "rebuilding..."
|
41
|
+
build
|
42
|
+
puts "done."
|
43
|
+
end.start
|
44
|
+
loop { sleep 1000 }
|
45
|
+
end
|
46
|
+
end
|
data/lib/inesita/server.rb
CHANGED
@@ -10,27 +10,41 @@ module Inesita
|
|
10
10
|
class Server
|
11
11
|
attr_reader :assets_app
|
12
12
|
|
13
|
-
def initialize
|
13
|
+
def initialize(opts = {})
|
14
|
+
setup_dirs(opts)
|
15
|
+
setup_env(opts)
|
14
16
|
@assets_app = create_assets_app
|
15
17
|
@source_maps_app = create_source_maps_app
|
16
18
|
@app = create_app
|
17
19
|
Inesita.assets_code = assets_code
|
18
20
|
end
|
19
21
|
|
22
|
+
def setup_env(opts)
|
23
|
+
@dist = opts[:dist] || false
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup_dirs(opts)
|
27
|
+
@static_dir = opts[:static_dir] || Config::STATIC_DIR
|
28
|
+
@app_dir = opts[:app_dir] || Config::APP_DIR
|
29
|
+
@app_dist_dir = opts[:app_dist_dir] || Config::APP_DIST_DIR
|
30
|
+
@app_dev_dir = opts[:app_dev_dir] || Config::APP_DEV_DIR
|
31
|
+
end
|
32
|
+
|
20
33
|
def assets_code
|
21
|
-
assets_prefix =
|
34
|
+
assets_prefix = @dist ? nil : Config::ASSETS_PREFIX
|
22
35
|
%(
|
23
36
|
<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:
|
37
|
+
#{Opal::Sprockets.javascript_include_tag('application', sprockets: @assets_app, prefix: assets_prefix, debug: !@dist)}
|
25
38
|
)
|
26
39
|
end
|
27
40
|
|
28
41
|
def create_app
|
29
42
|
assets_app = @assets_app
|
30
43
|
source_maps_app = @source_maps_app
|
44
|
+
static_dir = @static_dir
|
31
45
|
|
32
46
|
Rack::Builder.new do
|
33
|
-
use Rack::Static, :urls => [
|
47
|
+
use Rack::Static, :urls => [static_dir]
|
34
48
|
|
35
49
|
use Rack::Rewrite do
|
36
50
|
rewrite(/^(?!#{Config::ASSETS_PREFIX}|#{Config::SOURCE_MAP_PREFIX}).*/, Config::ASSETS_PREFIX)
|
@@ -48,9 +62,12 @@ module Inesita
|
|
48
62
|
|
49
63
|
def create_assets_app
|
50
64
|
Opal::Server.new do |s|
|
51
|
-
s.append_path
|
52
|
-
|
53
|
-
|
65
|
+
s.append_path @app_dir
|
66
|
+
if @dist
|
67
|
+
s.append_path @app_dist_dir
|
68
|
+
else
|
69
|
+
s.append_path @app_dev_dir
|
70
|
+
end
|
54
71
|
|
55
72
|
Opal.paths.each do |p|
|
56
73
|
s.append_path p
|
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.
|
4
|
+
version: 0.3.5
|
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-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/inesita/cli/template/app/stylesheet.css.sass.tt
|
173
173
|
- lib/inesita/cli/template/config.ru.tt
|
174
174
|
- lib/inesita/cli/template/static/inesita-rb.png
|
175
|
+
- lib/inesita/cli/watch.rb
|
175
176
|
- lib/inesita/config.rb
|
176
177
|
- lib/inesita/live_reload.rb
|
177
178
|
- lib/inesita/minify.rb
|