whiteboard 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +2 -0
- data/lib/whiteboard.rb +251 -0
- data/lib/whiteboard/version.rb +3 -0
- data/whiteboard.gemspec +22 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dc0054ec9f12531bab69d59e92f037221ce8fb96
|
4
|
+
data.tar.gz: 548676ed8c15bdd0d6e6a323935976b8dabc1f3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e545420d4458686a5c056e8779ae1eec16aeedbec5a8700be4329718f31e98cafa0cc4ad28ac26bc5b6c31c5db5fcc30cc366203345c11fc6bf1197a4ddd3601
|
7
|
+
data.tar.gz: 7b0e00a024cd2aac58a15de613e344d485c53d7fddb0ce65c8eb3be4f19b22f00ba2702891b6eb070f69fde1dce8fadb93fbaf91be9e58a1b2ca62c628bd6a30
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Nathan Bashaw
|
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,65 @@
|
|
1
|
+
# Whiteboard
|
2
|
+
|
3
|
+
An intellectually satisfying way to start new rails projects. Figure out the basics of your app in a file, then run it to generate a basic rails skeleton with all the config options, gems, models, views, and controllers you want.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
It's simple.
|
8
|
+
|
9
|
+
$ gem install whiteboard
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Run `whiteboard new` to generate a sample `.whiteboard` file. Edit that file then run `whiteboard` to generate your app.
|
14
|
+
|
15
|
+
## Example .whiteboard file
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require "whiteboard"
|
19
|
+
include Whiteboard
|
20
|
+
|
21
|
+
Whiteboard.test_run! # Prints commands without actually running them
|
22
|
+
|
23
|
+
# Generate app
|
24
|
+
Whiteboard::App.new do |app|
|
25
|
+
app.name 'TestApp' # the only required field
|
26
|
+
# app.skip_bundle! # skip individual options
|
27
|
+
# app.skip! ['git', 'test-unit'] # skip multiple things
|
28
|
+
app.database 'postgresql' # defaults to sqlite, possible options are
|
29
|
+
# the rails defaults (not mongo, unfortunately)
|
30
|
+
app.ruby_version '2.1.2' # generates .ruby-version file
|
31
|
+
app.ruby_gemset 'testapp-gemset' # generates .ruby-gemset file
|
32
|
+
app.gems ['omniauth', 'omniauth-twitter'] # appends to Gemfile
|
33
|
+
app.gems ['twitter', ['rack', '>=1.0']] # appends gem with version specified
|
34
|
+
end
|
35
|
+
|
36
|
+
# Generate User model
|
37
|
+
Whiteboard::Model.new do |m|
|
38
|
+
m.name 'User'
|
39
|
+
m.field :name, :string
|
40
|
+
m.field :email, :string
|
41
|
+
m.field :password_digest, :string
|
42
|
+
end
|
43
|
+
|
44
|
+
# Generate Post Model
|
45
|
+
Whiteboard::Model.new do |m|
|
46
|
+
m.name 'Post'
|
47
|
+
m.field :title, :string
|
48
|
+
m.field :body, :text
|
49
|
+
m.field :user_id, :references, :index
|
50
|
+
end
|
51
|
+
|
52
|
+
# User controller
|
53
|
+
Whiteboard::Controller.new do |c|
|
54
|
+
c.name 'Users'
|
55
|
+
c.actions [:index, :new, :show]
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it ( https://github.com/[my-github-username]/whiteboard/fork )
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/whiteboard.rb
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
require "whiteboard/version"
|
2
|
+
|
3
|
+
module Whiteboard
|
4
|
+
|
5
|
+
# Need to fix all this stuff and put it inside a class
|
6
|
+
# or something else that's not globally scoped. Not sure
|
7
|
+
# how to do that though. Help?
|
8
|
+
|
9
|
+
$command_queue = []
|
10
|
+
|
11
|
+
def test_run!
|
12
|
+
$test_run = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def queue_cmd(cmd)
|
16
|
+
$command_queue << cmd
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute!(commands)
|
20
|
+
$command_queue.each do |cmd|
|
21
|
+
if $test_run
|
22
|
+
puts cmd
|
23
|
+
else
|
24
|
+
system cmd
|
25
|
+
end
|
26
|
+
end
|
27
|
+
$command_queue = []
|
28
|
+
end
|
29
|
+
|
30
|
+
class App
|
31
|
+
|
32
|
+
def initialize(&block)
|
33
|
+
# Everything must be in the initialization block
|
34
|
+
if block_given?
|
35
|
+
instance_eval(&block)
|
36
|
+
generate_app!
|
37
|
+
else
|
38
|
+
raise "You need to use a block to specify your app, like this: \n\nApp.new do |app|\n app.name 'twitter'\nend"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def name(name)
|
43
|
+
@app_name = name
|
44
|
+
$app_name = name
|
45
|
+
end
|
46
|
+
|
47
|
+
def database(db)
|
48
|
+
@db = db
|
49
|
+
end
|
50
|
+
|
51
|
+
# Skipping things
|
52
|
+
|
53
|
+
def skip!(skip_list)
|
54
|
+
skip_list.each do |item|
|
55
|
+
case item
|
56
|
+
when 'gemfile'
|
57
|
+
@skip_gemfile = true
|
58
|
+
when 'bundle'
|
59
|
+
@skip_bundle = true
|
60
|
+
when 'active-record'
|
61
|
+
@skip_active_record = true
|
62
|
+
when 'git'
|
63
|
+
@skip_git = true
|
64
|
+
when 'javascript'
|
65
|
+
@skip_javascript = true
|
66
|
+
when 'test-unit'
|
67
|
+
@skip_test_unit = true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def skip_bundle!
|
73
|
+
@skip_bundle = true
|
74
|
+
end
|
75
|
+
|
76
|
+
def skip_gemfile!
|
77
|
+
@skip_gemfile = true
|
78
|
+
end
|
79
|
+
|
80
|
+
def skip_active_record!
|
81
|
+
@skip_active_record = true
|
82
|
+
end
|
83
|
+
|
84
|
+
def skip_javascript!
|
85
|
+
@skip_javascript = true
|
86
|
+
end
|
87
|
+
|
88
|
+
def skip_git!
|
89
|
+
@skip_git = true
|
90
|
+
end
|
91
|
+
|
92
|
+
def skip_test_unit!
|
93
|
+
@skip_test_unit = true
|
94
|
+
end
|
95
|
+
|
96
|
+
# Ruby version & gemset
|
97
|
+
|
98
|
+
def ruby_version(v)
|
99
|
+
@ruby_version = v
|
100
|
+
end
|
101
|
+
|
102
|
+
def ruby_gemset(g)
|
103
|
+
@ruby_gemset = g
|
104
|
+
end
|
105
|
+
|
106
|
+
def gems(gemlist)
|
107
|
+
@gemlist = gemlist
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def generate_app!
|
113
|
+
rails_new!
|
114
|
+
add_ruby_version! if @ruby_version
|
115
|
+
add_ruby_gemset! if @ruby_gemset
|
116
|
+
add_gems! if @gemlist
|
117
|
+
install_gems!
|
118
|
+
execute! $command_queue
|
119
|
+
end
|
120
|
+
|
121
|
+
def rails_new!
|
122
|
+
|
123
|
+
# Check to make sure we've specified an app name
|
124
|
+
if @app_name
|
125
|
+
|
126
|
+
# Basic app stuff
|
127
|
+
cmd = "rails new #{@app_name}"
|
128
|
+
cmd += " --database=#{@db}" if @db
|
129
|
+
|
130
|
+
# Skip things
|
131
|
+
cmd += " --skip-bundle" if @skip_bundle
|
132
|
+
cmd += " --skip-gemfile" if @skip_gemfile
|
133
|
+
cmd += " --skip-active-record" if @skip_active_record
|
134
|
+
cmd += " --skip-javascript" if @skip_javascript
|
135
|
+
cmd += " --skip-git" if @skip_git
|
136
|
+
cmd += " --skip-test-unit" if @skip_test_unit
|
137
|
+
queue_cmd cmd
|
138
|
+
else
|
139
|
+
raise "You need to specify an app name"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def add_ruby_version!
|
144
|
+
cmd = "echo '#{@ruby_version}' >> #{@app_name}/.ruby-version"
|
145
|
+
queue_cmd cmd
|
146
|
+
end
|
147
|
+
|
148
|
+
def add_ruby_gemset!
|
149
|
+
cmd = "echo '#{@ruby_gemset}' >> #{@app_name}/.ruby-gemset"
|
150
|
+
queue_cmd cmd
|
151
|
+
end
|
152
|
+
|
153
|
+
def add_gems!
|
154
|
+
raise 'You can\'t skip the gemfile AND specify gems.' if @skip_gemfile
|
155
|
+
@gemlist.each do |g|
|
156
|
+
if g.is_a? String
|
157
|
+
queue_cmd "echo 'gem \"#{g}\"' >> #{@app_name}/Gemfile"
|
158
|
+
elsif g.is_a? Array
|
159
|
+
queue_cmd "echo 'gem \"#{g[0]}\", \"#{g[1]}\"' >> #{@app_name}/Gemfile"
|
160
|
+
else
|
161
|
+
raise "Gem #{g}'s format needs to be a String or an Array."
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def install_gems!
|
167
|
+
queue_cmd "cd #{$app_name} && spring stop" # Hack to fix spring bug
|
168
|
+
queue_cmd "cd #{$app_name} && bundle"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
class Model
|
173
|
+
def initialize(&block)
|
174
|
+
# Everything must be in the initialization block
|
175
|
+
@fields = []
|
176
|
+
if block_given?
|
177
|
+
instance_eval(&block)
|
178
|
+
generate_model!
|
179
|
+
else
|
180
|
+
raise "You need to use a block to specify your app, like this: \n\nApp.new do |app|\n app.name 'twitter'\nend"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def name(model_name)
|
185
|
+
@model_name = model_name
|
186
|
+
end
|
187
|
+
|
188
|
+
def field(name, type, index = nil)
|
189
|
+
@fields << [name, type, index]
|
190
|
+
end
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
def generate_model!
|
195
|
+
if @model_name
|
196
|
+
cmd = "cd #{$app_name} && "
|
197
|
+
cmd += "rails g model #{@model_name}"
|
198
|
+
@fields.each do |field|
|
199
|
+
cmd += " #{field[0]}:#{field[1]}"
|
200
|
+
cmd += ":index" if field[2]
|
201
|
+
end
|
202
|
+
queue_cmd cmd
|
203
|
+
execute! $command_queue
|
204
|
+
else
|
205
|
+
raise "You need to specify the model name."
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
class Controller
|
212
|
+
def initialize(&block)
|
213
|
+
# Everything must be in the initialization block
|
214
|
+
@action_list = []
|
215
|
+
if block_given?
|
216
|
+
instance_eval(&block)
|
217
|
+
generate_controller!
|
218
|
+
else
|
219
|
+
raise "You need to use a block to specify your app, like this: \n\nApp.new do |app|\n app.name 'twitter'\nend"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def name(controller_name)
|
224
|
+
if controller_name.split('').last != 's'
|
225
|
+
raise 'Rails controller names should be plural'
|
226
|
+
else
|
227
|
+
@controller_name = controller_name
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def actions(action_list)
|
232
|
+
if action_list.is_a? Array
|
233
|
+
@action_list = action_list
|
234
|
+
else
|
235
|
+
raise 'The controller action should be in an array'
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
private
|
240
|
+
|
241
|
+
def generate_controller!
|
242
|
+
cmd = "rails g controller #{@controller_name}"
|
243
|
+
@action_list.each do |action|
|
244
|
+
cmd += " #{action}"
|
245
|
+
end
|
246
|
+
puts cmd
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
data/whiteboard.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'whiteboard/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "whiteboard"
|
8
|
+
spec.version = Whiteboard::VERSION
|
9
|
+
spec.authors = ["Nathan Bashaw"]
|
10
|
+
spec.email = ["nbashaw@gmail.com"]
|
11
|
+
spec.summary = %q{An intellectually satisfying way to start new rails apps.}
|
12
|
+
spec.homepage = "http://github.com/nbashaw/whiteboard"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whiteboard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Bashaw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- nbashaw@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/whiteboard.rb
|
54
|
+
- lib/whiteboard/version.rb
|
55
|
+
- whiteboard.gemspec
|
56
|
+
homepage: http://github.com/nbashaw/whiteboard
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.2.2
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: An intellectually satisfying way to start new rails apps.
|
80
|
+
test_files: []
|