pyro 0.8.0
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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +115 -0
- data/Rakefile +11 -0
- data/bin/pyro +34 -0
- data/lib/pyro/assets/scripts.rb +47 -0
- data/lib/pyro/assets/stylesheets.rb +53 -0
- data/lib/pyro/assets/templates.rb +36 -0
- data/lib/pyro/server.rb +23 -0
- data/lib/pyro.rb +33 -0
- data/pyro.gemspec +25 -0
- data/template/assets/img/favicon.ico +0 -0
- data/template/lib/app.coffee +10 -0
- data/template/lib/index.erb +19 -0
- data/template/lib/stylesheets/normalize.css +402 -0
- data/template/lib/stylesheets/style.css +4 -0
- data/template/lib/templates/application.hbs +3 -0
- data/template/lib/templates/index.hbs +5 -0
- data/template/vendor/ember/ember-1.0.0-rc.7.js +32846 -0
- data/template/vendor/ember/ember-data-0.13.js +8887 -0
- data/template/vendor/handlebars/handlebars-1.0.0.js +2278 -0
- data/template/vendor/jquery/jquery-1.9.1.js +9597 -0
- metadata +181 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Jarrod Taylor
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
> **DISCLAIMER**: A lot of this is still being developed.
|
2
|
+
|
3
|
+
> Consider this readme a preview of code to come. (see: [Readme Driven Development](http://tom.preston-werner.com/2010/08/23/readme-driven-development.html))
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
# Pyro
|
8
|
+
|
9
|
+
> Build Ember.js apps with CoffeeScript and Sass... without all that damn configuration.
|
10
|
+
|
11
|
+
Pyro is a Ruby gem for building Ember.js apps. Under the hood, it's a build script wrapped in a web server.
|
12
|
+
|
13
|
+
## tl;dr
|
14
|
+
|
15
|
+
```bash
|
16
|
+
~ $ gem install pyro
|
17
|
+
~ $ pyro new MyApp
|
18
|
+
~ $ cd MyApp
|
19
|
+
~/MyApp $ pyro serve
|
20
|
+
# => http://localhost:5678
|
21
|
+
```
|
22
|
+
|
23
|
+
## Install Pyro
|
24
|
+
|
25
|
+
From Rubygems.org:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
~ $ gem install pyro
|
29
|
+
```
|
30
|
+
|
31
|
+
This will install the Pyro CLI that you'll use to create, build, and serve your Ember.js apps.
|
32
|
+
|
33
|
+
## Create a New App
|
34
|
+
|
35
|
+
The ```pyro new``` command will generate a new app:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
~ $ pyro new MyApp
|
39
|
+
~ $ cd MyApp
|
40
|
+
```
|
41
|
+
|
42
|
+
Your app starts with three folders.
|
43
|
+
|
44
|
+
- ```/assets``` for storing static files.
|
45
|
+
- ```/lib``` for writing your code.
|
46
|
+
- ```/vendor``` for storing third party code.
|
47
|
+
|
48
|
+
```/vendor``` comes preloaded with jQuery, Handlebars, Ember, and Ember Data.
|
49
|
+
|
50
|
+
```/lib``` is the basic Ember Starter Kit, rewritten in CoffeeScript and placed in a sensible default folder structure.
|
51
|
+
|
52
|
+
Consider this your starting point. From here, add write your app in any combination CoffeeScript, JavaScript, Sass, Less, and CSS. Put your code in a file structure that makes sense, and link it all together in ```/lib/index.erb```.
|
53
|
+
|
54
|
+
Pyro comes with a few Ruby helpers to make it easier:
|
55
|
+
|
56
|
+
```erb
|
57
|
+
<%= stylesheet src: 'css/bootstrap.css' %>
|
58
|
+
<%= stylesheet dir: 'css/themes' %>
|
59
|
+
|
60
|
+
<%= template src: 'views/application.hbs' %>
|
61
|
+
<%= template dir: 'views/components' %>
|
62
|
+
|
63
|
+
<%= script src: 'app.coffee' %>
|
64
|
+
<%= script dir: 'models' %>
|
65
|
+
```
|
66
|
+
|
67
|
+
All three helpers can accept either a single file (```src:```) or a directory (```dir:```). During the build process, scripts and stylesheets are compiled and linked to in place of the helper. Templates are inserted inline.
|
68
|
+
|
69
|
+
Using these helpers lets your organize your application's folder structure and your code's load order without having to edit any config files or build scripts.
|
70
|
+
|
71
|
+
## Scripts, Stylesheets, and Templates
|
72
|
+
|
73
|
+
Pyro uses file extensions to determine how to compile your and link to your code. Supported languages include:
|
74
|
+
|
75
|
+
- CoffeeScript (.coffee)
|
76
|
+
- JavaScript (.js)
|
77
|
+
- Sass (.scss)
|
78
|
+
- Less (.less)
|
79
|
+
- CSS (.css)
|
80
|
+
- Handlebars (.hbs, .handlebars, .x-handlebars)
|
81
|
+
|
82
|
+
> Templates are given a ```data-template-name``` attribute with a value matching their filename.
|
83
|
+
|
84
|
+
## The Development Server
|
85
|
+
|
86
|
+
The ```pyro serve``` command loads your app into a built-in dev server:
|
87
|
+
|
88
|
+
```bash
|
89
|
+
~/MyApp $ pyro serve
|
90
|
+
# => http://localhost:5678
|
91
|
+
```
|
92
|
+
|
93
|
+
Just start the server and visit [localhost:5678](http://localhost:5678).
|
94
|
+
|
95
|
+
If you want to skip building ```/assets``` and ```/vendor``` on reloads, just pass the ```--fast``` option.
|
96
|
+
|
97
|
+
```bash
|
98
|
+
~/MyApp $ pyro serve --fast
|
99
|
+
# => http://localhost:5678
|
100
|
+
```
|
101
|
+
|
102
|
+
Everything will be built on the first page load, but reloads will only rebuild ```/lib```. This is useful for speeding up builds with large asset files and vendor libraries that rarely change.
|
103
|
+
|
104
|
+
## Production Builds
|
105
|
+
|
106
|
+
When you're ready to deploy, the ```pyro build``` command will compile and minify your app into ```/builds/production/<timestamp>```:
|
107
|
+
|
108
|
+
```bash
|
109
|
+
~/MyApp $ pyro build
|
110
|
+
# => MyApp is compiled and minified into ~/MyApp/builds/production/20130816020233/
|
111
|
+
```
|
112
|
+
|
113
|
+
> You may want to add your release folders to your .gitignore file.
|
114
|
+
|
115
|
+
Now you're ready to deploy your app to a production server.
|
data/Rakefile
ADDED
data/bin/pyro
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'pyro'
|
5
|
+
|
6
|
+
class PyroCLI < Thor
|
7
|
+
|
8
|
+
desc 'new NAME', 'Creats a new app'
|
9
|
+
def new(name)
|
10
|
+
FileUtils.cp_r("#{File.dirname(__FILE__)}/../template", name)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'build', 'Builds the app for production'
|
14
|
+
def build
|
15
|
+
Pyro.build
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'serve', 'Starts a Pyro app on localhost, --fast skips asset reloading'
|
19
|
+
option :fast
|
20
|
+
def serve
|
21
|
+
require 'pyro/server'
|
22
|
+
|
23
|
+
if options[:fast]
|
24
|
+
PyroServer.set :fast, true
|
25
|
+
else
|
26
|
+
PyroServer.set :fast, false
|
27
|
+
end
|
28
|
+
|
29
|
+
PyroServer.run!
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
PyroCLI.start(ARGV)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'coffee-script'
|
3
|
+
|
4
|
+
module Pyro
|
5
|
+
module Assets
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
|
12
|
+
def script *args
|
13
|
+
args = args.first
|
14
|
+
|
15
|
+
scripts = []
|
16
|
+
scripts << "./lib/#{args[:src]}" if args[:src]
|
17
|
+
if args[:dir]
|
18
|
+
Dir.glob("./lib/#{args[:dir]}/**/*.{js,coffee}").each do |f|
|
19
|
+
scripts << f
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
tags = ''
|
24
|
+
scripts.each do |s|
|
25
|
+
file_name = s.split('/').last
|
26
|
+
extension = s.split('.').last
|
27
|
+
name = file_name.sub(".#{extension}", '')
|
28
|
+
path = s.sub(file_name, '')
|
29
|
+
build_path = path.sub('./', "#{$build_dir}/")
|
30
|
+
FileUtils.mkdir_p(build_path)
|
31
|
+
|
32
|
+
contents = File.read(s)
|
33
|
+
contents = CoffeeScript.compile(contents) if extension == 'coffee'
|
34
|
+
|
35
|
+
File.open("#{build_path}/#{name}.js", 'w+') do |f|
|
36
|
+
f.write(contents)
|
37
|
+
end
|
38
|
+
|
39
|
+
tags << "<script src='#{s.gsub(extension, 'js')}?#{$timestamp}' type='text/javascript'></script>"
|
40
|
+
end
|
41
|
+
|
42
|
+
tags
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'less'
|
3
|
+
require 'sass'
|
4
|
+
|
5
|
+
module Pyro
|
6
|
+
module Assets
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
|
13
|
+
def stylesheet *args
|
14
|
+
args = args.first
|
15
|
+
|
16
|
+
stylesheets = []
|
17
|
+
stylesheets << "./lib/#{args[:src]}" if args[:src]
|
18
|
+
if args[:dir]
|
19
|
+
Dir.glob("./lib/#{args[:dir]}/**/*.{css,scss,less}").each do |f|
|
20
|
+
stylesheets << f
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
tags = ''
|
25
|
+
stylesheets.each do |s|
|
26
|
+
file_name = s.split('/').last
|
27
|
+
extension = s.split('.').last
|
28
|
+
name = file_name.sub(".#{extension}", '')
|
29
|
+
path = s.sub(file_name, '')
|
30
|
+
build_path = path.sub('./', "#{$build_dir}/")
|
31
|
+
FileUtils.mkdir_p(build_path)
|
32
|
+
|
33
|
+
contents = File.read(s)
|
34
|
+
case extension
|
35
|
+
when 'scss'
|
36
|
+
contents = Sass::Engine.for_file(s, { style: :expanded }).render
|
37
|
+
when 'less'
|
38
|
+
contents = Less::Parser.new.parse(contents).to_css
|
39
|
+
end
|
40
|
+
|
41
|
+
File.open("#{build_path}/#{name}.css", 'w+') do |f|
|
42
|
+
f.write(contents)
|
43
|
+
end
|
44
|
+
|
45
|
+
tags << "<link rel='stylesheet' href='#{s.gsub(extension, 'css')}?#{$timestamp}' type='text/css' />"
|
46
|
+
end
|
47
|
+
|
48
|
+
tags
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Pyro
|
4
|
+
module Assets
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def template *args
|
12
|
+
args = args.first
|
13
|
+
|
14
|
+
templates = []
|
15
|
+
templates << "./lib/#{args[:src]}" if args[:src]
|
16
|
+
if args[:dir]
|
17
|
+
Dir.glob("./lib/#{args[:dir]}/**/*.{hbs, handlebars,x-handlebars}").each do |f|
|
18
|
+
templates << f
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
tags = ''
|
23
|
+
templates.each do |t|
|
24
|
+
contents = File.read t
|
25
|
+
name = t.split('/').last.split('.').first
|
26
|
+
tags << "\n<script type='text/x-handlebars' data-template-name='#{name}'>\n"
|
27
|
+
tags << contents
|
28
|
+
tags << "\n</script>\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
tags
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/pyro/server.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pyro'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
class PyroServer < Sinatra::Base
|
6
|
+
include Pyro
|
7
|
+
|
8
|
+
set :port, 5678
|
9
|
+
set :public_folder, './builds/development'
|
10
|
+
set :fast_build, false
|
11
|
+
|
12
|
+
#helpers do
|
13
|
+
# define_method(:script) { |*args| Pyro.script public_folder, args }
|
14
|
+
# define_method(:stylesheet) { |*args| Pyro.stylesheet args }
|
15
|
+
# define_method(:template) { |*args| Pyro.template args }
|
16
|
+
#end
|
17
|
+
|
18
|
+
get '/?' do
|
19
|
+
Pyro.build('development', settings.fast_build)
|
20
|
+
settings.fast_build = settings.fast
|
21
|
+
File.read('./builds/development/index.html')
|
22
|
+
end
|
23
|
+
end
|
data/lib/pyro.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'pyro/assets/scripts'
|
3
|
+
require 'pyro/assets/stylesheets'
|
4
|
+
require 'pyro/assets/templates'
|
5
|
+
|
6
|
+
module Pyro
|
7
|
+
include Pyro::Assets
|
8
|
+
|
9
|
+
def self.build(target = 'production', fast = false)
|
10
|
+
unless File.exists? './lib/index.erb'
|
11
|
+
raise 'Can\'t find an index.erb file to build.'
|
12
|
+
end
|
13
|
+
|
14
|
+
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
15
|
+
|
16
|
+
if target == 'development'
|
17
|
+
$build_dir = './builds/development'
|
18
|
+
else
|
19
|
+
$build_dir = "./builds/production/#{$timestamp}"
|
20
|
+
end
|
21
|
+
|
22
|
+
FileUtils.mkdir_p($build_dir)
|
23
|
+
|
24
|
+
unless fast
|
25
|
+
FileUtils.cp_r('./assets/.', $build_dir)
|
26
|
+
FileUtils.cp_r('./vendor', $build_dir)
|
27
|
+
end
|
28
|
+
|
29
|
+
File.open("#{$build_dir}/index.html", 'w+') do |index|
|
30
|
+
index.write( ERB.new(File.read './lib/index.erb').result(binding) )
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/pyro.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "pyro"
|
7
|
+
gem.version = "0.8.0"
|
8
|
+
gem.authors = "Jarrod Taylor"
|
9
|
+
gem.email = "jarrodtaylor@icloud.com"
|
10
|
+
gem.summary = "Build web apps with CoffeeScript and Sass... without all that damn configuration."
|
11
|
+
gem.homepage = "https://github.com/jarrodtaylor/pyro"
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($/)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
gem.add_dependency 'coffee-script'
|
19
|
+
gem.add_dependency 'jsmin'
|
20
|
+
gem.add_dependency 'less'
|
21
|
+
gem.add_dependency 'rake'
|
22
|
+
gem.add_dependency 'sass'
|
23
|
+
gem.add_dependency 'sinatra'
|
24
|
+
gem.add_dependency 'thor'
|
25
|
+
end
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Ember Starter Kit</title>
|
6
|
+
<%= stylesheet src: 'stylesheets/normalize.css' %>
|
7
|
+
<%= stylesheet src: 'stylesheets/style.css' %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%= template dir: 'templates' %>
|
11
|
+
|
12
|
+
<script src="/vendor/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="/vendor/handlebars/handlebars-1.0.0.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="/vendor/ember/ember-1.0.0-rc.7.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="/vendor/ember/ember-data-0.13.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
<%= script src: 'app.coffee' %>
|
18
|
+
</body>
|
19
|
+
</html>
|