sweetsinatra 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/sweetsinatra +3 -0
- data/lib/sweetsinatra.rb +133 -0
- data/lib/sweetsinatra/version.rb +3 -0
- data/sweetsinatra-0.0.1.gem +0 -0
- data/sweetsinatra.gemspec +24 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGZjMDdlZmE4ZWQzMmY0OGQxNmJkOTU1NDljMmYwNTJiMzJhYTA3Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
N2RkOTE3OTU4YzFhNTg5MWY3ZDA4YjUwYmE3ZGI2Mzc3OGU3YTRjYQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzM1ZDk5NzgwOWVhN2RmNDVjNzg3MjA4YjZhNzU4ZWEyOGVlZTcyOTY3MDBl
|
10
|
+
MmU1NTU3NjFhNzNkZjBiMDkzN2E4MWRkM2U3Mzk4ODZlMjUyMTNiODZjZWJh
|
11
|
+
NWJkZTQ3ZWRkZDIzZjcwZTE2ZjgwY2VkMTVjZGU0NTBhNzkwODM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZWVlMGNmZjIzN2MxOGU2YjBhZjQxZmM4ZTViYTllOWRmODg5NGM3NzNjMThm
|
14
|
+
NTM2YjA4YzViNzA1NGNlMGEwZjhhYzMyNjY2MmU0ZmUzZGIyZWJiNzdkNmFl
|
15
|
+
NWVjODYwMTg5MjZjZmJkOTgwODI1OWIxOWVlN2Y2NWZlNWRjNjk=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Ain't She Sweet
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Puru Dahal, Arik Gadye and Sebastian Belmar
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# SweetSinatra
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sweetsinatra'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sweetsinatra
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/SweetSinatra/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/sweetsinatra
ADDED
data/lib/sweetsinatra.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require "sweetsinatra/version"
|
2
|
+
|
3
|
+
module SweetSinatra
|
4
|
+
|
5
|
+
|
6
|
+
INPUT = ARGV
|
7
|
+
COMMAND = INPUT[-2]
|
8
|
+
APPNAME = INPUT[-1]
|
9
|
+
|
10
|
+
def self.run
|
11
|
+
if COMMAND == "new"
|
12
|
+
setup
|
13
|
+
elsif INPUT.include?("scaffold")
|
14
|
+
scaffold
|
15
|
+
else
|
16
|
+
puts "You looser MoFO!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.setup
|
21
|
+
`git clone https://github.com/Sinatrify/Sinatra_Skeleton.git`
|
22
|
+
`mv Sinatra_Skeleton #{APPNAME}`
|
23
|
+
`rm -rf #{APPNAME}/.git`
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.scaffold
|
27
|
+
INPUT.shift(2)
|
28
|
+
table = INPUT.shift
|
29
|
+
fields = INPUT
|
30
|
+
name = table.capitalize
|
31
|
+
|
32
|
+
#model
|
33
|
+
`rake generate:model NAME=#{name}`
|
34
|
+
#migration
|
35
|
+
filename = "%s_create_%s.rb" % [Time.now.strftime('%Y%m%d%H%M%S'), table]
|
36
|
+
#path = APP_ROOT.join('db', 'migrate', filename)
|
37
|
+
path = "db/migrate/#{filename}"
|
38
|
+
|
39
|
+
if File.exist?(path)
|
40
|
+
raise "ERROR: File '#{path}' already exists"
|
41
|
+
end
|
42
|
+
|
43
|
+
table_fields = Hash[fields.map{|a| a.split(":").to_a}]
|
44
|
+
fields_str = ""
|
45
|
+
table_fields.each do |column, data_type|
|
46
|
+
fields_str << "t.#{data_type} :#{column} \n"
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "Creating #{path}"
|
50
|
+
File.open(path, 'w+') do |f|
|
51
|
+
f.write(<<-EOF)
|
52
|
+
class Create#{name} < ActiveRecord::Migration
|
53
|
+
def change
|
54
|
+
create_table :#{table}s do |t|
|
55
|
+
#{fields_str}
|
56
|
+
|
57
|
+
t.timestamps
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
EOF
|
62
|
+
end
|
63
|
+
#calling controller creation
|
64
|
+
controller_name = (name + 's_controller').capitalize
|
65
|
+
controller_filename = name.downcase + '.rb'
|
66
|
+
controller_path = "app/controllers/#{controller_filename}"
|
67
|
+
|
68
|
+
if File.exist?(controller_path)
|
69
|
+
raise "ERROR: controller file '#{controller_path}' already exists"
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "Creating #{controller_path}"
|
73
|
+
File.open(controller_path, 'w+') do |f|
|
74
|
+
f.write(<<-EOF)
|
75
|
+
get '/' do
|
76
|
+
@#{name.downcase} = #{name}.all
|
77
|
+
erb :index
|
78
|
+
end
|
79
|
+
|
80
|
+
get '/new' do
|
81
|
+
erb :new
|
82
|
+
end
|
83
|
+
|
84
|
+
post '/new' do
|
85
|
+
#{name}.create(params)
|
86
|
+
redirect to('/')
|
87
|
+
end
|
88
|
+
|
89
|
+
get '/show/:id' do
|
90
|
+
@#{name.downcase} = #{name}.find(params[:id])
|
91
|
+
end
|
92
|
+
EOF
|
93
|
+
end
|
94
|
+
#views
|
95
|
+
view_filename = name.downcase + '.erb'
|
96
|
+
view_path = "app/views"
|
97
|
+
|
98
|
+
if File.exist?(view_path)
|
99
|
+
raise "ERROR: view file '#{view_path}' already exists"
|
100
|
+
end
|
101
|
+
|
102
|
+
puts "Creating #{view_path}"
|
103
|
+
`mkdir app/views`
|
104
|
+
index = "index.erb"
|
105
|
+
create = "new.erb"
|
106
|
+
show = "show.erb"
|
107
|
+
`touch app/views/index.erb app/views/new.erb app/views/show.erb`
|
108
|
+
arr = [index, create, show]
|
109
|
+
arr.each do |path|
|
110
|
+
File.open(view_path + path, 'w+') do |f|
|
111
|
+
if path == index
|
112
|
+
f.write(<<-EOF)
|
113
|
+
<% @#{name.downcase}.each do |#{name.downcase}| %>
|
114
|
+
<%= #{name.downcase}.name %>
|
115
|
+
<% end %>
|
116
|
+
EOF
|
117
|
+
elsif path == create
|
118
|
+
f.write(<<-EOF)
|
119
|
+
<form action='' method='post'>
|
120
|
+
<input>
|
121
|
+
<input>
|
122
|
+
</form>
|
123
|
+
EOF
|
124
|
+
else
|
125
|
+
f.write(<<-EOF)
|
126
|
+
<h1>SHOW</h1>
|
127
|
+
EOF
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sweetsinatra/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sweetsinatra"
|
8
|
+
spec.version = SweetSinatra::VERSION
|
9
|
+
spec.authors = ["Puru Dahal", "Arik Gadye", "Sebastian Belmar"]
|
10
|
+
spec.email = ["pdahal@me.com", "arikdovgadye@gmail.com", "si.belmar@gmail.com"]
|
11
|
+
spec.summary = %q{Sinatra Skeleton and Scaffold Generator}
|
12
|
+
spec.description = %q{This gems will help you generate Sinatra Skeleton and CRUD Scaffold.}
|
13
|
+
spec.homepage = "https://github.com/Sinatrify/SweetSinatra"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["sweetsinatra"]
|
18
|
+
#spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sweetsinatra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Puru Dahal
|
8
|
+
- Arik Gadye
|
9
|
+
- Sebastian Belmar
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.6'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
description: This gems will help you generate Sinatra Skeleton and CRUD Scaffold.
|
44
|
+
email:
|
45
|
+
- pdahal@me.com
|
46
|
+
- arikdovgadye@gmail.com
|
47
|
+
- si.belmar@gmail.com
|
48
|
+
executables:
|
49
|
+
- sweetsinatra
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/sweetsinatra
|
60
|
+
- lib/sweetsinatra.rb
|
61
|
+
- lib/sweetsinatra/version.rb
|
62
|
+
- sweetsinatra-0.0.1.gem
|
63
|
+
- sweetsinatra.gemspec
|
64
|
+
homepage: https://github.com/Sinatrify/SweetSinatra
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.1.5
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Sinatra Skeleton and Scaffold Generator
|
88
|
+
test_files: []
|