melodiest 0.4.0 → 1.0.0
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/CHANGELOG.md +12 -0
- data/Gemfile.lock +2 -2
- data/README.md +17 -12
- data/lib/melodiest.rb +4 -2
- data/lib/melodiest/command.rb +1 -1
- data/lib/melodiest/generator.rb +36 -52
- data/lib/melodiest/setting.rb +1 -5
- data/lib/melodiest/templates/Gemfile.erb +16 -0
- data/lib/melodiest/templates/Rakefile.erb +23 -0
- data/lib/melodiest/templates/app.erb +47 -0
- data/lib/melodiest/templates/app/routes/home.erb +6 -0
- data/lib/melodiest/templates/app/views/home/index.erb +1 -0
- data/lib/melodiest/templates/app/views/layout.erb +22 -0
- data/lib/melodiest/templates/assets/javascripts/app.js +2 -0
- data/lib/melodiest/templates/assets/javascripts/main.js +1 -0
- data/lib/melodiest/templates/assets/javascripts/plugins.js +24 -0
- data/lib/melodiest/templates/assets/stylesheets/app.css.scss +1 -0
- data/lib/melodiest/templates/assets/stylesheets/main.css.scss +8 -0
- data/lib/melodiest/templates/config.ru.erb +5 -0
- data/lib/melodiest/templates/config/application.rb +7 -0
- data/lib/melodiest/templates/config/boot.rb +10 -0
- data/lib/melodiest/templates/public/.DS_Store +0 -0
- data/lib/melodiest/templates/public/404.html +60 -0
- data/lib/melodiest/templates/public/apple-touch-icon.png +0 -0
- data/lib/melodiest/templates/public/browserconfig.xml +12 -0
- data/lib/melodiest/templates/public/crossdomain.xml +15 -0
- data/lib/melodiest/templates/public/favicon.ico +0 -0
- data/lib/melodiest/templates/public/humans.txt +15 -0
- data/lib/melodiest/templates/public/robots.txt +5 -0
- data/lib/melodiest/templates/public/tile-wide.png +0 -0
- data/lib/melodiest/templates/public/tile.png +0 -0
- data/lib/melodiest/version.rb +1 -1
- data/spec/fixtures/app_routes_home.txt +6 -0
- data/spec/fixtures/config_ru.txt +5 -0
- data/spec/fixtures/with_db/app.txt +42 -0
- data/spec/fixtures/with_db/gemfile.txt +14 -0
- data/{lib/melodiest/templates/Rakefile → spec/fixtures/with_db/rakefile.txt} +6 -5
- data/spec/fixtures/without_db/app.txt +15 -0
- data/spec/fixtures/without_db/gemfile.txt +8 -0
- data/spec/fixtures/without_db/rakefile.txt +5 -0
- data/spec/melodiest/command_spec.rb +0 -1
- data/spec/melodiest/generator_spec.rb +137 -104
- data/spec/melodiest_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -1
- metadata +35 -4
- data/spec/melodiest/setting_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eece355e0a6414d9bc928d73070eee099b9df27a
|
4
|
+
data.tar.gz: 18e71602d9b587def177b120c8bedf2947125d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b276aab69efe0e3239d75441a06e82a86aabfd139fd6c2dfa46daed8c93f06d1e1020c569d5d6ad0b552d9487532e799ee4fdb164835347151a3bbcd6836a0
|
7
|
+
data.tar.gz: fbde39029c8854b4703a3a653499750e83faf28436e70c5000423a6e46a16cabe195731159393cdc4bb828dd0517c65d6dde102225f3fba2eb7a95e425b4fdbc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
development:
|
2
|
+
* prevent tux to be required
|
3
|
+
* add sinatra assets pipeline extension
|
4
|
+
* restructure generated app
|
5
|
+
* use erb for app templates
|
6
|
+
* create Rakefile generator with and without database
|
7
|
+
* add new Sequel configuration when generating app with database
|
8
|
+
* add Sinatra::Cache extension
|
9
|
+
* remove Melodiest::Setting. Rename setup method to cookie_secret.
|
10
|
+
* restructure generated app
|
11
|
+
* add some configurations from h5bp
|
12
|
+
|
1
13
|
0.4.0:
|
2
14
|
* add SQL logger to development environment
|
3
15
|
* generate public dir when running generator
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
melodiest (0.
|
4
|
+
melodiest (0.4.0)
|
5
5
|
encrypted_cookie (= 0.0.4)
|
6
6
|
sinatra (= 1.4.6)
|
7
7
|
sinatra-contrib (= 1.4.2)
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
backports (3.6.4)
|
13
13
|
diff-lcs (1.2.5)
|
14
14
|
encrypted_cookie (0.0.4)
|
15
|
-
multi_json (1.11.
|
15
|
+
multi_json (1.11.2)
|
16
16
|
rack (1.6.0)
|
17
17
|
rack-protection (1.5.3)
|
18
18
|
rack
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Background
|
2
2
|
|
3
|
-
Melodiest is [Sinatra](http://www.sinatrarb.com/) application boilerplate. It provides generator and contains
|
3
|
+
Melodiest is [Sinatra](http://www.sinatrarb.com/) application boilerplate. It provides generator and contains minimum configuration to develop application with Sinatra.
|
4
|
+
The reason why I create Melodiest is because I want to create many small web application based on sinatra with other third party ruby gems as foundation.
|
5
|
+
Originally, I wanted to name this project as Harmony or Melody, but because it was already taken I decided to name this project as Melodiest.
|
4
6
|
|
5
7
|
### Installation
|
6
8
|
|
@@ -36,13 +38,13 @@ melodiest -n my_app -d
|
|
36
38
|
### Melodiest::Application
|
37
39
|
Because Melodiest is already required Sinatra, you don't have to require 'sinatra' anymore, just require 'melodiest'.
|
38
40
|
|
39
|
-
`Melodiest::Application` is subclass from `Sinatra::Application
|
41
|
+
`Melodiest::Application` is subclass from `Sinatra::Application`.
|
40
42
|
|
41
43
|
```ruby
|
42
44
|
# my_app.rb
|
43
45
|
|
44
46
|
class App < Melodiest::Application
|
45
|
-
|
47
|
+
cookie_secret 'this_is_secret_for_encrypted_cookie'
|
46
48
|
...
|
47
49
|
end
|
48
50
|
```
|
@@ -83,10 +85,6 @@ For complete example see [github.com/kuntoaji/todo_melodiest](https://github.com
|
|
83
85
|
|
84
86
|
```ruby
|
85
87
|
class MyApp
|
86
|
-
get '/' do
|
87
|
-
"hello world!"
|
88
|
-
end
|
89
|
-
|
90
88
|
get '/artists' do
|
91
89
|
@artists = Artist.all
|
92
90
|
erb :"artists/index"
|
@@ -122,11 +120,18 @@ For complete example see [github.com/kuntoaji/todo_melodiest](https://github.com
|
|
122
120
|
10. run the server `bundle exec thin start`
|
123
121
|
11. open url `localhost:3000/artists`
|
124
122
|
|
125
|
-
###
|
123
|
+
### List of Ruby Gems
|
126
124
|
|
125
|
+
* sinatra (required by default)
|
126
|
+
* sinatra-contrib (required by default)
|
127
|
+
* encrypted_cookie (required by default)
|
127
128
|
* `Sinatra::Reloader` in development environment only
|
128
|
-
*
|
129
|
+
* thin
|
129
130
|
* `Rack::Session::EncryptedCookie`
|
130
131
|
* `Rack::Csrf`
|
131
|
-
*
|
132
|
-
*
|
132
|
+
* sequel
|
133
|
+
* sequel_pg as PostgreSQL adapter
|
134
|
+
* sinatra-asset-pipeline
|
135
|
+
* uglifier
|
136
|
+
* tux for console
|
137
|
+
* `Sinatra::Cache` in production environment only
|
data/lib/melodiest.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'encrypted_cookie'
|
3
|
-
require 'melodiest/setting'
|
4
3
|
|
5
4
|
module Melodiest
|
6
5
|
class Application < Sinatra::Application
|
7
|
-
|
6
|
+
def self.cookie_secret(secret)
|
7
|
+
use Rack::Session::EncryptedCookie,
|
8
|
+
secret: secret
|
9
|
+
end
|
8
10
|
|
9
11
|
# http://www.sinatrarb.com/contrib/reloader.html
|
10
12
|
configure :development do
|
data/lib/melodiest/command.rb
CHANGED
@@ -45,10 +45,10 @@ module Melodiest
|
|
45
45
|
generator = Melodiest::Generator.new args[:name],
|
46
46
|
destination: args[:target], with_database: args[:database]
|
47
47
|
|
48
|
+
generator.generate_rakefile
|
48
49
|
generator.generate_gemfile
|
49
50
|
generator.generate_bundle_config
|
50
51
|
generator.generate_app
|
51
|
-
generator.copy_templates
|
52
52
|
|
53
53
|
msg = "#{args[:name]} is successfully generated"
|
54
54
|
msg << " in #{args[:target]}" if args[:target]
|
data/lib/melodiest/generator.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'securerandom'
|
3
|
+
require 'erb'
|
3
4
|
require_relative 'version'
|
4
5
|
|
5
6
|
module Melodiest
|
@@ -21,83 +22,66 @@ module Melodiest
|
|
21
22
|
@destination = File.expand_path(destination)
|
22
23
|
end
|
23
24
|
|
25
|
+
def generate_rakefile
|
26
|
+
gemfile = File.read File.expand_path("../templates/Rakefile.erb", __FILE__)
|
27
|
+
erb = ERB.new gemfile, 0, '-'
|
28
|
+
|
29
|
+
File.open "#{@destination}/Rakefile", "w" do |f|
|
30
|
+
f.write erb.result(binding)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
def generate_gemfile
|
35
|
+
gemfile = File.read File.expand_path("../templates/Gemfile.erb", __FILE__)
|
36
|
+
erb = ERB.new gemfile, 0, '-'
|
37
|
+
|
25
38
|
File.open "#{@destination}/Gemfile", "w" do |f|
|
26
|
-
f.write
|
27
|
-
f.write("gem 'melodiest', '#{Melodiest::VERSION}'\n")
|
28
|
-
f.write("gem 'thin'\n")
|
29
|
-
f.write("gem 'tux'\n")
|
30
|
-
f.write("gem 'rack_csrf', require: 'rack/csrf'")
|
31
|
-
|
32
|
-
if @with_database
|
33
|
-
f.write("\ngem 'sequel'\n")
|
34
|
-
f.write("gem 'sequel_pg', require: 'sequel'")
|
35
|
-
end
|
39
|
+
f.write erb.result(binding)
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
def generate_bundle_config
|
44
|
+
config_ru = File.read File.expand_path("../templates/config.ru.erb", __FILE__)
|
45
|
+
erb = ERB.new config_ru
|
46
|
+
|
40
47
|
File.open "#{@destination}/config.ru", "w" do |f|
|
41
|
-
f.write(
|
42
|
-
f.write("require 'rubygems'\n")
|
43
|
-
f.write("require 'bundler'\n\n")
|
44
|
-
f.write("Bundler.require :default, ENV['RACK_ENV'].to_sym\n\n")
|
45
|
-
f.write("require './#{@app_name}'\n")
|
46
|
-
f.write("run #{@app_class_name}\n")
|
48
|
+
f.write erb.result(binding)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
52
|
# https://github.com/sinatra/sinatra-book/blob/master/book/Organizing_your_application.markdown
|
51
53
|
def generate_app
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
content[:yaml] = "require 'yaml'\n\n"
|
56
|
-
content[:database] = " configure :development, :test do\n"
|
57
|
-
content[:database] << " require 'logger'\n\n"
|
58
|
-
content[:database] << " Sequel.connect YAML.load_file(File.expand_path(\"../config/database.yml\", __FILE__))[settings.environment.to_s],\n"
|
59
|
-
content[:database] << " loggers: [Logger.new($stdout)]\n"
|
60
|
-
content[:database] << " end\n\n"
|
61
|
-
content[:database] << " configure :production do\n"
|
62
|
-
content[:database] << " Sequel.connect YAML.load_file(File.expand_path(\"../config/database.yml\", __FILE__))['production']\n"
|
63
|
-
content[:database] << " end\n"
|
64
|
-
else
|
65
|
-
content[:yaml] = nil
|
66
|
-
content[:database] = " configure do\n"
|
67
|
-
content[:database] << " # Load up database and such\n"
|
68
|
-
content[:database] << " end\n"
|
69
|
-
end
|
54
|
+
copy_templates
|
55
|
+
app = File.read File.expand_path("../templates/app.erb", __FILE__)
|
56
|
+
erb = ERB.new app, 0, '-'
|
70
57
|
|
71
58
|
File.open "#{@destination}/#{@app_name}.rb", "w" do |f|
|
72
|
-
f.write(
|
73
|
-
f.write("class #{app_class_name} < Melodiest::Application\n")
|
74
|
-
f.write(" setup '#{SecureRandom.hex(32)}'\n\n")
|
75
|
-
f.write(" set :app_file, __FILE__\n")
|
76
|
-
f.write(" set :views, Proc.new { File.join(root, \"app/views\") }\n\n")
|
77
|
-
f.write(" use Rack::Csrf, raise: true\n\n")
|
78
|
-
f.write(content[:database])
|
79
|
-
f.write("end\n\n")
|
80
|
-
f.write("%w{app/models app/routes}.each do |dir|\n")
|
81
|
-
f.write(" Dir[File.join(dir, '**/*.rb')].each do |file|\n")
|
82
|
-
f.write(" require_relative file\n")
|
83
|
-
f.write(" end\n")
|
84
|
-
f.write("end\n")
|
59
|
+
f.write erb.result(binding)
|
85
60
|
end
|
86
61
|
|
87
|
-
|
62
|
+
route = File.read File.expand_path("../templates/app/routes/home.erb", __FILE__)
|
63
|
+
erb = ERB.new route, 0, '-'
|
88
64
|
|
89
|
-
|
90
|
-
|
91
|
-
FileUtils.mkdir "#{app_dir}/#{dir}"
|
65
|
+
File.open "#{@destination}/app/routes/home.rb", "w" do |f|
|
66
|
+
f.write erb.result(binding)
|
92
67
|
end
|
68
|
+
|
69
|
+
FileUtils.rm "#{@destination}/app/routes/home.erb"
|
93
70
|
end
|
94
71
|
|
72
|
+
private
|
73
|
+
|
95
74
|
def copy_templates
|
75
|
+
FileUtils.cp_r File.expand_path("../templates/assets", __FILE__), @destination
|
96
76
|
FileUtils.cp_r File.expand_path("../templates/config", __FILE__), @destination
|
77
|
+
FileUtils.cp_r File.expand_path("../templates/public", __FILE__), @destination
|
78
|
+
FileUtils.cp_r File.expand_path("../templates/app", __FILE__), @destination
|
97
79
|
|
98
80
|
if @with_database
|
99
|
-
FileUtils.
|
81
|
+
FileUtils.mkdir "#{@destination}/app/models"
|
100
82
|
FileUtils.cp_r File.expand_path("../templates/db", __FILE__), @destination
|
83
|
+
else
|
84
|
+
FileUtils.rm "#{@destination}/config/database.yml.example"
|
101
85
|
end
|
102
86
|
end
|
103
87
|
end
|
data/lib/melodiest/setting.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'melodiest', '<%= Melodiest::VERSION %>'
|
4
|
+
gem 'thin'
|
5
|
+
gem 'tux', require: false
|
6
|
+
gem 'sinatra-asset-pipeline', require: 'sinatra/asset_pipeline'
|
7
|
+
gem 'uglifier', require: false
|
8
|
+
gem 'rack_csrf', require: 'rack/csrf'
|
9
|
+
<% if @with_database -%>
|
10
|
+
gem 'sequel'
|
11
|
+
gem 'sequel_pg', require: 'sequel'
|
12
|
+
|
13
|
+
group :production do
|
14
|
+
gem 'sinatra-cache'
|
15
|
+
end
|
16
|
+
<% end -%>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'config/boot'
|
2
|
+
require_relative '<%= @app_name %>'
|
3
|
+
require 'sinatra/asset_pipeline/task'
|
4
|
+
|
5
|
+
Sinatra::AssetPipeline::Task.define! <%= @app_class_name %>
|
6
|
+
<% if @with_database %>
|
7
|
+
namespace :db do
|
8
|
+
desc "Run migrations"
|
9
|
+
task :migrate, [:version] do |t, args|
|
10
|
+
Sequel.extension :migration
|
11
|
+
db = Sequel.connect(YAML.load_file("#{Melodiest::ROOT}/config/database.yml")[ENV['RACK_ENV']])
|
12
|
+
migration_path = "#{Melodiest::ROOT}/db/migrations"
|
13
|
+
|
14
|
+
if args[:version]
|
15
|
+
puts "Migrating to version #{args[:version]}"
|
16
|
+
Sequel::Migrator.run(db, migration_path, target: args[:version].to_i)
|
17
|
+
else
|
18
|
+
puts "Migrating to latest"
|
19
|
+
Sequel::Migrator.run(db, migration_path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
<% end -%>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<%= "require 'yaml'\n\n" if @with_database -%>
|
2
|
+
class <%= @app_class_name %> < Melodiest::Application
|
3
|
+
cookie_secret '<%= SecureRandom.hex 32 %>'
|
4
|
+
|
5
|
+
set :app_file, __FILE__
|
6
|
+
set :views, Proc.new { File.join(root, "app/views") }
|
7
|
+
set :assets_css_compressor, :sass
|
8
|
+
set :assets_js_compressor, :uglifier
|
9
|
+
|
10
|
+
register Sinatra::AssetPipeline
|
11
|
+
use Rack::Csrf, raise: true
|
12
|
+
|
13
|
+
<% if @with_database -%>
|
14
|
+
configure do
|
15
|
+
Sequel::Database.extension :pagination
|
16
|
+
Sequel::Model.plugin :timestamps
|
17
|
+
Sequel::Model.plugin :auto_validations,
|
18
|
+
not_null: :presence, unique_opts: { only_if_modified: true }
|
19
|
+
end
|
20
|
+
|
21
|
+
configure :development do
|
22
|
+
require 'logger'
|
23
|
+
|
24
|
+
Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['development'],
|
25
|
+
loggers: [Logger.new($stdout)]
|
26
|
+
end
|
27
|
+
|
28
|
+
configure :test do
|
29
|
+
Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['test']
|
30
|
+
end
|
31
|
+
|
32
|
+
configure :production do
|
33
|
+
# Serve assets via Nginx or Apache
|
34
|
+
disable :static
|
35
|
+
|
36
|
+
register Sinatra::Cache
|
37
|
+
set :cache_enabled, true
|
38
|
+
set :cache_output_dir, Proc.new { File.join(root, "public/cache") }
|
39
|
+
|
40
|
+
Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['production']
|
41
|
+
end
|
42
|
+
<% else -%>
|
43
|
+
configure do
|
44
|
+
# Load up database and such
|
45
|
+
end
|
46
|
+
<% end -%>
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @home %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html class="no-js" lang="id">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
6
|
+
<title>My Title</title>
|
7
|
+
<meta name="description" content="my description">
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
|
+
|
10
|
+
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
11
|
+
<link rel="stylesheet" type="text/css" href="<%= stylesheet_path 'app' %>">
|
12
|
+
|
13
|
+
<script src="<%= javascript_path 'app' %>"></script>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<!--[if lt IE 8]>
|
17
|
+
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
18
|
+
<![endif]-->
|
19
|
+
|
20
|
+
<%= yield %>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
/* custom js */
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// Avoid `console` errors in browsers that lack a console.
|
2
|
+
(function() {
|
3
|
+
var method;
|
4
|
+
var noop = function () {};
|
5
|
+
var methods = [
|
6
|
+
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
|
7
|
+
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
|
8
|
+
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
|
9
|
+
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
|
10
|
+
];
|
11
|
+
var length = methods.length;
|
12
|
+
var console = (window.console = window.console || {});
|
13
|
+
|
14
|
+
while (length--) {
|
15
|
+
method = methods[length];
|
16
|
+
|
17
|
+
// Only stub undefined methods.
|
18
|
+
if (!console[method]) {
|
19
|
+
console[method] = noop;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}());
|
23
|
+
|
24
|
+
// Place any jQuery/helper plugins in here.
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require main
|
Binary file
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Page Not Found</title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<style>
|
8
|
+
|
9
|
+
* {
|
10
|
+
line-height: 1.2;
|
11
|
+
margin: 0;
|
12
|
+
}
|
13
|
+
|
14
|
+
html {
|
15
|
+
color: #888;
|
16
|
+
display: table;
|
17
|
+
font-family: sans-serif;
|
18
|
+
height: 100%;
|
19
|
+
text-align: center;
|
20
|
+
width: 100%;
|
21
|
+
}
|
22
|
+
|
23
|
+
body {
|
24
|
+
display: table-cell;
|
25
|
+
vertical-align: middle;
|
26
|
+
margin: 2em auto;
|
27
|
+
}
|
28
|
+
|
29
|
+
h1 {
|
30
|
+
color: #555;
|
31
|
+
font-size: 2em;
|
32
|
+
font-weight: 400;
|
33
|
+
}
|
34
|
+
|
35
|
+
p {
|
36
|
+
margin: 0 auto;
|
37
|
+
width: 280px;
|
38
|
+
}
|
39
|
+
|
40
|
+
@media only screen and (max-width: 280px) {
|
41
|
+
|
42
|
+
body, p {
|
43
|
+
width: 95%;
|
44
|
+
}
|
45
|
+
|
46
|
+
h1 {
|
47
|
+
font-size: 1.5em;
|
48
|
+
margin: 0 0 0.3em;
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
</style>
|
54
|
+
</head>
|
55
|
+
<body>
|
56
|
+
<h1>Page Not Found</h1>
|
57
|
+
<p>Sorry, but the page you were trying to view does not exist.</p>
|
58
|
+
</body>
|
59
|
+
</html>
|
60
|
+
<!-- IE needs 512+ bytes: http://blogs.msdn.com/b/ieinternals/archive/2010/08/19/http-error-pages-in-internet-explorer.aspx -->
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Please read: http://msdn.microsoft.com/en-us/library/ie/dn455106.aspx -->
|
3
|
+
<browserconfig>
|
4
|
+
<msapplication>
|
5
|
+
<tile>
|
6
|
+
<square70x70logo src="tile.png"/>
|
7
|
+
<square150x150logo src="tile.png"/>
|
8
|
+
<wide310x150logo src="tile-wide.png"/>
|
9
|
+
<square310x310logo src="tile.png"/>
|
10
|
+
</tile>
|
11
|
+
</msapplication>
|
12
|
+
</browserconfig>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
|
3
|
+
<cross-domain-policy>
|
4
|
+
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
|
5
|
+
|
6
|
+
<!-- Most restrictive policy: -->
|
7
|
+
<site-control permitted-cross-domain-policies="none"/>
|
8
|
+
|
9
|
+
<!-- Least restrictive policy: -->
|
10
|
+
<!--
|
11
|
+
<site-control permitted-cross-domain-policies="all"/>
|
12
|
+
<allow-access-from domain="*" to-ports="*" secure="false"/>
|
13
|
+
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
|
14
|
+
-->
|
15
|
+
</cross-domain-policy>
|
Binary file
|
Binary file
|
Binary file
|
data/lib/melodiest/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class MyApp < Melodiest::Application
|
4
|
+
cookie_secret 'supersecretcookiefromgenerator'
|
5
|
+
|
6
|
+
set :app_file, __FILE__
|
7
|
+
set :views, Proc.new { File.join(root, "app/views") }
|
8
|
+
set :assets_css_compressor, :sass
|
9
|
+
set :assets_js_compressor, :uglifier
|
10
|
+
|
11
|
+
register Sinatra::AssetPipeline
|
12
|
+
use Rack::Csrf, raise: true
|
13
|
+
|
14
|
+
configure do
|
15
|
+
Sequel::Database.extension :pagination
|
16
|
+
Sequel::Model.plugin :timestamps
|
17
|
+
Sequel::Model.plugin :auto_validations,
|
18
|
+
not_null: :presence, unique_opts: { only_if_modified: true }
|
19
|
+
end
|
20
|
+
|
21
|
+
configure :development do
|
22
|
+
require 'logger'
|
23
|
+
|
24
|
+
Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['development'],
|
25
|
+
loggers: [Logger.new($stdout)]
|
26
|
+
end
|
27
|
+
|
28
|
+
configure :test do
|
29
|
+
Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['test']
|
30
|
+
end
|
31
|
+
|
32
|
+
configure :production do
|
33
|
+
# Serve assets via Nginx or Apache
|
34
|
+
disable :static
|
35
|
+
|
36
|
+
register Sinatra::Cache
|
37
|
+
set :cache_enabled, true
|
38
|
+
set :cache_output_dir, Proc.new { File.join(root, "public/cache") }
|
39
|
+
|
40
|
+
Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['production']
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'melodiest', '0.4.0'
|
4
|
+
gem 'thin'
|
5
|
+
gem 'tux', require: false
|
6
|
+
gem 'sinatra-asset-pipeline', require: 'sinatra/asset_pipeline'
|
7
|
+
gem 'uglifier', require: false
|
8
|
+
gem 'rack_csrf', require: 'rack/csrf'
|
9
|
+
gem 'sequel'
|
10
|
+
gem 'sequel_pg', require: 'sequel'
|
11
|
+
|
12
|
+
group :production do
|
13
|
+
gem 'sinatra-cache'
|
14
|
+
end
|
@@ -1,14 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative 'config/boot'
|
2
|
+
require_relative 'my_app'
|
3
|
+
require 'sinatra/asset_pipeline/task'
|
3
4
|
|
4
|
-
|
5
|
+
Sinatra::AssetPipeline::Task.define! MyApp
|
5
6
|
|
6
7
|
namespace :db do
|
7
8
|
desc "Run migrations"
|
8
9
|
task :migrate, [:version] do |t, args|
|
9
10
|
Sequel.extension :migration
|
10
|
-
db = Sequel.connect(YAML.load_file(
|
11
|
-
migration_path =
|
11
|
+
db = Sequel.connect(YAML.load_file("#{Melodiest::ROOT}/config/database.yml")[ENV['RACK_ENV']])
|
12
|
+
migration_path = "#{Melodiest::ROOT}/db/migrations"
|
12
13
|
|
13
14
|
if args[:version]
|
14
15
|
puts "Migrating to version #{args[:version]}"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class MyApp < Melodiest::Application
|
2
|
+
cookie_secret 'supersecretcookiefromgenerator'
|
3
|
+
|
4
|
+
set :app_file, __FILE__
|
5
|
+
set :views, Proc.new { File.join(root, "app/views") }
|
6
|
+
set :assets_css_compressor, :sass
|
7
|
+
set :assets_js_compressor, :uglifier
|
8
|
+
|
9
|
+
register Sinatra::AssetPipeline
|
10
|
+
use Rack::Csrf, raise: true
|
11
|
+
|
12
|
+
configure do
|
13
|
+
# Load up database and such
|
14
|
+
end
|
15
|
+
end
|
@@ -42,7 +42,6 @@ describe Melodiest::Command do
|
|
42
42
|
it "has --database option" do
|
43
43
|
app = Melodiest::Command.parse %w(-n my_app --target /tmp -d)
|
44
44
|
|
45
|
-
puts `ls /tmp/my_app`
|
46
45
|
expect(app).to include "my_app is successfully generated in /tmp"
|
47
46
|
expect(Dir.exists?("/tmp/my_app/db")).to be_truthy
|
48
47
|
end
|
@@ -31,7 +31,9 @@ describe Melodiest::Generator do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "has default destination path app_name" do
|
34
|
+
FileUtils.rm_r @app if Dir.exists?(@app)
|
34
35
|
expect(Melodiest::Generator.new(@app).destination).to eq File.expand_path(@app)
|
36
|
+
FileUtils.rm_r @app
|
35
37
|
end
|
36
38
|
|
37
39
|
it "sets new destination path even if it's not exist yet" do
|
@@ -45,15 +47,10 @@ describe Melodiest::Generator do
|
|
45
47
|
it "should generate Gemfile without sequel" do
|
46
48
|
generator.generate_gemfile
|
47
49
|
file_content = File.read(gemfile)
|
50
|
+
expected_file_content = File.read(File.expand_path("../../fixtures/without_db/gemfile.txt", __FILE__))
|
48
51
|
|
49
52
|
expect(File.exists?(gemfile)).to be_truthy
|
50
|
-
expect(file_content).to
|
51
|
-
expect(file_content).to include "gem 'melodiest', '#{Melodiest::VERSION}'"
|
52
|
-
expect(file_content).to include "gem 'thin'"
|
53
|
-
expect(file_content).to include "gem 'tux'"
|
54
|
-
expect(file_content).to include "gem 'rack_csrf', require: 'rack/csrf'"
|
55
|
-
expect(file_content).to_not include "gem 'sequel'"
|
56
|
-
expect(file_content).to_not include "gem 'sequel_pg'"
|
53
|
+
expect(file_content).to eq(expected_file_content)
|
57
54
|
end
|
58
55
|
end
|
59
56
|
|
@@ -63,8 +60,10 @@ describe Melodiest::Generator do
|
|
63
60
|
it "should generate Gemfile with sequel" do
|
64
61
|
generator_with_db.generate_gemfile
|
65
62
|
file_content = File.read(gemfile)
|
66
|
-
|
67
|
-
|
63
|
+
expected_file_content = File.read(File.expand_path("../../fixtures/with_db/gemfile.txt", __FILE__))
|
64
|
+
|
65
|
+
expect(File.exists?(gemfile)).to be_truthy
|
66
|
+
expect(file_content).to eq(expected_file_content)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
@@ -75,132 +74,166 @@ describe Melodiest::Generator do
|
|
75
74
|
it "should generate config.ru with correct content" do
|
76
75
|
generator.generate_bundle_config
|
77
76
|
file_content = File.read(bundle_config)
|
77
|
+
expected_file_content = File.read(File.expand_path("../../fixtures/config_ru.txt", __FILE__))
|
78
78
|
|
79
79
|
expect(File.exists?(bundle_config)).to be_truthy
|
80
|
-
expect(file_content).to
|
81
|
-
expect(file_content).to include "require 'rubygems'"
|
82
|
-
expect(file_content).to include "require 'bundler'"
|
83
|
-
expect(file_content).to include "Bundler.require :default, ENV['RACK_ENV'].to_sym"
|
84
|
-
expect(file_content).to include "require './my_app'"
|
85
|
-
expect(file_content).to include "run MyApp"
|
80
|
+
expect(file_content).to eq(expected_file_content)
|
86
81
|
end
|
87
82
|
end
|
88
83
|
|
89
84
|
describe "#generate_app" do
|
90
|
-
|
91
|
-
before {
|
85
|
+
before { FileUtils.rm_r @dest if Dir.exists?(@dest) }
|
86
|
+
before { FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db) }
|
92
87
|
|
93
|
-
it "generates
|
94
|
-
FileUtils.rm_r @dest if Dir.exists?(@dest)
|
88
|
+
it "generates home route" do
|
95
89
|
generator.generate_app
|
96
|
-
app_file = "#{target_dir}/my_app.rb"
|
97
|
-
file_content = File.read(app_file)
|
98
|
-
|
99
|
-
expected_file_content =
|
100
|
-
<<DOC
|
101
|
-
class MyApp < Melodiest::Application
|
102
|
-
setup '#{secret}'
|
103
90
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
configure do
|
110
|
-
# Load up database and such
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
%w{app/models app/routes}.each do |dir|
|
115
|
-
Dir[File.join(dir, '**/*.rb')].each do |file|
|
116
|
-
require_relative file
|
117
|
-
end
|
118
|
-
end
|
119
|
-
DOC
|
91
|
+
app_file = "#{target_dir}/app/routes/home.rb"
|
92
|
+
erb_file = "#{target_dir}/app/routes/home.erb"
|
93
|
+
file_content = File.read(app_file)
|
94
|
+
expected_file_content = File.read(File.expand_path("../../fixtures/app_routes_home.txt", __FILE__))
|
120
95
|
|
121
96
|
expect(File.exists?(app_file)).to be_truthy
|
97
|
+
expect(File.exists?(erb_file)).to be_falsey
|
122
98
|
expect(file_content).to eq expected_file_content
|
123
|
-
expect(Dir.exists?("#{target_dir}/public")).to be_truthy
|
124
|
-
expect(Dir.exists?("#{target_dir}/app")).to be_truthy
|
125
|
-
expect(Dir.exists?("#{target_dir}/app/routes")).to be_truthy
|
126
|
-
expect(Dir.exists?("#{target_dir}/app/models")).to be_truthy
|
127
|
-
expect(Dir.exists?("#{target_dir}/app/views")).to be_truthy
|
128
99
|
end
|
129
100
|
|
130
|
-
context "
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
101
|
+
context "when generating without database" do
|
102
|
+
describe "copy_templates" do
|
103
|
+
let(:config_dir) { "#{target_dir}/config" }
|
104
|
+
let(:assets_dir) { "#{target_dir}/assets" }
|
105
|
+
let(:public_dir) { "#{target_dir}/public" }
|
106
|
+
let(:without_db_sample_migration) { "#{target_dir}/db_migrations/000_example.rb" }
|
107
|
+
|
108
|
+
it "copies from melodiest templates" do
|
109
|
+
expect(File.exists?(config_dir)).to be_falsey
|
110
|
+
expect(File.exists?(without_db_sample_migration)).to be_falsey
|
111
|
+
expect(File.exists?(assets_dir)).to be_falsey
|
112
|
+
expect(File.exists?(public_dir)).to be_falsey
|
113
|
+
|
114
|
+
expect(Dir.exists?("#{target_dir}/app")).to be_falsey
|
115
|
+
expect(Dir.exists?("#{target_dir}/app/routes")).to be_falsey
|
116
|
+
expect(Dir.exists?("#{target_dir}/app/models")).to be_falsey
|
117
|
+
expect(Dir.exists?("#{target_dir}/app/views")).to be_falsey
|
118
|
+
expect(File.exists?("#{target_dir}/app/views/layout.erb")).to be_falsey
|
119
|
+
expect(File.exists?("#{target_dir}/app/views/home/index.erb")).to be_falsey
|
120
|
+
|
121
|
+
generator.generate_app
|
122
|
+
|
123
|
+
expect(File.exists?(config_dir)).to be_truthy
|
124
|
+
expect(File.exists?("#{config_dir}/database.yml.example")).to be_falsey
|
125
|
+
expect(File.exists?(without_db_sample_migration)).to be_falsey
|
126
|
+
expect(File.exists?(assets_dir)).to be_truthy
|
127
|
+
expect(File.exists?(public_dir)).to be_truthy
|
128
|
+
|
129
|
+
expect(Dir.exists?("#{target_dir}/app")).to be_truthy
|
130
|
+
expect(Dir.exists?("#{target_dir}/app/routes")).to be_truthy
|
131
|
+
expect(Dir.exists?("#{target_dir}/app/models")).to be_falsey
|
132
|
+
expect(Dir.exists?("#{target_dir}/app/views")).to be_truthy
|
133
|
+
expect(File.exists?("#{target_dir}/app/views/layout.erb")).to be_truthy
|
134
|
+
expect(File.exists?("#{target_dir}/app/views/home/index.erb")).to be_truthy
|
135
|
+
end
|
136
|
+
end
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
describe "app file" do
|
139
|
+
let(:secret) { "supersecretcookiefromgenerator" }
|
140
|
+
before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) }
|
140
141
|
|
141
|
-
|
142
|
-
|
142
|
+
it "generates <app_name>.rb, public dir, and app dir" do
|
143
|
+
generator.generate_app
|
143
144
|
|
144
|
-
|
145
|
-
|
145
|
+
app_file = "#{target_dir}/my_app.rb"
|
146
|
+
file_content = File.read(app_file)
|
147
|
+
expected_file_content = File.read(File.expand_path("../../fixtures/without_db/app.txt", __FILE__))
|
146
148
|
|
147
|
-
|
149
|
+
expect(File.exists?(app_file)).to be_truthy
|
150
|
+
expect(file_content).to eq expected_file_content
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
148
154
|
|
149
|
-
|
150
|
-
|
155
|
+
context "when generating with database" do
|
156
|
+
describe "copy templates" do
|
157
|
+
let(:config_dir) { "#{target_dir_with_db}/config" }
|
158
|
+
let(:assets_dir) { "#{target_dir_with_db}/assets" }
|
159
|
+
let(:public_dir) { "#{target_dir_with_db}/public" }
|
160
|
+
let(:with_db_sample_migration) { "#{target_dir_with_db}/db/migrations/000_example.rb" }
|
161
|
+
|
162
|
+
it "copies from melodiest templates" do
|
163
|
+
expect(File.exists?(config_dir)).to be_falsey
|
164
|
+
expect(File.exists?("#{config_dir}/database.yml.example")).to be_falsey
|
165
|
+
expect(File.exists?("#{config_dir}/boot.rb")).to be_falsey
|
166
|
+
expect(File.exists?("#{config_dir}/application.rb")).to be_falsey
|
167
|
+
|
168
|
+
expect(File.exists?(with_db_sample_migration)).to be_falsey
|
169
|
+
expect(File.exists?(assets_dir)).to be_falsey
|
170
|
+
expect(File.exists?(public_dir)).to be_falsey
|
171
|
+
|
172
|
+
expect(Dir.exists?("#{target_dir_with_db}/app")).to be_falsey
|
173
|
+
expect(Dir.exists?("#{target_dir_with_db}/app/routes")).to be_falsey
|
174
|
+
expect(Dir.exists?("#{target_dir_with_db}/app/models")).to be_falsey
|
175
|
+
expect(Dir.exists?("#{target_dir_with_db}/app/views")).to be_falsey
|
176
|
+
expect(File.exists?("#{target_dir_with_db}/app/views/layout.erb")).to be_falsey
|
177
|
+
expect(File.exists?("#{target_dir_with_db}/app/views/home/index.erb")).to be_falsey
|
178
|
+
|
179
|
+
generator_with_db.generate_app
|
180
|
+
|
181
|
+
expect(File.exists?(config_dir)).to be_truthy
|
182
|
+
expect(File.exists?("#{config_dir}/database.yml.example")).to be_truthy
|
183
|
+
expect(File.exists?("#{config_dir}/boot.rb")).to be_truthy
|
184
|
+
expect(File.exists?("#{config_dir}/application.rb")).to be_truthy
|
185
|
+
|
186
|
+
expect(File.exists?(with_db_sample_migration)).to be_truthy
|
187
|
+
expect(File.exists?(assets_dir)).to be_truthy
|
188
|
+
expect(File.exists?(public_dir)).to be_truthy
|
189
|
+
|
190
|
+
expect(Dir.exists?("#{target_dir_with_db}/app")).to be_truthy
|
191
|
+
expect(Dir.exists?("#{target_dir_with_db}/app/routes")).to be_truthy
|
192
|
+
expect(Dir.exists?("#{target_dir_with_db}/app/models")).to be_truthy
|
193
|
+
expect(Dir.exists?("#{target_dir_with_db}/app/views")).to be_truthy
|
194
|
+
expect(File.exists?("#{target_dir_with_db}/app/views/layout.erb")).to be_truthy
|
195
|
+
expect(File.exists?("#{target_dir_with_db}/app/views/home/index.erb")).to be_truthy
|
196
|
+
end
|
197
|
+
end
|
151
198
|
|
152
|
-
|
153
|
-
|
154
|
-
|
199
|
+
describe "app file" do
|
200
|
+
let(:secret) { "supersecretcookiefromgenerator" }
|
201
|
+
before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) }
|
155
202
|
|
156
|
-
|
157
|
-
|
158
|
-
end
|
159
|
-
end
|
203
|
+
it "has sequel database connector" do
|
204
|
+
generator_with_db.generate_app
|
160
205
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
165
|
-
end
|
166
|
-
DOC
|
206
|
+
app_file = "#{target_dir_with_db}/my_app.rb"
|
207
|
+
file_content = File.read(app_file)
|
208
|
+
expected_file_content = File.read(File.expand_path("../../fixtures/with_db/app.txt", __FILE__))
|
167
209
|
|
168
|
-
|
210
|
+
expect(file_content).to eq expected_file_content
|
211
|
+
end
|
169
212
|
end
|
170
213
|
end
|
171
214
|
end
|
172
215
|
|
173
|
-
describe "#
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
expect(File.exists?(without_db_sample_migration)).to be_falsey
|
184
|
-
generator.copy_templates
|
185
|
-
|
186
|
-
expect(File.exists?(config_dir)).to be_truthy
|
187
|
-
expect(File.exists?("#{config_dir}/database.yml.example")).to be_truthy
|
188
|
-
expect(File.exists?(without_db_rakefile)).to be_falsey
|
189
|
-
expect(File.exists?(without_db_sample_migration)).to be_falsey
|
190
|
-
end
|
216
|
+
describe "#generate_rakefile" do
|
217
|
+
it "generate basic Rakefile tasks" do
|
218
|
+
expected_rakefile_content =
|
219
|
+
expected_rakefile_content = File.read(File.expand_path("../../fixtures/without_db/rakefile.txt", __FILE__))
|
220
|
+
|
221
|
+
generator.generate_rakefile
|
222
|
+
rakefile = "#{target_dir}/Rakefile"
|
223
|
+
rakefile_content = File.read(rakefile)
|
224
|
+
|
225
|
+
expect(rakefile_content).to eq expected_rakefile_content
|
191
226
|
end
|
192
227
|
|
193
|
-
context "
|
194
|
-
|
195
|
-
|
228
|
+
context "with database" do
|
229
|
+
it "generates db related tasks" do
|
230
|
+
expected_rakefile_content = File.read(File.expand_path("../../fixtures/with_db/rakefile.txt", __FILE__))
|
196
231
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
generator_with_db.copy_templates
|
232
|
+
generator_with_db.generate_rakefile
|
233
|
+
rakefile = "#{target_dir_with_db}/Rakefile"
|
234
|
+
rakefile_content = File.read(rakefile)
|
201
235
|
|
202
|
-
expect(
|
203
|
-
expect(File.exists?(with_db_sample_migration)).to be_truthy
|
236
|
+
expect(rakefile_content).to eq expected_rakefile_content
|
204
237
|
end
|
205
238
|
end
|
206
239
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Melodiest::Application do
|
2
|
+
let(:my_app) do
|
3
|
+
class MyApp < Melodiest::Application
|
4
|
+
cookie_secret 'mysupersecretcookie'
|
5
|
+
end
|
6
|
+
|
7
|
+
MyApp
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
it "use encrypted cookie" do
|
12
|
+
expect(my_app.instance_variable_get("@middleware")).to include
|
13
|
+
[Rack::Session::EncryptedCookie, [{:secret => "mysupersecretcookie"}], nil]
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: melodiest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kunto Aji Kristianto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,45 @@ files:
|
|
114
114
|
- lib/melodiest/command.rb
|
115
115
|
- lib/melodiest/generator.rb
|
116
116
|
- lib/melodiest/setting.rb
|
117
|
-
- lib/melodiest/templates/
|
117
|
+
- lib/melodiest/templates/Gemfile.erb
|
118
|
+
- lib/melodiest/templates/Rakefile.erb
|
119
|
+
- lib/melodiest/templates/app.erb
|
120
|
+
- lib/melodiest/templates/app/routes/home.erb
|
121
|
+
- lib/melodiest/templates/app/views/home/index.erb
|
122
|
+
- lib/melodiest/templates/app/views/layout.erb
|
123
|
+
- lib/melodiest/templates/assets/javascripts/app.js
|
124
|
+
- lib/melodiest/templates/assets/javascripts/main.js
|
125
|
+
- lib/melodiest/templates/assets/javascripts/plugins.js
|
126
|
+
- lib/melodiest/templates/assets/stylesheets/app.css.scss
|
127
|
+
- lib/melodiest/templates/assets/stylesheets/main.css.scss
|
128
|
+
- lib/melodiest/templates/config.ru.erb
|
129
|
+
- lib/melodiest/templates/config/application.rb
|
130
|
+
- lib/melodiest/templates/config/boot.rb
|
118
131
|
- lib/melodiest/templates/config/database.yml.example
|
119
132
|
- lib/melodiest/templates/db/migrations/000_example.rb
|
133
|
+
- lib/melodiest/templates/public/.DS_Store
|
134
|
+
- lib/melodiest/templates/public/404.html
|
135
|
+
- lib/melodiest/templates/public/apple-touch-icon.png
|
136
|
+
- lib/melodiest/templates/public/browserconfig.xml
|
137
|
+
- lib/melodiest/templates/public/crossdomain.xml
|
138
|
+
- lib/melodiest/templates/public/favicon.ico
|
139
|
+
- lib/melodiest/templates/public/humans.txt
|
140
|
+
- lib/melodiest/templates/public/robots.txt
|
141
|
+
- lib/melodiest/templates/public/tile-wide.png
|
142
|
+
- lib/melodiest/templates/public/tile.png
|
120
143
|
- lib/melodiest/version.rb
|
121
144
|
- melodiest.gemspec
|
145
|
+
- spec/fixtures/app_routes_home.txt
|
146
|
+
- spec/fixtures/config_ru.txt
|
147
|
+
- spec/fixtures/with_db/app.txt
|
148
|
+
- spec/fixtures/with_db/gemfile.txt
|
149
|
+
- spec/fixtures/with_db/rakefile.txt
|
150
|
+
- spec/fixtures/without_db/app.txt
|
151
|
+
- spec/fixtures/without_db/gemfile.txt
|
152
|
+
- spec/fixtures/without_db/rakefile.txt
|
122
153
|
- spec/melodiest/command_spec.rb
|
123
154
|
- spec/melodiest/generator_spec.rb
|
124
|
-
- spec/
|
155
|
+
- spec/melodiest_spec.rb
|
125
156
|
- spec/spec_helper.rb
|
126
157
|
homepage: http://github.com/kuntoaji/melodiest
|
127
158
|
licenses:
|
@@ -1,25 +0,0 @@
|
|
1
|
-
describe Melodiest::Setting do
|
2
|
-
describe ".setup" do
|
3
|
-
let(:my_app) do
|
4
|
-
class MyApp < Melodiest::Application
|
5
|
-
setup 'mysupersecretcookie', server: 'puma'
|
6
|
-
end
|
7
|
-
|
8
|
-
MyApp
|
9
|
-
end
|
10
|
-
|
11
|
-
it "set thin as server" do
|
12
|
-
expect(app.settings.server).to eq("thin")
|
13
|
-
end
|
14
|
-
|
15
|
-
it "overrides default setting" do
|
16
|
-
expect(my_app.settings.server).to eq("puma")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "use encrypted cookie" do
|
20
|
-
expect(my_app.instance_variable_get("@middleware")).to include
|
21
|
-
[Rack::Session::EncryptedCookie, [{:secret => "mysupersecretcookie"}], nil]
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|