lepidoptera 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lepidoptera.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lepidoptera}
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Duerr"]
12
- s.date = %q{2010-11-19}
12
+ s.date = %q{2010-12-11}
13
13
  s.default_executable = %q{lep}
14
14
  s.description = %q{Lepidoptera is a simple and easy to extend code generator for common every day projects.}
15
15
  s.email = %q{thomduerr@gmail.com}
@@ -49,6 +49,14 @@ Gem::Specification.new do |s|
49
49
  "lib/stub_generators/stub/templates/generator-type_INFO",
50
50
  "lib/stub_generators/stub/templates/generator-type_README.txt",
51
51
  "lib/stub_generators/stub/templates/generator-type_generator.rb",
52
+ "sinatra_generators/activerecord/INFO",
53
+ "sinatra_generators/activerecord/activerecord_generator.rb",
54
+ "sinatra_generators/activerecord/templates/Gemfile",
55
+ "sinatra_generators/activerecord/templates/app.rb",
56
+ "sinatra_generators/activerecord/templates/config.ru",
57
+ "sinatra_generators/activerecord/templates/public/css/main.css",
58
+ "sinatra_generators/activerecord/templates/views/.index.erb.swp",
59
+ "sinatra_generators/activerecord/templates/views/index.haml",
52
60
  "sinatra_generators/base/INFO",
53
61
  "sinatra_generators/base/base_generator.rb",
54
62
  "sinatra_generators/base/templates/Gemfile",
data/lib/butterfly.rb CHANGED
@@ -7,7 +7,7 @@ require 'rubigen'
7
7
  module Butterfly
8
8
 
9
9
  # Current version
10
- VERSION = '0.3.1'
10
+ VERSION = '0.4.0'
11
11
 
12
12
  # local lepidoptera folder
13
13
  DOTFOLDER = '.lepidoptera'
