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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 989ddfd1e75b461a27418e6fbcb87a5aaa3f1d43
4
- data.tar.gz: d2f1d305b9e74f2b8b5672f91b71c33460ddcb67
3
+ metadata.gz: a16fd784ae388046bd56640aedc3d84799f0e6ff
4
+ data.tar.gz: 02a5c9fa3e6b2c2eb6d655aba33d70160643a19d
5
5
  SHA512:
6
- metadata.gz: 4db8444d523a7df72a5d3bffa12fa97bf24b7fd20b5f930b935174ae86eda222f19f22967a6de74e45a3b79314c4a53efe745c41aa8a2482672723357842836a
7
- data.tar.gz: 7a659f6815edb885f70fc34c14b102b1a913b2f31f8e44ec0671acc82c60281b3d2ee98428414754a5568a03d331c0608b5486ba33d6e14d8b3a4dd5651a8479
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)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flame
4
- VERSION = '4.0.16'.freeze
4
+ VERSION = '4.2.0'.freeze
5
5
  end
@@ -0,0 +1,11 @@
1
+ # configuration
2
+ config/*.yml
3
+ !config/*example.yml
4
+
5
+ # temp
6
+ log/
7
+ tmp/
8
+ *.bak
9
+
10
+ # dumps
11
+ *.sql
data/template/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ## Framework
4
+ gem 'flame'
5
+ # gem 'flame-flash'
6
+ # gem 'flame-r18n'
7
+
8
+ ## Server
9
+ gem 'thin'
10
+
11
+ ## DataBase
12
+ gem 'sequel'
13
+ # gem 'pg'
@@ -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
@@ -0,0 +1,5 @@
1
+ module <%= @module_name %>
2
+ ## Class for application (mounting controllers)
3
+ class Application
4
+ end
5
+ end
@@ -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,5 @@
1
+ :adapter: 'postgres'
2
+ :host: 'localhost'
3
+ :database: 'database'
4
+ :user: 'user'
5
+ :password: 'password'
@@ -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
@@ -0,0 +1,11 @@
1
+ module <%= @module_name %>
2
+ ## Base controller for any others controllers
3
+ class Controller < Flame::Controller
4
+ # include Flame::R18n
5
+
6
+ def execute(method)
7
+ # session[:locale] = params[:locale] || 'ru'
8
+ super
9
+ end
10
+ end
11
+ end
data/template/db/.keep ADDED
File without changes
File without changes
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.16
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-16 00:00:00.000000000 Z
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