this_town 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -1
- data/lib/this_town/generator.rb +4 -8
- data/lib/this_town/version.rb +1 -1
- data/templates/Gemfile.erb +0 -19
- data/templates/Guardfile +1 -7
- data/templates/lib/newgem.rb.erb +0 -2
- data/templates/lib/newgem/application.rb.erb +1 -8
- data/templates/newgem.gemspec.erb +11 -1
- data/templates/{templates/index.mustache → views/index.erb} +0 -0
- data/templates/{templates/layout.mustache.erb → views/layout.erb.erb} +1 -2
- metadata +4 -8
- data/templates/lib/newgem/views.rb.erb +0 -4
- data/templates/lib/newgem/views/index.rb.erb +0 -6
- data/templates/lib/newgem/views/layout.rb.erb +0 -6
- data/templates/public/jquery.mustache.min.js +0 -6
data/README.md
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
following libraries:
|
5
5
|
|
6
6
|
* database: [sequel](http://sequel.rubyforge.org/)
|
7
|
-
* templates: [mustache](https://github.com/defunkt/mustache)
|
8
7
|
* testing: [test-unit](http://test-unit.rubyforge.org/) and [rack-test](https://github.com/brynary/rack-test)
|
9
8
|
* mocking: [mocha](http://gofreerange.com/mocha/docs/)
|
10
9
|
* automation: [guard](https://github.com/guard/guard)
|
data/lib/this_town/generator.rb
CHANGED
@@ -43,7 +43,7 @@ module ThisTown
|
|
43
43
|
|
44
44
|
def run
|
45
45
|
directory "db/migrate"
|
46
|
-
directory "
|
46
|
+
directory "views"
|
47
47
|
|
48
48
|
# root
|
49
49
|
root_templates = %w{Gemfile LICENSE.txt README.md Rakefile config.ru}
|
@@ -58,13 +58,10 @@ module ThisTown
|
|
58
58
|
template "lib/newgem.rb", "lib/#{@gem_name}.rb"
|
59
59
|
template "lib/newgem/version.rb", "lib/#{@gem_name}/version.rb"
|
60
60
|
template "lib/newgem/application.rb", "lib/#{@gem_name}/application.rb"
|
61
|
-
template "lib/newgem/views.rb", "lib/#{@gem_name}/views.rb"
|
62
|
-
template "lib/newgem/views/layout.rb", "lib/#{@gem_name}/views/layout.rb"
|
63
|
-
template "lib/newgem/views/index.rb", "lib/#{@gem_name}/views/index.rb"
|
64
61
|
|
65
|
-
#
|
66
|
-
template "
|
67
|
-
file "
|
62
|
+
# views
|
63
|
+
template "views/layout.erb"
|
64
|
+
file "views/index.erb"
|
68
65
|
|
69
66
|
# config
|
70
67
|
template "config/database.yml"
|
@@ -77,7 +74,6 @@ module ThisTown
|
|
77
74
|
file "public/reset.css"
|
78
75
|
file "public/style.css"
|
79
76
|
fetch "http://code.jquery.com/jquery-latest.min.js", "public/jquery.min.js"
|
80
|
-
file "public/jquery.mustache.min.js"
|
81
77
|
|
82
78
|
Dir.chdir(@destination_root) do
|
83
79
|
`git init && git add .`
|
data/lib/this_town/version.rb
CHANGED
data/templates/Gemfile.erb
CHANGED
@@ -2,22 +2,3 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in <%= gem_name %>.gemspec
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem 'sqlite3'
|
8
|
-
gem 'test-unit'
|
9
|
-
gem 'rack-test'
|
10
|
-
gem 'mocha'
|
11
|
-
gem 'rake'
|
12
|
-
|
13
|
-
# Guard gems
|
14
|
-
gem 'guard'
|
15
|
-
gem 'guard-test'
|
16
|
-
gem 'guard-rack'
|
17
|
-
gem 'guard-bundler'
|
18
|
-
gem 'guard-shell'
|
19
|
-
gem 'rb-inotify', '~> 0.8.8', :require => false
|
20
|
-
gem 'rb-fsevent', :require => false
|
21
|
-
gem 'rb-fchange', :require => false
|
22
|
-
gem 'wdm', :platforms => [:mswin, :mingw], :require => false
|
23
|
-
end
|
data/templates/Guardfile
CHANGED
@@ -11,13 +11,7 @@ guard 'test' do
|
|
11
11
|
end
|
12
12
|
watch(%r{^test/((?:[^/]+\/)*)test.+\.rb$})
|
13
13
|
watch('test/helper.rb') { 'test' }
|
14
|
-
watch(%r{^
|
15
|
-
if m[1]
|
16
|
-
"test/unit/extensions/test_#{m[1]}.rb"
|
17
|
-
else
|
18
|
-
'test/unit/test_application.rb'
|
19
|
-
end
|
20
|
-
end
|
14
|
+
watch(%r{^views/.+\.erb$}) { 'test/unit/test_application.rb' }
|
21
15
|
end
|
22
16
|
|
23
17
|
guard 'bundler' do
|
data/templates/lib/newgem.rb.erb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require 'mustache/sinatra'
|
3
2
|
require 'sequel'
|
4
3
|
require 'erb'
|
5
4
|
require 'yaml'
|
@@ -22,5 +21,4 @@ require 'logger'
|
|
22
21
|
<%- end -%>
|
23
22
|
|
24
23
|
require "<%= gem_name %>/version"
|
25
|
-
require "<%= gem_name %>/views"
|
26
24
|
require "<%= gem_name %>/application"
|
@@ -1,17 +1,10 @@
|
|
1
1
|
<%- code do -%>
|
2
2
|
class Application < Sinatra::Base
|
3
|
-
register Mustache::Sinatra
|
4
|
-
|
5
3
|
set :root, Root.to_s
|
6
|
-
set :mustache, {
|
7
|
-
:templates => (Root + 'templates').to_s,
|
8
|
-
:views => (Root + 'lib' + '<%= gem_name %>' + 'views').to_s,
|
9
|
-
:namespace => <%= constant_name %>
|
10
|
-
}
|
11
4
|
enable :reload_templates if development?
|
12
5
|
|
13
6
|
get "/" do
|
14
|
-
|
7
|
+
erb :index
|
15
8
|
end
|
16
9
|
end
|
17
10
|
<%- end -%>
|
@@ -19,5 +19,15 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_dependency 'sinatra'
|
21
21
|
gem.add_dependency 'sequel'
|
22
|
-
gem.
|
22
|
+
gem.add_development_dependency 'bundler'
|
23
|
+
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'sqlite3'
|
25
|
+
gem.add_development_dependency 'test-unit'
|
26
|
+
gem.add_development_dependency 'rack-test'
|
27
|
+
gem.add_development_dependency 'mocha'
|
28
|
+
gem.add_development_dependency 'guard'
|
29
|
+
gem.add_development_dependency 'guard-test'
|
30
|
+
gem.add_development_dependency 'guard-rack'
|
31
|
+
gem.add_development_dependency 'guard-bundler'
|
32
|
+
gem.add_development_dependency 'guard-shell'
|
23
33
|
end
|
File without changes
|
@@ -6,11 +6,10 @@
|
|
6
6
|
<link rel="stylesheet" type="text/css" href="/reset.css" />
|
7
7
|
<link rel="stylesheet" type="text/css" href="/style.css" />
|
8
8
|
<script type="text/javascript" src="/jquery.min.js"></script>
|
9
|
-
<script type="text/javascript" src="/jquery.mustache.min.js"></script>
|
10
9
|
</head>
|
11
10
|
|
12
11
|
<body>
|
13
|
-
|
12
|
+
<%%= yield %>
|
14
13
|
</body>
|
15
14
|
|
16
15
|
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: this_town
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Gem generator for Sinatra applications that use the following libraries:
|
15
15
|
sequel, mustache, test-unit, rack-test, mocha, guard'
|
@@ -41,17 +41,13 @@ files:
|
|
41
41
|
- templates/lib/newgem.rb.erb
|
42
42
|
- templates/lib/newgem/application.rb.erb
|
43
43
|
- templates/lib/newgem/version.rb.erb
|
44
|
-
- templates/lib/newgem/views.rb.erb
|
45
|
-
- templates/lib/newgem/views/index.rb.erb
|
46
|
-
- templates/lib/newgem/views/layout.rb.erb
|
47
44
|
- templates/newgem.gemspec.erb
|
48
|
-
- templates/public/jquery.mustache.min.js
|
49
45
|
- templates/public/reset.css
|
50
46
|
- templates/public/style.css
|
51
|
-
- templates/templates/index.mustache
|
52
|
-
- templates/templates/layout.mustache.erb
|
53
47
|
- templates/test/helper.rb.erb
|
54
48
|
- templates/test/unit/test_application.rb.erb
|
49
|
+
- templates/views/index.erb
|
50
|
+
- templates/views/layout.erb.erb
|
55
51
|
- this_town.gemspec
|
56
52
|
homepage: ''
|
57
53
|
licenses: []
|
@@ -1,6 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Shameless port of a shameless port
|
3
|
-
@defunkt => @janl => @aq
|
4
|
-
|
5
|
-
See http://github.com/defunkt/mustache for more info.
|
6
|
-
*/(function(e){(function(e,t){typeof exports=="object"&&exports?module.exports=t:typeof define=="function"&&define.amd?define(t):e.Mustache=t})(this,function(){function f(e,t){return u.call(e,t)}function l(e){return!f(r,e)}function h(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function d(e){return String(e).replace(/[&<>"'\/]/g,function(e){return p[e]})}function v(e){this.string=e,this.tail=e,this.pos=0}function m(e,t){this.view=e,this.parent=t,this._cache={}}function g(){this.clearCache()}function y(t,n,r,i){var s="",o,u,a;for(var f=0,l=t.length;f<l;++f){o=t[f],u=o[1];switch(o[0]){case"#":a=r.lookup(u);if(typeof a=="object")if(c(a))for(var h=0,p=a.length;h<p;++h)s+=y(o[4],n,r.push(a[h]),i);else a&&(s+=y(o[4],n,r.push(a),i));else if(typeof a=="function"){var d=i==null?null:i.slice(o[3],o[5]);a=a.call(r.view,d,function(e){return n.render(e,r)}),a!=null&&(s+=a)}else a&&(s+=y(o[4],n,r,i));break;case"^":a=r.lookup(u);if(!a||c(a)&&a.length===0)s+=y(o[4],n,r,i);break;case">":a=n.getPartial(u),typeof a=="function"&&(s+=a(r));break;case"&":a=r.lookup(u),a!=null&&(s+=a);break;case"name":a=r.lookup(u),a!=null&&(s+=e.escape(a));break;case"text":s+=u}}return s}function b(e){var t=[],n=t,r=[],i;for(var s=0,o=e.length;s<o;++s){i=e[s];switch(i[0]){case"#":case"^":r.push(i),n.push(i),n=i[4]=[];break;case"/":var u=r.pop();u[5]=i[2],n=r.length>0?r[r.length-1][4]:t;break;default:n.push(i)}}return t}function w(e){var t=[],n,r;for(var i=0,s=e.length;i<s;++i)n=e[i],n&&(n[0]==="text"&&r&&r[0]==="text"?(r[1]+=n[1],r[3]=n[3]):(r=n,t.push(n)));return t}function E(e){return[new RegExp(h(e[0])+"\\s*"),new RegExp("\\s*"+h(e[1]))]}var e={};e.name="mustache.js",e.version="0.7.2",e.tags=["{{","}}"],e.Scanner=v,e.Context=m,e.Writer=g;var t=/\s*/,n=/\s+/,r=/\S/,i=/\s*=/,s=/\s*\}/,o=/#|\^|\/|>|\{|&|=|!/,u=RegExp.prototype.test,a=Object.prototype.toString,c=Array.isArray||function(e){return a.call(e)==="[object Array]"},p={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};e.escape=d,v.prototype.eos=function(){return this.tail===""},v.prototype.scan=function(e){var t=this.tail.match(e);return t&&t.index===0?(this.tail=this.tail.substring(t[0].length),this.pos+=t[0].length,t[0]):""},v.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.pos+=this.tail.length,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n),this.pos+=n}return t},m.make=function(e){return e instanceof m?e:new m(e)},m.prototype.push=function(e){return new m(e,this)},m.prototype.lookup=function(e){var t=this._cache[e];if(!t){if(e==".")t=this.view;else{var n=this;while(n){if(e.indexOf(".")>0){t=n.view;var r=e.split("."),i=0;while(t&&i<r.length)t=t[r[i++]]}else t=n.view[e];if(t!=null)break;n=n.parent}}this._cache[e]=t}return typeof t=="function"&&(t=t.call(this.view)),t},g.prototype.clearCache=function(){this._cache={},this._partialCache={}},g.prototype.compile=function(t,n){var r=this._cache[t];if(!r){var i=e.parse(t,n);r=this._cache[t]=this.compileTokens(i,t)}return r},g.prototype.compilePartial=function(e,t,n){var r=this.compile(t,n);return this._partialCache[e]=r,r},g.prototype.getPartial=function(e){return!(e in this._partialCache)&&this._loadPartial&&this.compilePartial(e,this._loadPartial(e)),this._partialCache[e]},g.prototype.compileTokens=function(e,t){var n=this;return function(r,i){if(i)if(typeof i=="function")n._loadPartial=i;else for(var s in i)n.compilePartial(s,i[s]);return y(e,n,m.make(r),t)}},g.prototype.render=function(e,t,n){return this.compile(e)(t,n)},e.parse=function(r,u){function y(){if(m&&!g)while(d.length)delete p[d.pop()];else d=[];m=!1,g=!1}r=r||"",u=u||e.tags,typeof u=="string"&&(u=u.split(n));if(u.length!==2)throw new Error("Invalid tags: "+u.join(", "));var a=E(u),f=new v(r),c=[],p=[],d=[],m=!1,g=!1,S,x,T,N,C;while(!f.eos()){S=f.pos,T=f.scanUntil(a[0]);if(T)for(var k=0,L=T.length;k<L;++k)N=T.charAt(k),l(N)?d.push(p.length):g=!0,p.push(["text",N,S,S+1]),S+=1,N=="\n"&&y();if(!f.scan(a[0]))break;m=!0,x=f.scan(o)||"name",f.scan(t),x==="="?(T=f.scanUntil(i),f.scan(i),f.scanUntil(a[1])):x==="{"?(T=f.scanUntil(new RegExp("\\s*"+h("}"+u[1]))),f.scan(s),f.scanUntil(a[1]),x="&"):T=f.scanUntil(a[1]);if(!f.scan(a[1]))throw new Error("Unclosed tag at "+f.pos);C=[x,T,S,f.pos],p.push(C);if(x==="#"||x==="^")c.push(C);else if(x==="/"){if(c.length===0)throw new Error('Unopened section "'+T+'" at '+S);var A=c.pop();if(A[1]!==T)throw new Error('Unclosed section "'+A[1]+'" at '+S)}else if(x==="name"||x==="{"||x==="&")g=!0;else if(x==="="){u=T.split(n);if(u.length!==2)throw new Error("Invalid tags at "+S+": "+u.join(", "));a=E(u)}}var A=c.pop();if(A)throw new Error('Unclosed section "'+A[1]+'" at '+f.pos);return p=w(p),b(p)};var S=new g;return e.clearCache=function(){return S.clearCache()},e.compile=function(e,t){return S.compile(e,t)},e.compilePartial=function(e,t,n){return S.compilePartial(e,t,n)},e.compileTokens=function(e,t){return S.compileTokens(e,t)},e.render=function(e,t,n){return S.render(e,t,n)},e.to_html=function(t,n,r,i){var s=e.render(t,n,r);if(typeof i!="function")return s;i(s)},e}()),e.mustache=function(e,t,n){return Mustache.render(e,t,n)},e.fn.mustache=function(t,n){return e(this).map(function(r,i){var s=e.trim(e(i).html()),o=e.mustache(s,t,n);return e(o).get()})}})(jQuery);
|