@@ -0,0 +1,19 @@
1
+ =====================================================
2
+ install gems:
3
+ $ bundle install
4
+
5
+ start sinatra application on localhost:
6
+ $ rackup
7
+
8
+ deploy sinatra project on heroku:
9
+ <% if !gitinit then %>
10
+ $ git init
11
+ [do your work...]
12
+ <% end %>
13
+ $ heroku create <%= name %>
14
+ $ git push heroku master
15
+ $ heroku open
16
+ ======================================================
17
+ Documentation can be found at
18
+ http://www.sinatrarb.com
19
+ http://ar.rubyonrails.org/
@@ -0,0 +1,59 @@
1
+ class ActiverecordGenerator < Butterfly::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+
6
+ # Create a directory including any missing parent directories.
7
+ # Always skips directories which exist.
8
+ m.directory "public/css"
9
+ m.directory "public/images"
10
+ m.directory "public/js"
11
+ m.directory "views"
12
+
13
+ # Generate a file using an ERuby template.
14
+ # Looks up and evaluates a template by name and writes the result.
15
+ #
16
+ # The ERB template uses explicit trim mode to best control the
17
+ # proliferation of whitespace in generated code. <%- trims leading
18
+ # whitespace; -%> trims trailing whitespace including one newline.
19
+ #
20
+ # A hash of template options may be passed as the last argument.
21
+ # The options accepted by the file are accepted as well as :assigns,
22
+ # a hash of variable bindings. Example:
23
+ # template 'foo', 'bar', :assigns => { :action => 'view' }
24
+ #
25
+ # Template is implemented in terms of file. It calls file with a
26
+ # block which takes a file handle and returns its rendered contents.
27
+ m.template "app.rb", "#{@name}.rb"
28
+
29
+ m.template_copy_each %w(
30
+ config.ru
31
+ public/css/main.css
32
+ views/index.haml
33
+ )
34
+
35
+ # Copy a file from source to destination with collision checking.
36
+ #
37
+ # The file_options hash accepts :chmod and :shebang and :collision options.
38
+ # :chmod sets the permissions of the destination file:
39
+ # file 'config/empty.log', 'log/test.log', :chmod => 0664
40
+ # :shebang sets the #!/usr/bin/ruby line for scripts
41
+ # file 'bin/generate.rb', 'script/generate', :chmod => 0755, :shebang => '/usr/bin/env ruby'
42
+ # :collision sets the collision option only for the destination file:
43
+ # file 'settings/server.yml', 'config/server.yml', :collision => :skip
44
+ #
45
+ # Collisions are handled by checking whether the destination file
46
+ # exists and either skipping the file, forcing overwrite, or asking
47
+ # the user what to do.
48
+ # m.file "models.rb", "models.rb"
49
+
50
+ # Copy files from source to destination using the same path and name
51
+ m.file_copy_each %w(
52
+ Gemfile
53
+ )
54
+
55
+ end
56
+ end
57
+
58
+ end
59
+
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "haml", "3.0.23"
4
+ gem "sinatra", "1.1.0"
5
+ gem "do_sqlite3", "0.10.2"
6
+ gem "activerecord", "3.0.0"
@@ -0,0 +1,42 @@
1
+ require "rubygems"
2
+ require "sinatra"
3
+ require "active_record"
4
+ require 'haml'
5
+
6
+
7
+ # Database Object Model
8
+
9
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "<%= name.pluralize %>.sqlite3")
10
+
11
+ class Migrate < ActiveRecord::Migration
12
+ def self.up
13
+ create_table :<%= name.pluralize %> do |t|
14
+ t.text :body
15
+ t.string :title
16
+ end
17
+ end
18
+
19
+ def self.down
20
+ drop_table :<%= name.pluralize %>s
21
+ end
22
+ end
23
+
24
+ class <%= name.classify %> < ActiveRecord::Base
25
+ end
26
+
27
+ Migrate.up unless <%= name.classify %>.table_exists?
28
+
29
+
30
+ # Controller
31
+
32
+ get '/' do
33
+ @<%= name.pluralize %> = <%= name.classify %>.find(:all)
34
+ haml :index
35
+ end
36
+
37
+ post '/' do
38
+ <%= name.classify %>.delete(<%= name.classify %>.find(:first)) until <%= name.classify %>.count(:all) < 5
39
+ @<%= name %> = <%= name.classify %>.new(:title => params[:title], :body => params[:body])
40
+ @<%= name %>.save
41
+ redirect '/'
42
+ end
@@ -0,0 +1,2 @@
1
+ require File.dirname(__FILE__) + '/<%= name %>.rb'
2
+ run Sinatra::Application
@@ -0,0 +1,24 @@
1
+ body {
2
+ font: normal normal normal 12px/1.5 Helvetica,sans-serif;
3
+ }
4
+
5
+ .<%= name.dasherize %> {
6
+ background: #EEE;
7
+ margin: 20px auto;
8
+ width: 500px;
9
+ padding: 1px 10px;
10
+ }
11
+
12
+ .<%= name.dasherize %> h1,
13
+ .<%= name.dasherize %> h1 input {
14
+ font-weight: bold;
15
+ font-size: 16px;
16
+ }
17
+
18
+ .<%= name.dasherize %> h1 input,
19
+ .<%= name.dasherize %> p textarea {
20
+ border: none;
21
+ width: 490px;
22
+ padding: 5px;
23
+ }
24
+
@@ -0,0 +1,20 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %meta{:charset => "UTF-8"}/
5
+ %title <%= name.titleize %>
6
+ %link{:rel => "stylesheet", :href => "css/main.css"}
7
+ %body
8
+ - @<%= name.pluralize %>.each do |<%= name %>|
9
+ .<%= name.dasherize %>
10
+ %h1
11
+ = <%= name %>.title
12
+ %p
13
+ = <%= name %>.body
14
+ .<%= name.dasherize %>
15
+ %form{:action => "/", :method => "post", :class => "post"}
16
+ %h1
17
+ %input{:name => "title"}
18
+ %p
19
+ %textarea{:rows => 5, :name => "body"}
20
+ %input{:type => "submit", :value => "add <%= name.humanize %>"}
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 1
9
- version: 0.3.1
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Thomas Duerr
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-19 00:00:00 +01:00
17
+ date: 2010-12-11 00:00:00 +01:00
18
18
  default_executable: lep
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -102,6 +102,14 @@ files:
102
102
  - lib/stub_generators/stub/templates/generator-type_INFO
103
103
  - lib/stub_generators/stub/templates/generator-type_README.txt
104
104
  - lib/stub_generators/stub/templates/generator-type_generator.rb
105
+ - sinatra_generators/activerecord/INFO
106
+ - sinatra_generators/activerecord/activerecord_generator.rb
107
+ - sinatra_generators/activerecord/templates/Gemfile
108
+ - sinatra_generators/activerecord/templates/app.rb
109
+ - sinatra_generators/activerecord/templates/config.ru
110
+ - sinatra_generators/activerecord/templates/public/css/main.css
111
+ - sinatra_generators/activerecord/templates/views/.index.erb.swp
112
+ - sinatra_generators/activerecord/templates/views/index.haml
105
113
  - sinatra_generators/base/INFO
106
114
  - sinatra_generators/base/base_generator.rb
107
115
  - sinatra_generators/base/templates/Gemfile