flame 4.0.16 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/flame +70 -0
- data/lib/flame/application.rb +22 -0
- data/lib/flame/version.rb +1 -1
- data/template/.gitignore +11 -0
- data/template/Gemfile +13 -0
- data/template/Rakefile.erb +62 -0
- data/template/app.rb.erb +5 -0
- data/template/config.ru.erb +18 -0
- data/template/config/config.rb.erb +14 -0
- data/template/config/database.example.yml +5 -0
- data/template/config/sequel.rb.erb +13 -0
- data/template/config/thin.example.yml +18 -0
- data/template/controllers/_base_controller.rb.erb +11 -0
- data/template/db/.keep +0 -0
- data/template/helpers/.keep +0 -0
- data/template/lib/.keep +0 -0
- data/template/locales/en.yml +0 -0
- data/template/models/.keep +0 -0
- data/template/public/.keep +0 -0
- data/template/server +48 -0
- data/template/views/.keep +0 -0
- metadata +37 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a16fd784ae388046bd56640aedc3d84799f0e6ff
|
4
|
+
data.tar.gz: 02a5c9fa3e6b2c2eb6d655aba33d70160643a19d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ff76b22007c5e11890da7acbcd32e2e6489f3ad0702018362e3756e01cbb2e78d2e11a287ab534c00e1bf61b6886aee54534611febbde50d5458561f59f7340
|
7
|
+
data.tar.gz: 8d6c2133c19e5c4b1d24bee411059294727d2f32cd4806583cf620cc56462326467a1fed7a4cf25fc353735f54c759db7824c5a4bf0fc7d91708453fc517dfeb
|
data/bin/flame
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'gorilla-patch/string'
|
6
|
+
require 'erb'
|
7
|
+
|
8
|
+
## CLI Application
|
9
|
+
class FlameCLI < Thor
|
10
|
+
desc 'new APP', 'Generate new application directory with sub-directories'
|
11
|
+
def new(app_name)
|
12
|
+
FlameApp.new app_name
|
13
|
+
end
|
14
|
+
|
15
|
+
## Class for Flame Application
|
16
|
+
class FlameApp
|
17
|
+
def initialize(app_name)
|
18
|
+
@app_name = app_name
|
19
|
+
New.build @app_name
|
20
|
+
puts 'Done!'
|
21
|
+
puts "\nMoving to '#{@app_name}' directory by:\n\ncd #{@app_name}\n\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
## Module for new application
|
25
|
+
module New
|
26
|
+
module_function
|
27
|
+
|
28
|
+
using GorillaPatch::StringExt
|
29
|
+
|
30
|
+
def build(app_name)
|
31
|
+
@app_name = app_name
|
32
|
+
@module_name = @app_name.camelize
|
33
|
+
make_dir do
|
34
|
+
copy_template
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def make_dir(&block)
|
39
|
+
puts "Creating '#{@app_name}' directory..."
|
40
|
+
FileUtils.mkdir @app_name
|
41
|
+
FileUtils.cd @app_name, &block
|
42
|
+
end
|
43
|
+
|
44
|
+
def copy_template
|
45
|
+
puts 'Copy template directories and files...'
|
46
|
+
FileUtils.cp_r File.join(__dir__, '..', 'template', '.'), '.'
|
47
|
+
clean_dirs
|
48
|
+
render_templates
|
49
|
+
end
|
50
|
+
|
51
|
+
def clean_dirs
|
52
|
+
puts 'Clean directories...'
|
53
|
+
FileUtils.rm Dir[File.join('**', '*', '.keep')]
|
54
|
+
end
|
55
|
+
|
56
|
+
def render_templates
|
57
|
+
puts 'Replace module names in template...'
|
58
|
+
Dir[File.join('**', '*.erb')].each do |file|
|
59
|
+
basename = File.basename(file, '.*')
|
60
|
+
puts "- #{basename}"
|
61
|
+
content = ERB.new(File.read(file)).result(binding)
|
62
|
+
File.write(File.join(File.dirname(file), basename), content)
|
63
|
+
FileUtils.rm file
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
FlameCLI.start(ARGV)
|
data/lib/flame/application.rb
CHANGED
@@ -92,6 +92,28 @@ module Flame
|
|
92
92
|
end
|
93
93
|
result
|
94
94
|
end
|
95
|
+
|
96
|
+
## Method for loading YAML-files from config directory
|
97
|
+
## @param file [String, Symbol] file name (typecast to String with '.yml')
|
98
|
+
## @param key [Symbol, String, nil]
|
99
|
+
## key for allocating YAML in config Hash (typecast to Symbol)
|
100
|
+
## @param set [Boolean] allocating YAML in Config Hash
|
101
|
+
## @example Load SMTP file from `config/smtp.yml' to config[]
|
102
|
+
## config.load_yaml('smtp.yml')
|
103
|
+
## @example Load SMTP file without extension, by Symbol
|
104
|
+
## config.load_yaml(:smtp)
|
105
|
+
## @example Load SMTP file with other key to config[:mail]
|
106
|
+
## config.load_yaml('smtp.yml', :mail)
|
107
|
+
## @example Load SMTP file without allocating in config[]
|
108
|
+
## config.load_yaml('smtp.yml', set: false)
|
109
|
+
def load_yaml(file, key: nil, set: true)
|
110
|
+
file = "#{file}.yml" if file.is_a? Symbol
|
111
|
+
file_path = File.join(self[:config_dir], file)
|
112
|
+
yaml = YAML.load_file(file_path)
|
113
|
+
key ||= File.basename(file, '.*')
|
114
|
+
self[key.to_sym] = yaml if set
|
115
|
+
yaml
|
116
|
+
end
|
95
117
|
end
|
96
118
|
end
|
97
119
|
end
|
data/lib/flame/version.rb
CHANGED
data/template/.gitignore
ADDED
data/template/Gemfile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
namespace :db do
|
2
|
+
## Require libs and config
|
3
|
+
require 'sequel'
|
4
|
+
require File.join(__dir__, 'config', 'sequel.rb')
|
5
|
+
## Default path to db-files
|
6
|
+
db_dir = File.join(__dir__, 'db')
|
7
|
+
|
8
|
+
desc 'Run migrations'
|
9
|
+
task :migrate, [:version] do |_t, args|
|
10
|
+
Sequel.extension :migration
|
11
|
+
migrations_dir = File.join(db_dir, 'migrations')
|
12
|
+
|
13
|
+
if args[:version]
|
14
|
+
puts "Migrating to version #{args[:version]}"
|
15
|
+
Sequel::Migrator.run(
|
16
|
+
<%= @module_name %>::DB,
|
17
|
+
migrations_dir,
|
18
|
+
target: args[:version].to_i
|
19
|
+
)
|
20
|
+
else
|
21
|
+
puts 'Migrating to latest'
|
22
|
+
Sequel::Migrator.run(<%= @module_name %>::DB, migrations_dir)
|
23
|
+
end
|
24
|
+
|
25
|
+
Rake::Task['db:schema:dump'].invoke('same_db=true')
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Run seeds'
|
29
|
+
task :seed do |_t|
|
30
|
+
require 'sequel/extensions/seed'
|
31
|
+
seeds_dir = File.join(db_dir, 'seeds')
|
32
|
+
|
33
|
+
## Doesn't support version yet
|
34
|
+
puts 'Seeding latest'
|
35
|
+
Sequel::Seeder.apply(<%= @module_name %>::DB, seeds_dir)
|
36
|
+
end
|
37
|
+
|
38
|
+
namespace :schema do
|
39
|
+
schema_filename = '001_schema.rb'
|
40
|
+
|
41
|
+
desc 'Run schema dump'
|
42
|
+
task :dump do |_t|
|
43
|
+
<%= @module_name %>::DB.extension :schema_dumper
|
44
|
+
puts 'Dump latest schema'
|
45
|
+
dump = <%= @module_name %>::DB.dump_schema_migration(
|
46
|
+
same_db: env_true?('same_db')
|
47
|
+
)
|
48
|
+
File.write(File.join(db_dir, schema_filename), dump)
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Run schema load'
|
52
|
+
task :load do |_t|
|
53
|
+
Sequel.extension :migration
|
54
|
+
puts 'Load latest schema'
|
55
|
+
Sequel::Migrator.run(<%= @module_name %>::DB, db_dir, target: 1)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def env_true?(key)
|
61
|
+
%(true yes 1 y).include?(ENV[key].to_s.downcase)
|
62
|
+
end
|
data/template/app.rb.erb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Require gems
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
## Require project
|
6
|
+
Dir[File.join(
|
7
|
+
__dir__, '{config,models,helpers,controllers}', '{,**}', '{_,}*.rb'
|
8
|
+
)].each { |file| require file }
|
9
|
+
|
10
|
+
## Require application
|
11
|
+
require_relative './app'
|
12
|
+
|
13
|
+
## Use middlewares
|
14
|
+
use Rack::Session::Cookie, key: 'rack.session', secret: 'dummy_secret'
|
15
|
+
use Rack::CommonLogger
|
16
|
+
|
17
|
+
## Run application
|
18
|
+
run <%= @module_name %>::Application
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module <%= @module_name %>
|
4
|
+
## Constants
|
5
|
+
SITE_NAME = '<%= @module_name %>'.freeze
|
6
|
+
|
7
|
+
## Configuration for application
|
8
|
+
module Config
|
9
|
+
def self.included(app)
|
10
|
+
## Translations
|
11
|
+
# Flame::R18n.config(app)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
## Database initialize for Sequel
|
4
|
+
module <%= @module_name %>
|
5
|
+
# Sequel::Model.plugin :timestamps
|
6
|
+
# Sequel::Model.raise_on_save_failure = false
|
7
|
+
|
8
|
+
DB = Sequel.connect(
|
9
|
+
YAML.load_file(File.join(__dir__, 'database.yml'))
|
10
|
+
)
|
11
|
+
|
12
|
+
# DB.extension :pg_enum
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
# user: www-data
|
3
|
+
# group: www-data
|
4
|
+
pid: tmp/pids/thin.pid
|
5
|
+
timeout: 30
|
6
|
+
wait: 30
|
7
|
+
log: log/thin.log
|
8
|
+
max_conns: 1024
|
9
|
+
require: []
|
10
|
+
environment: development # production
|
11
|
+
max_persistent_conns: 512
|
12
|
+
servers: 1
|
13
|
+
threaded: true
|
14
|
+
no-epoll: true
|
15
|
+
daemonize: true
|
16
|
+
socket: tmp/sockets/thin.sock
|
17
|
+
chdir: /path/to/the/project
|
18
|
+
# tag: a-name-to-show-up-in-ps aux
|
data/template/db/.keep
ADDED
File without changes
|
File without changes
|
data/template/lib/.keep
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/template/server
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
## Functons
|
4
|
+
def show_usage
|
5
|
+
puts 'Usage: ./server COMMAND'
|
6
|
+
puts 'COMMAND is one of:'
|
7
|
+
puts ' start - Start server'
|
8
|
+
puts ' stop - Stop server'
|
9
|
+
puts ' restart - Stop/Start server'
|
10
|
+
puts ' monitor - Show log'
|
11
|
+
puts ' devel - Restart/Monitor server'
|
12
|
+
end
|
13
|
+
|
14
|
+
def start_server
|
15
|
+
system 'rm log/*'
|
16
|
+
system 'thin -C config/thin.yml start'
|
17
|
+
end
|
18
|
+
|
19
|
+
def stop_server
|
20
|
+
system 'thin -C config/thin.yml stop'
|
21
|
+
end
|
22
|
+
|
23
|
+
def restart_server
|
24
|
+
stop_server
|
25
|
+
start_server
|
26
|
+
end
|
27
|
+
|
28
|
+
def monitor_server
|
29
|
+
system 'tail -f log/thin.*.log'
|
30
|
+
end
|
31
|
+
|
32
|
+
## Runtime
|
33
|
+
case ARGV[0]
|
34
|
+
when 'start'
|
35
|
+
start_server
|
36
|
+
when 'stop'
|
37
|
+
stop_server
|
38
|
+
when 'restart'
|
39
|
+
restart_server
|
40
|
+
when 'monitor'
|
41
|
+
monitor_server
|
42
|
+
when 'devel'
|
43
|
+
restart_server
|
44
|
+
monitor_server
|
45
|
+
else
|
46
|
+
puts "Unknown command #{ARGV[0]}"
|
47
|
+
show_usage
|
48
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -64,14 +64,30 @@ dependencies:
|
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 0.0.8.1
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: thor
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
67
81
|
description: Use controller's classes with instance methods as routing actions, mounting
|
68
82
|
its in application class.
|
69
83
|
email:
|
70
84
|
- alex.wayfer@gmail.com
|
71
|
-
executables:
|
85
|
+
executables:
|
86
|
+
- flame
|
72
87
|
extensions: []
|
73
88
|
extra_rdoc_files: []
|
74
89
|
files:
|
90
|
+
- bin/flame
|
75
91
|
- lib/flame.rb
|
76
92
|
- lib/flame/application.rb
|
77
93
|
- lib/flame/controller.rb
|
@@ -87,6 +103,24 @@ files:
|
|
87
103
|
- lib/flame/validators.rb
|
88
104
|
- lib/flame/version.rb
|
89
105
|
- public/favicon.ico
|
106
|
+
- template/.gitignore
|
107
|
+
- template/Gemfile
|
108
|
+
- template/Rakefile.erb
|
109
|
+
- template/app.rb.erb
|
110
|
+
- template/config.ru.erb
|
111
|
+
- template/config/config.rb.erb
|
112
|
+
- template/config/database.example.yml
|
113
|
+
- template/config/sequel.rb.erb
|
114
|
+
- template/config/thin.example.yml
|
115
|
+
- template/controllers/_base_controller.rb.erb
|
116
|
+
- template/db/.keep
|
117
|
+
- template/helpers/.keep
|
118
|
+
- template/lib/.keep
|
119
|
+
- template/locales/en.yml
|
120
|
+
- template/models/.keep
|
121
|
+
- template/public/.keep
|
122
|
+
- template/server
|
123
|
+
- template/views/.keep
|
90
124
|
homepage: https://github.com/AlexWayfer/flame
|
91
125
|
licenses:
|
92
126
|
- MIT
|