inesita 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d3909fa440874cd1f0df998382f07bb79399344
4
- data.tar.gz: 231bf829dcdc7d2316133b94c146513ee04369d1
3
+ metadata.gz: a4f6109fc15e7bd31378ca4936813572ede6fcd7
4
+ data.tar.gz: 0093982d7f8c2e465766746f71fef462a9e82103
5
5
  SHA512:
6
- metadata.gz: d1e291ba6e0fa81c9616001debbd19c79f26e0152f5a9564c0440644002b8a1c96594a940e8e58f717e7aca90d815838ae49a4de8b5878753f5ea3be14254361
7
- data.tar.gz: 00e5ac2d3da8824231421ea9feddc1c188ed81b03bb3dd9941adffbe5d0a5cb597e86446627926316edaf1d53c6f3a938b887e85181ab3980212d9161632493d
6
+ metadata.gz: 3c56b82fd98cec517334f977bda6f7a40bd166b1091c3ad23a21a2dfbedf63c49aa27158a11047f28e598a6a88a48bfdbad77fe55b6a5e82a08a424a8bdb6b8c
7
+ data.tar.gz: f29604ebbe6ca8963b8be80dbdba463b4e834f02f3b4bfef75202d22faa25042f3fc914c16e68ee5d79faa0168c349a06bc0c33bd86bdbe11a1885799f27b7b8
data/README.md CHANGED
@@ -27,6 +27,6 @@ $ bundle exec inesita server
27
27
 
