sinator 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +22 -0
- data/README.md +126 -0
- data/bin/sinator +5 -0
- data/lib/sinator/command.rb +61 -0
- data/lib/sinator/generator.rb +106 -0
- data/lib/sinator/templates/Gemfile.erb +15 -0
- data/lib/sinator/templates/Rakefile.erb +33 -0
- data/lib/sinator/templates/app/routes/home.erb +6 -0
- data/lib/sinator/templates/app/views/home/index.erb +1 -0
- data/lib/sinator/templates/app/views/layout.erb +21 -0
- data/lib/sinator/templates/app.erb +71 -0
- data/lib/sinator/templates/assets/javascripts/app.js +2 -0
- data/lib/sinator/templates/assets/javascripts/main.js +1 -0
- data/lib/sinator/templates/assets/javascripts/plugins.js +24 -0
- data/lib/sinator/templates/assets/stylesheets/app.css.scss +1 -0
- data/lib/sinator/templates/assets/stylesheets/main.css.scss +8 -0
- data/lib/sinator/templates/config/application.rb +7 -0
- data/lib/sinator/templates/config/boot.rb +10 -0
- data/lib/sinator/templates/config/database.yml +8 -0
- data/lib/sinator/templates/config/puma/development.erb +7 -0
- data/lib/sinator/templates/config/puma/production.erb +16 -0
- data/lib/sinator/templates/config.ru.erb +5 -0
- data/lib/sinator/templates/db/migrations/000_example.rb +12 -0
- data/lib/sinator/templates/public/404.html +60 -0
- data/lib/sinator/templates/public/apple-touch-icon.png +0 -0
- data/lib/sinator/templates/public/browserconfig.xml +12 -0
- data/lib/sinator/templates/public/crossdomain.xml +15 -0
- data/lib/sinator/templates/public/favicon.ico +0 -0
- data/lib/sinator/templates/public/humans.txt +15 -0
- data/lib/sinator/templates/public/robots.txt +5 -0
- data/lib/sinator/templates/public/tile-wide.png +0 -0
- data/lib/sinator/templates/public/tile.png +0 -0
- data/lib/sinator/version.rb +3 -0
- data/lib/sinator.rb +1 -0
- data/sinator.gemspec +19 -0
- data/spec/fixtures/app_routes_home.txt +6 -0
- data/spec/fixtures/config/puma/development.txt +7 -0
- data/spec/fixtures/config/puma/production.txt +16 -0
- data/spec/fixtures/config_ru.txt +5 -0
- data/spec/fixtures/with_db/app.txt +50 -0
- data/spec/fixtures/with_db/gemfile.txt +13 -0
- data/spec/fixtures/with_db/rakefile.txt +32 -0
- data/spec/fixtures/without_db/app.txt +31 -0
- data/spec/fixtures/without_db/gemfile.txt +11 -0
- data/spec/fixtures/without_db/rakefile.txt +15 -0
- data/spec/helpers/generator.rb +46 -0
- data/spec/sinator/command_spec.rb +70 -0
- data/spec/sinator/generator_spec.rb +184 -0
- data/spec/sinator_spec.rb +1 -0
- data/spec/spec_helper.rb +29 -0
- metadata +128 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
require_relative '../../lib/sinator/generator'
|
2
|
+
require_relative '../helpers/generator'
|
3
|
+
|
4
|
+
describe Sinator::Generator do
|
5
|
+
include Helper::Generator
|
6
|
+
|
7
|
+
let(:generator) { Sinator::Generator.new @app, destination: @dest }
|
8
|
+
let(:generator_with_db) { Sinator::Generator.new @app, destination: @dest_with_db, with_database: true }
|
9
|
+
let(:target_dir) { "#{@dest}/#{@app}" }
|
10
|
+
let(:target_dir_with_db) { "#{@dest_with_db}/#{@app}" }
|
11
|
+
|
12
|
+
before do
|
13
|
+
@dest = "/tmp/sinator"
|
14
|
+
@dest_with_db = "#{@dest}_with_db"
|
15
|
+
@app = "my_app"
|
16
|
+
|
17
|
+
FileUtils.rm_r @dest if Dir.exists?(@dest)
|
18
|
+
FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db)
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
FileUtils.rm_r @dest if Dir.exists?(@dest)
|
23
|
+
FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sets app_name" do
|
27
|
+
expect(generator.app_name).to eq @app
|
28
|
+
end
|
29
|
+
|
30
|
+
it "sets app_class_name" do
|
31
|
+
expect(generator.app_class_name).to eq "MyApp"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has default destination path app_name" do
|
35
|
+
FileUtils.rm_r @app if Dir.exists?(@app)
|
36
|
+
expect(Sinator::Generator.new(@app).destination).to eq File.expand_path(@app)
|
37
|
+
FileUtils.rm_r @app if Dir.exists?(@app)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "sets new destination path even if it's not exist yet" do
|
41
|
+
expect(Sinator::Generator.new(@dest).destination).to eq File.expand_path(@dest)
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#generate_gemfile" do
|
45
|
+
context "without database" do
|
46
|
+
let(:gemfile) { "#{target_dir}/Gemfile" }
|
47
|
+
let(:expected_gemfile) { File.expand_path("../../fixtures/without_db/gemfile.txt", __FILE__) }
|
48
|
+
|
49
|
+
it "should generate Gemfile without sequel" do
|
50
|
+
generator.generate_gemfile
|
51
|
+
expect_file_eq(gemfile, expected_gemfile)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with database" do
|
56
|
+
let(:gemfile) { "#{target_dir_with_db}/Gemfile" }
|
57
|
+
let(:expected_gemfile) { File.expand_path("../../fixtures/with_db/gemfile.txt", __FILE__) }
|
58
|
+
|
59
|
+
it "should generate Gemfile with sequel" do
|
60
|
+
generator_with_db.generate_gemfile
|
61
|
+
expect_file_eq(gemfile, expected_gemfile)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#generate_bundle_config" do
|
67
|
+
let(:bundle_config) { "#{target_dir}/config.ru" }
|
68
|
+
let(:expected_bundle_config) { File.expand_path("../../fixtures/config_ru.txt", __FILE__) }
|
69
|
+
|
70
|
+
it "should generate config.ru with correct content" do
|
71
|
+
generator.generate_bundle_config
|
72
|
+
expect_file_eq(bundle_config, expected_bundle_config)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#generate_puma_config" do
|
77
|
+
it "should generate puma config with correct content" do
|
78
|
+
FileUtils.mkdir_p("#{target_dir}/config/puma")
|
79
|
+
|
80
|
+
generator.generate_puma_config
|
81
|
+
|
82
|
+
puma_development = "#{target_dir}/config/puma/development.rb"
|
83
|
+
puma_production = "#{target_dir}/config/puma/production.rb"
|
84
|
+
expected_puma_development = File.expand_path("../../fixtures/config/puma/development.txt", __FILE__)
|
85
|
+
expected_puma_production = File.expand_path("../../fixtures/config/puma/production.txt", __FILE__)
|
86
|
+
|
87
|
+
expect_file_eq(puma_development, expected_puma_development)
|
88
|
+
expect_file_eq(puma_production, expected_puma_production)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#generate_app" do
|
93
|
+
it "generates home route" do
|
94
|
+
generator.generate_app
|
95
|
+
|
96
|
+
erb_file = "#{target_dir}/app/routes/home.erb"
|
97
|
+
generated_file = "#{target_dir}/app/routes/home.rb"
|
98
|
+
expected_file = File.expand_path("../../fixtures/app_routes_home.txt", __FILE__)
|
99
|
+
|
100
|
+
expect(File.exists?(erb_file)).to be_falsey
|
101
|
+
expect(File.exists?(generated_file)).to be_truthy
|
102
|
+
expect_file_eq(generated_file, expected_file)
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when generating without database" do
|
106
|
+
describe "copy_templates" do
|
107
|
+
it "copies from sinator templates" do
|
108
|
+
expected_default_files(target_dir, false)
|
109
|
+
expected_generated_files_with_db(target_dir, false)
|
110
|
+
|
111
|
+
generator.generate_app
|
112
|
+
|
113
|
+
expected_default_files(target_dir, true)
|
114
|
+
expected_generated_files_with_db(target_dir, false)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "app file" do
|
119
|
+
let(:secret) { "supersecretcookiefromgenerator" }
|
120
|
+
before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) }
|
121
|
+
|
122
|
+
it "generates <app_name>.rb, public dir, and app dir" do
|
123
|
+
generator.generate_app
|
124
|
+
|
125
|
+
generated_file = "#{target_dir}/my_app.rb"
|
126
|
+
expected_file = File.expand_path("../../fixtures/without_db/app.txt", __FILE__)
|
127
|
+
|
128
|
+
expect_file_eq(generated_file, expected_file)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "when generating with database" do
|
134
|
+
describe "copy templates" do
|
135
|
+
it "copies from sinator templates" do
|
136
|
+
expected_default_files(target_dir_with_db, false)
|
137
|
+
expected_generated_files_with_db(target_dir_with_db, false)
|
138
|
+
|
139
|
+
generator_with_db.generate_app
|
140
|
+
|
141
|
+
expected_default_files(target_dir_with_db, true)
|
142
|
+
expected_generated_files_with_db(target_dir_with_db, true)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "app file" do
|
147
|
+
let(:secret) { "supersecretcookiefromgenerator" }
|
148
|
+
before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) }
|
149
|
+
|
150
|
+
it "has sequel database connector" do
|
151
|
+
generator_with_db.generate_app
|
152
|
+
|
153
|
+
generated_file = "#{target_dir_with_db}/my_app.rb"
|
154
|
+
expected_file = File.expand_path("../../fixtures/with_db/app.txt", __FILE__)
|
155
|
+
|
156
|
+
expect_file_eq(generated_file, expected_file)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "#generate_rakefile" do
|
163
|
+
it "generate basic Rakefile tasks" do
|
164
|
+
generator.generate_rakefile
|
165
|
+
|
166
|
+
generated_file = "#{target_dir}/Rakefile"
|
167
|
+
expected_file = File.expand_path("../../fixtures/without_db/rakefile.txt", __FILE__)
|
168
|
+
|
169
|
+
expect_file_eq(generated_file, expected_file)
|
170
|
+
end
|
171
|
+
|
172
|
+
context "with database" do
|
173
|
+
it "generates db related tasks" do
|
174
|
+
generator_with_db.generate_rakefile
|
175
|
+
|
176
|
+
generated_file = "#{target_dir_with_db}/Rakefile"
|
177
|
+
expected_file = File.expand_path("../../fixtures/with_db/rakefile.txt", __FILE__)
|
178
|
+
|
179
|
+
expect_file_eq(generated_file, expected_file)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# :)
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
require_relative '../lib/sinator'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.verify_partial_doubles = true
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
config.filter_run :focus
|
15
|
+
config.run_all_when_everything_filtered = true
|
16
|
+
|
17
|
+
#config.disable_monkey_patching!
|
18
|
+
config.warnings = false
|
19
|
+
|
20
|
+
if config.files_to_run.one?
|
21
|
+
config.default_formatter = 'doc'
|
22
|
+
end
|
23
|
+
|
24
|
+
config.profile_examples = 10
|
25
|
+
config.order = :random
|
26
|
+
|
27
|
+
Kernel.srand config.seed
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kunto Aji Kristianto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-18 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.0
|
41
|
+
description: Sinator provides generator and contains minimal configuration to develop
|
42
|
+
application with Sinatra
|
43
|
+
email: kuntoaji@kaklabs.com
|
44
|
+
executables:
|
45
|
+
- sinator
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- CHANGELOG.md
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- bin/sinator
|
57
|
+
- lib/sinator.rb
|
58
|
+
- lib/sinator/command.rb
|
59
|
+
- lib/sinator/generator.rb
|
60
|
+
- lib/sinator/templates/Gemfile.erb
|
61
|
+
- lib/sinator/templates/Rakefile.erb
|
62
|
+
- lib/sinator/templates/app.erb
|
63
|
+
- lib/sinator/templates/app/routes/home.erb
|
64
|
+
- lib/sinator/templates/app/views/home/index.erb
|
65
|
+
- lib/sinator/templates/app/views/layout.erb
|
66
|
+
- lib/sinator/templates/assets/javascripts/app.js
|
67
|
+
- lib/sinator/templates/assets/javascripts/main.js
|
68
|
+
- lib/sinator/templates/assets/javascripts/plugins.js
|
69
|
+
- lib/sinator/templates/assets/stylesheets/app.css.scss
|
70
|
+
- lib/sinator/templates/assets/stylesheets/main.css.scss
|
71
|
+
- lib/sinator/templates/config.ru.erb
|
72
|
+
- lib/sinator/templates/config/application.rb
|
73
|
+
- lib/sinator/templates/config/boot.rb
|
74
|
+
- lib/sinator/templates/config/database.yml
|
75
|
+
- lib/sinator/templates/config/puma/development.erb
|
76
|
+
- lib/sinator/templates/config/puma/production.erb
|
77
|
+
- lib/sinator/templates/db/migrations/000_example.rb
|
78
|
+
- lib/sinator/templates/public/404.html
|
79
|
+
- lib/sinator/templates/public/apple-touch-icon.png
|
80
|
+
- lib/sinator/templates/public/browserconfig.xml
|
81
|
+
- lib/sinator/templates/public/crossdomain.xml
|
82
|
+
- lib/sinator/templates/public/favicon.ico
|
83
|
+
- lib/sinator/templates/public/humans.txt
|
84
|
+
- lib/sinator/templates/public/robots.txt
|
85
|
+
- lib/sinator/templates/public/tile-wide.png
|
86
|
+
- lib/sinator/templates/public/tile.png
|
87
|
+
- lib/sinator/version.rb
|
88
|
+
- sinator.gemspec
|
89
|
+
- spec/fixtures/app_routes_home.txt
|
90
|
+
- spec/fixtures/config/puma/development.txt
|
91
|
+
- spec/fixtures/config/puma/production.txt
|
92
|
+
- spec/fixtures/config_ru.txt
|
93
|
+
- spec/fixtures/with_db/app.txt
|
94
|
+
- spec/fixtures/with_db/gemfile.txt
|
95
|
+
- spec/fixtures/with_db/rakefile.txt
|
96
|
+
- spec/fixtures/without_db/app.txt
|
97
|
+
- spec/fixtures/without_db/gemfile.txt
|
98
|
+
- spec/fixtures/without_db/rakefile.txt
|
99
|
+
- spec/helpers/generator.rb
|
100
|
+
- spec/sinator/command_spec.rb
|
101
|
+
- spec/sinator/generator_spec.rb
|
102
|
+
- spec/sinator_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: http://github.com/kuntoaji/sinator
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.1'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.6.13
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Sinatra application boilerplate generator
|
128
|
+
test_files: []
|