make_it_so 0.0.3 → 0.0.4
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 +4 -4
- data/README.md +29 -1
- data/app.rb +20 -0
- data/lib/generators/sinatra_app_generator.rb +96 -0
- data/lib/make_it_so/command_line_interface.rb +9 -1
- data/lib/make_it_so/version.rb +1 -1
- data/lib/make_it_so.rb +1 -0
- data/spec/features/user_generates_sinatra_spec.rb +116 -0
- data/templates/rails/app/views/layouts/application.html.erb.tt +0 -5
- data/templates/sinatra/.gitignore +3 -0
- data/templates/sinatra/.rspec +1 -0
- data/templates/sinatra/Gemfile +15 -0
- data/templates/sinatra/Rakefile +9 -0
- data/templates/sinatra/app.rb +16 -0
- data/templates/sinatra/config.ru +2 -0
- data/templates/sinatra/spec/spec_helper.rb +9 -0
- data/templates/sinatra/views/index.erb +1 -0
- data/templates/sinatra/views/layout.erb +14 -0
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7edf6e86640b40baa5dbae141ad1cd9e2c6ff132
|
4
|
+
data.tar.gz: 5084c958f8b8997ff9c88843f62beaebc4a66c48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0900609b3fc0df653c762e61e94c48e013ac115bf46e4d9fee294f40973fd4c013b248ad19e1707950e3bfe9a87efa064f2659571c74bad6d2929e729aa78cd
|
7
|
+
data.tar.gz: 576d395e41da2034743d7b92702eaded0df70648b9ad55d4f855ae6f348ae86926287e863ead515ad9587ffb5ea8bdc663d4abdcedfcc67fbb86dd0e79999d8b
|
data/README.md
CHANGED
@@ -16,16 +16,44 @@ Install it yourself as:
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
-
|
19
|
+
|
20
|
+
### Rails
|
21
|
+
|
22
|
+
In the terminal, run:
|
23
|
+
|
24
|
+
```no-highlight
|
20
25
|
make_it_so rails <app_name>
|
21
26
|
```
|
22
27
|
|
23
28
|
Then run:
|
29
|
+
|
24
30
|
```ruby
|
25
31
|
rake db:create
|
26
32
|
rake db:migrate
|
27
33
|
```
|
28
34
|
|
35
|
+
## Extra Footer in Views
|
36
|
+
|
37
|
+
Inject javascript at the end of the body tag. Javascript should always be the last thing loaded on the page. In view logic you can do the following:
|
38
|
+
|
39
|
+
```erb
|
40
|
+
<%= content_for :extra_footer do %>
|
41
|
+
<script type="text/javascript">
|
42
|
+
var widget = new Something.Widget('foo');
|
43
|
+
</script>
|
44
|
+
<% end %>
|
45
|
+
```
|
46
|
+
|
47
|
+
### Sinatra
|
48
|
+
|
49
|
+
In the terminal, run:
|
50
|
+
|
51
|
+
```no-highlight
|
52
|
+
make_it_so sinatra <app_name>
|
53
|
+
```
|
54
|
+
|
55
|
+
By default, the generator, will create a sinatra root complete with an RSpec configuration.
|
56
|
+
|
29
57
|
## Contributing
|
30
58
|
|
31
59
|
1. Fork it ( https://github.com/[my-github-username]/make_it_so/fork )
|
data/app.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'sinatra/reloader'
|
3
|
+
|
4
|
+
configure :development, :test do
|
5
|
+
require 'pry'
|
6
|
+
end
|
7
|
+
|
8
|
+
configure do
|
9
|
+
set :views, 'app/views'
|
10
|
+
end
|
11
|
+
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].each do |file|
|
13
|
+
require file
|
14
|
+
also_reload file
|
15
|
+
end
|
16
|
+
|
17
|
+
get '/' do
|
18
|
+
@title = "Hello World"
|
19
|
+
erb :index
|
20
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module MakeItSo
|
2
|
+
class SinatraAppGenerator < Thor::Group
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
desc "Creates a new Sinatra application"
|
6
|
+
argument :name,
|
7
|
+
type: :string,
|
8
|
+
desc: "The name of the new application"
|
9
|
+
|
10
|
+
class_option :rspec,
|
11
|
+
type: :boolean,
|
12
|
+
default: true,
|
13
|
+
desc: 'install rspec'
|
14
|
+
|
15
|
+
def directories
|
16
|
+
[
|
17
|
+
'lib',
|
18
|
+
'views',
|
19
|
+
'public/stylesheets',
|
20
|
+
'public/javascripts'
|
21
|
+
].each do |dir|
|
22
|
+
empty_directory File.join(app_path, dir)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def app_file
|
27
|
+
file_path = 'app.rb'
|
28
|
+
template(file_path, File.join(app_path, file_path))
|
29
|
+
end
|
30
|
+
|
31
|
+
def rakefile
|
32
|
+
file_path = 'Rakefile'
|
33
|
+
template(file_path, File.join(app_path, file_path))
|
34
|
+
end
|
35
|
+
|
36
|
+
def view_files
|
37
|
+
[
|
38
|
+
'views/layout.erb',
|
39
|
+
'views/index.erb'
|
40
|
+
].each do |file_path|
|
41
|
+
template(file_path, File.join(app_path, file_path))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def asset_files
|
46
|
+
[
|
47
|
+
'public/javascripts/app.js',
|
48
|
+
'public/stylesheets/app.css'
|
49
|
+
].each do |file_path|
|
50
|
+
create_file(File.join(app_path, file_path))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def rackup_file
|
55
|
+
file_path = 'config.ru'
|
56
|
+
template(file_path, File.join(app_path, file_path))
|
57
|
+
end
|
58
|
+
|
59
|
+
def gemfile
|
60
|
+
file_path = 'Gemfile'
|
61
|
+
template(file_path, File.join(app_path, file_path))
|
62
|
+
end
|
63
|
+
|
64
|
+
def gitignore
|
65
|
+
file_path = '.gitignore'
|
66
|
+
template(file_path, File.join(app_path, file_path))
|
67
|
+
end
|
68
|
+
|
69
|
+
def rspec
|
70
|
+
if options.rspec?
|
71
|
+
empty_directory File.join(app_path, 'spec/features')
|
72
|
+
spec_helper = 'spec/spec_helper.rb'
|
73
|
+
template(spec_helper, File.join(app_path, spec_helper))
|
74
|
+
|
75
|
+
dot_rspec = '.rspec'
|
76
|
+
template(dot_rspec, File.join(app_path, dot_rspec))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.source_root
|
81
|
+
template_path = File.join(
|
82
|
+
File.dirname(__FILE__),
|
83
|
+
"..",
|
84
|
+
"..",
|
85
|
+
"templates",
|
86
|
+
"sinatra")
|
87
|
+
|
88
|
+
File.expand_path(template_path)
|
89
|
+
end
|
90
|
+
|
91
|
+
protected
|
92
|
+
def app_path
|
93
|
+
name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -1,11 +1,19 @@
|
|
1
1
|
require 'thor'
|
2
2
|
module MakeItSo
|
3
3
|
class CommandLineInterface < Thor
|
4
|
-
desc "rails <app_name>",
|
4
|
+
desc "rails <app_name>",
|
5
|
+
"generates a rails application based on your specifications"
|
5
6
|
option :devise
|
6
7
|
def rails(app_name)
|
7
8
|
puts "#{app_name}"
|
8
9
|
MakeItSo::RailsAppGenerator.start([app_name])
|
9
10
|
end
|
11
|
+
|
12
|
+
desc "sinatra <app_name>",
|
13
|
+
"generates a sinatra application based on your specifications"
|
14
|
+
def sinatra(*args)
|
15
|
+
puts "#{args.first}"
|
16
|
+
MakeItSo::SinatraAppGenerator.start(args)
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
data/lib/make_it_so/version.rb
CHANGED
data/lib/make_it_so.rb
CHANGED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'user generates sinatra app' do
|
4
|
+
def app_name
|
5
|
+
'dummy_sinatra'
|
6
|
+
end
|
7
|
+
|
8
|
+
def app_path
|
9
|
+
join_paths(tmp_path, app_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:all) do
|
13
|
+
make_it_so!("sinatra #{app_path}")
|
14
|
+
end
|
15
|
+
|
16
|
+
scenario 'includes sinatra in the app.rb file' do
|
17
|
+
expect(FileTest.exists?(join_paths(app_path, 'app.rb'))).
|
18
|
+
to be(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
scenario 'creates a lib directory' do
|
22
|
+
expect(has_dir?('lib')).to be(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
scenario 'creates a public/javascripts directory' do
|
26
|
+
expect(has_dir?('public/javascripts')).to be(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
scenario 'creates a public/stylesheets directory' do
|
30
|
+
expect(has_dir?('public/stylesheets')).to be(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario 'creates a views directory' do
|
34
|
+
expect(has_dir?('views')).to be(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
scenario 'includes a config.ru file' do
|
38
|
+
expect(has_file?('config.ru')).to be(true)
|
39
|
+
end
|
40
|
+
|
41
|
+
scenario 'includes a Gemfile' do
|
42
|
+
expect(has_file?('Gemfile')).to be(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
scenario 'includes sinatra in the Gemfile' do
|
46
|
+
expect(in_gemfile?('sinatra')).
|
47
|
+
to be(true)
|
48
|
+
end
|
49
|
+
|
50
|
+
scenario 'creates a public/javascripts/app.js' do
|
51
|
+
expect(has_file?('public/javascripts/app.js')).to be(true)
|
52
|
+
end
|
53
|
+
|
54
|
+
scenario 'creates a public/stylesheets/app.css' do
|
55
|
+
expect(has_file?('public/stylesheets/app.css')).to be(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
scenario 'creates a layout file' do
|
59
|
+
expect(has_file?('views/layout.erb')).to be(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
scenario 'creates an index file' do
|
63
|
+
expect(has_file?('views/index.erb')).to be(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
scenario 'creates a Rakefile' do
|
67
|
+
expect(has_file?('Rakefile')).to be(true)
|
68
|
+
end
|
69
|
+
|
70
|
+
scenario '.gitignore' do
|
71
|
+
expect(has_file?('.gitignore')).to be(true)
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'rspec' do
|
75
|
+
scenario 'creates a spec_helper' do
|
76
|
+
expect(has_file?('spec/spec_helper.rb')).to be(true)
|
77
|
+
end
|
78
|
+
|
79
|
+
scenario 'creates a .rspec file' do
|
80
|
+
expect(has_file?('.rspec')).to be(true)
|
81
|
+
end
|
82
|
+
|
83
|
+
scenario 'creates a spec directory' do
|
84
|
+
expect(has_dir?('spec')).to be(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
scenario 'creates a spec/features directory' do
|
88
|
+
expect(has_dir?('spec/features')).to be(true)
|
89
|
+
end
|
90
|
+
|
91
|
+
scenario 'includes rspec as a dependency' do
|
92
|
+
expect(in_gemfile?('rspec')).to be(true)
|
93
|
+
end
|
94
|
+
|
95
|
+
scenario 'includes capybara as a dependency' do
|
96
|
+
expect(in_gemfile?('capybara')).to be(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
scenario 'includes launchy as a dependency' do
|
100
|
+
expect(in_gemfile?('launchy')).to be(true)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def has_dir?(relative_path)
|
105
|
+
File.directory?(join_paths(app_path, relative_path))
|
106
|
+
end
|
107
|
+
|
108
|
+
def has_file?(relative_path)
|
109
|
+
FileTest.exists?(join_paths(app_path, relative_path))
|
110
|
+
end
|
111
|
+
|
112
|
+
def in_gemfile?(gem_name)
|
113
|
+
File.read(join_paths(app_path, 'Gemfile')).
|
114
|
+
match(/gem.*#{Regexp.escape(gem_name)}/).present?
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'sinatra/reloader'
|
3
|
+
|
4
|
+
configure :development, :test do
|
5
|
+
require 'pry'
|
6
|
+
end
|
7
|
+
|
8
|
+
Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].each do |file|
|
9
|
+
require file
|
10
|
+
also_reload file
|
11
|
+
end
|
12
|
+
|
13
|
+
get '/' do
|
14
|
+
@title = "Hello World"
|
15
|
+
erb :index
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1><%%= @title %></h1>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
+
<title>Hello World</title>
|
7
|
+
<link rel="stylesheet" href="/stylesheets/app.css" />
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%%= yield %>
|
11
|
+
|
12
|
+
<script src="/javascripts/app.js"></script>
|
13
|
+
</body>
|
14
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: make_it_so
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Pickett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- LICENSE.txt
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
126
|
+
- app.rb
|
126
127
|
- bin/make_it_so
|
127
128
|
- gemfiles/rails_4_0.gemfile
|
128
129
|
- gemfiles/rails_4_0.gemfile.lock
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- gemfiles/rails_4_2.gemfile
|
132
133
|
- gemfiles/rails_4_2.gemfile.lock
|
133
134
|
- lib/generators/rails_app_generator.rb
|
135
|
+
- lib/generators/sinatra_app_generator.rb
|
134
136
|
- lib/make_it_so.rb
|
135
137
|
- lib/make_it_so/command_line_interface.rb
|
136
138
|
- lib/make_it_so/rails.rb
|
@@ -140,6 +142,7 @@ files:
|
|
140
142
|
- snippets/rails/application_generator.rb
|
141
143
|
- snippets/rails/user_factory.rb
|
142
144
|
- spec/features/user_generates_rails_spec.rb
|
145
|
+
- spec/features/user_generates_sinatra_spec.rb
|
143
146
|
- spec/spec_helper.rb
|
144
147
|
- spec/support/make_it_so_spec_helpers.rb
|
145
148
|
- templates/.gitkeep
|
@@ -153,6 +156,15 @@ files:
|
|
153
156
|
- templates/rails/spec/features/user_signs_up_spec.rb
|
154
157
|
- templates/rails/spec/support/factory_girl.rb
|
155
158
|
- templates/rails/spec/support/valid_attribute.rb
|
159
|
+
- templates/sinatra/.gitignore
|
160
|
+
- templates/sinatra/.rspec
|
161
|
+
- templates/sinatra/Gemfile
|
162
|
+
- templates/sinatra/Rakefile
|
163
|
+
- templates/sinatra/app.rb
|
164
|
+
- templates/sinatra/config.ru
|
165
|
+
- templates/sinatra/spec/spec_helper.rb
|
166
|
+
- templates/sinatra/views/index.erb
|
167
|
+
- templates/sinatra/views/layout.erb
|
156
168
|
homepage: ''
|
157
169
|
licenses:
|
158
170
|
- MIT
|
@@ -179,5 +191,6 @@ specification_version: 4
|
|
179
191
|
summary: An application generator for all things ruby
|
180
192
|
test_files:
|
181
193
|
- spec/features/user_generates_rails_spec.rb
|
194
|
+
- spec/features/user_generates_sinatra_spec.rb
|
182
195
|
- spec/spec_helper.rb
|
183
196
|
- spec/support/make_it_so_spec_helpers.rb
|