28
28
  Go to [http://localhost:9292/](http://localhost:9292/)
29
29
 
30
- ## example
30
+ ## examples
31
31
 
32
- [More detailed example Inesita app](https://github.com/fazibear/inesita-example)
32
+ [More detailed example](https://github.com/fazibear/inesita-example)
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'
3
+ s.version = '0.0.4'
4
4
  s.authors = [ 'Michał Kalbarczyk' ]
5
5
  s.email = 'fazibear@gmail.com'
6
6
  s.homepage = 'http://github.com/fazibear/inesita'
data/lib/inesita/cli.rb CHANGED
@@ -1,6 +1,16 @@
1
1
  require 'thor'
2
- require 'rack'
3
2
 
3
+ begin
4
+ require 'bundler'
5
+ Bundler.require
6
+ rescue Bundler::GemfileNotFound
7
+ require 'opal-virtual-dom'
8
+ require 'slim'
9
+ require 'sass'
10
+ require 'inesita/server'
11
+ end
12
+
13
+ require 'rack'
4
14
  require 'inesita/cli/build'
5
15
  require 'inesita/cli/server'
6
16
  require 'inesita/cli/new'
@@ -1,4 +1,5 @@
1
1
  class InesitaCLI < Thor
2
+ include Thor::Actions
2
3
 
3
4
  check_unknown_options!
4
5
 
@@ -6,7 +7,29 @@ class InesitaCLI < Thor
6
7
 
7
8
  desc "build [OPTIONS]", "Build Inesita app"
8
9
 
10
+ method_option :force,
11
+ aliases: ['-f'],
12
+ default: false,
13
+ desc: 'force overwrite'
14
+
15
+ method_option :destination,
16
+ aliases: ['-d', '-dir'],
17
+ default: 'public',
18
+ desc: 'build destination directory'
19
+
9
20
  def build
10
- puts 'building'
21
+ build_dir = options[:destination]
22
+
23
+ assets = Inesita::Server.assets
24
+ Inesita::Server.set_global_vars(assets, false)
25
+
26
+ index = assets['index.html']
27
+ javascript = assets['application.js']
28
+ stylesheet = assets['application.css']
29
+
30
+ empty_directory build_dir, force: options[:force]
31
+ create_file File.join(build_dir, 'index.html'), index.source, force: options[:force]
32
+ create_file File.join(build_dir, 'application.js'), javascript.source, force: options[:force]
33
+ create_file File.join(build_dir, 'application.css'), stylesheet.source, force: options[:force]
11
34
  end
12
35
  end
@@ -7,18 +7,24 @@ class InesitaCLI < Thor
7
7
 
8
8
  desc "new PROJECT_NAME", "Create Inesita app"
9
9
 
10
+ method_option :force,
11
+ aliases: ['-f'],
12
+ default: false,
13
+ desc: 'force overwrite'
14
+
10
15
  def new(project_dir)
11
- empty_directory project_dir
16
+ empty_directory project_dir, force: options[:force]
17
+ copy_file 'template/.gitignore', File.join(project_dir, '.gitignore'), force: options[:force]
12
18
  copy_file 'template/config.ru', File.join(project_dir, 'config.ru'), force: options[:force]
13
19
  copy_file 'template/Gemfile', File.join(project_dir, 'Gemfile'), force: options[:force]
14
20
 
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')
21
+ empty_directory File.join(project_dir, 'app'), force: options[:force]
22
+ copy_file 'template/app/index.html.slim', File.join(project_dir, 'app', 'index.html.slim'), force: options[:force]
23
+ copy_file 'template/app/application.js.rb', File.join(project_dir, 'app', 'application.js.rb'), force: options[:force]
24
+ copy_file 'template/app/application.css.sass', File.join(project_dir, 'app', 'application.css.sass'), force: options[:force]
19
25
 
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')
26
+ empty_directory File.join(project_dir, 'app', 'components'), force: options[:force]
27
+ copy_file 'template/app/components/welcome_component.rb', File.join(project_dir, 'app', 'components', 'welcome_controller.rb'), force: options[:force]
22
28
 
23
29
  inside project_dir do
24
30
  run 'bundle install'
@@ -0,0 +1 @@
1
+ /public
@@ -3,8 +3,11 @@ html
3
3
  head
4
4
  title Inesita
5
5
  link href='application.css' rel='stylesheet' type='text/css'
6
- - $SCRIPT_FILES.each do |file|
7
- script src=file
6
+ - if $SCRIPT_FILES
7
+ - $SCRIPT_FILES.each do |file|
8
+ script src=file
9
+ - else
10
+ script src='application.js'
8
11
  javascript:
9
12
  #{{$LOAD_ASSETS_CODE}}
10
13
  body
@@ -1,4 +1,4 @@
1
1
  require 'bundler'
2
2
  Bundler.require
3
3
 
4
- run Inesita.server
4
+ run Inesita::Server.create
@@ -1,9 +1,11 @@
1
1
  module Inesita
2
- module_function
2
+ module Server
3
+ SOURCE_MAP_PREFIX = '/__OPAL_MAPS__'
3
4
 
4
- def server
5
- Rack::Builder.new do
6
- sprockets = Sprockets::Environment.new.tap do |s|
5
+ module_function
6
+
7
+ def assets
8
+ Sprockets::Environment.new.tap do |s|
7
9
  # register engines
8
10
  s.register_engine '.slim', Slim::Template
9
11
  s.register_engine '.rb', Opal::Processor
@@ -27,22 +29,33 @@ module Inesita
27
29
  end
28
30
  end
29
31
  end
32
+ end
30
33
 
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
34
+ def set_global_vars(assets, debug = false)
35
+ $LOAD_ASSETS_CODE = Opal::Processor.load_asset_code(assets, 'application.js')
36
+ if debug
37
+ $SCRIPT_FILES = (assets['application.js'].dependencies + [assets['application.self.js']]).map(&:logical_path)
39
38
  end
39
+ end
40
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)
41
+ def source_maps(sprockets)
42
+ ::Opal::Sprockets::SourceMapHeaderPatch.inject!(SOURCE_MAP_PREFIX)
43
+ Opal::SourceMapServer.new(sprockets, SOURCE_MAP_PREFIX)
44
+ end
45
+
46
+ def create
47
+ assets_app = assets
48
+ source_maps_app = source_maps(assets_app)
49
+ set_global_vars(assets_app, true)
43
50
 
44
- map '/' do
45
- run sprockets
51
+ Rack::Builder.new do
52
+ map '/' do
53
+ run assets_app
54
+ end
55
+
56
+ map SOURCE_MAP_PREFIX do
57
+ run source_maps_app
58
+ end
46
59
  end
47
60
  end
48
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inesita
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Kalbarczyk
@@ -112,6 +112,7 @@ files:
112
112
  - lib/inesita/cli/build.rb
113
113
  - lib/inesita/cli/new.rb
114
114
  - lib/inesita/cli/server.rb
115
+ - lib/inesita/cli/template/.gitignore
115
116
  - lib/inesita/cli/template/Gemfile
116
117
  - lib/inesita/cli/template/app/application.css.sass
117
118
  - lib/inesita/cli/template/app/application.js.rb