dandy 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dandy/generators/cli.rb +16 -2
- data/lib/dandy/generators/templates/Gemfile +1 -0
- data/lib/dandy/generators/templates/Gemfile_jet_set +11 -0
- data/lib/dandy/generators/templates/actions/common/open_db_session.rb +24 -0
- data/lib/dandy/generators/templates/app/app_jet_set.rb +13 -0
- data/lib/dandy/generators/templates/dandy.yml +9 -0
- data/lib/dandy/generators/templates/db/mapping.rb +25 -0
- data/lib/dandy/loaders/dependency_loader.rb +1 -1
- data/lib/dandy/loaders/type_loader.rb +6 -3
- data/lib/dandy/routing/file_reader.rb +8 -3
- data/lib/dandy/routing/syntax_grammar.tt +1 -1
- data/lib/dandy/version.rb +1 -1
- metadata +7 -3
- data/lib/dandy/generators/templates/silicon.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 874927c6a6c9fe878b77341cb699df8e1826a4c4
|
4
|
+
data.tar.gz: c29ffb2cf1211bb9a5eedb21c93c2117171e15af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1feb5fbc692297aba11bde80a584aeb7679d2cfab5d1144dba410e6f8178d38fd30ce0b088a897f7a08048cd35a1763c707d32ea91277d6a2ec102a34e854d6f
|
7
|
+
data.tar.gz: 5eb3ba4c287233663f58be493a4f9ed5fcaadc5f1ebdeddc1a80de2f46e4f3f4c60a7f838e5b47fa0af07607bd302fb503024ac94628ea8179ed6b7ae0558300
|
data/lib/dandy/generators/cli.rb
CHANGED
@@ -10,16 +10,30 @@ module Dandy
|
|
10
10
|
end
|
11
11
|
|
12
12
|
desc 'new NAME', 'Create new Dandy application'
|
13
|
+
method_options :jet_set => :boolean
|
13
14
|
def new(name)
|
14
|
-
|
15
|
+
|
16
|
+
if options[:jet_set]
|
17
|
+
copy_file 'templates/app/app_jet_set.rb', "#{name}/app/app.rb"
|
18
|
+
copy_file 'templates/Gemfile_jet_set', "#{name}/Gemfile"
|
19
|
+
copy_file 'templates/db/mapping.rb', "#{name}/db/mapping.rb"
|
20
|
+
copy_file 'templates/actions/common/open_db_session.rb', "#{name}/app/actions/common/open_db_session.rb"
|
21
|
+
else
|
22
|
+
copy_file 'templates/app/app.rb', "#{name}/app/app.rb"
|
23
|
+
copy_file 'templates/Gemfile', "#{name}/Gemfile"
|
24
|
+
end
|
25
|
+
|
15
26
|
copy_file 'templates/app/app.routes', "#{name}/app/app.routes"
|
16
27
|
copy_file 'templates/dandy.yml', "#{name}/dandy.yml"
|
17
28
|
copy_file 'templates/config.ru', "#{name}/config.ru"
|
18
29
|
copy_file 'templates/views/show_welcome.json.jbuilder', "#{name}/app/views/show_welcome.json.jbuilder"
|
19
30
|
copy_file 'templates/actions/common/handle_errors.rb', "#{name}/app/actions/common/handle_errors.rb"
|
20
|
-
copy_file 'templates/Gemfile', "#{name}/Gemfile"
|
21
31
|
template 'templates/actions/welcome.tt', "#{name}/app/actions/welcome.rb", {app_name: name}
|
22
32
|
|
33
|
+
if options[:jet_set]
|
34
|
+
insert_into_file "#{name}/app/app.routes", " :before -> common/open_db_session\n", :after => ".->\n"
|
35
|
+
end
|
36
|
+
|
23
37
|
inside name do
|
24
38
|
run 'bundle'
|
25
39
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
require 'jet_set'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
class OpenDbSession
|
6
|
+
def initialize(container, dandy_config, dandy_env)
|
7
|
+
@container = container
|
8
|
+
@config = dandy_config
|
9
|
+
@dandy_env = dandy_env
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
# Instead of :url you can specify required Sequel connection parameters in dandy.yml.
|
14
|
+
# Additional details about Sequel connection configuration
|
15
|
+
# see at http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html
|
16
|
+
connection = Sequel.connect(@config[:db][:url])
|
17
|
+
|
18
|
+
if @dandy_env == 'development'
|
19
|
+
connection.loggers << Logger.new($stdout)
|
20
|
+
end
|
21
|
+
|
22
|
+
JetSet::open_session(connection, :dandy_request)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Don't forget add dependencies
|
2
|
+
# require './domain/user'
|
3
|
+
# require './domain/invoice'
|
4
|
+
|
5
|
+
module Mapping
|
6
|
+
def load_mapping
|
7
|
+
JetSet::map do
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# entity User do
|
11
|
+
# field :first_name
|
12
|
+
# field :last_name
|
13
|
+
# field :company
|
14
|
+
# collection :invoices, type: Invoice
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# entity Invoice do
|
18
|
+
# field :amount
|
19
|
+
# field :date
|
20
|
+
# field :created_at
|
21
|
+
# reference :user, type: User
|
22
|
+
# end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -8,14 +8,17 @@ module Dandy
|
|
8
8
|
types = []
|
9
9
|
@directories.each do |directory|
|
10
10
|
dir = File.join(directory, '**/*')
|
11
|
-
files = Dir.glob(dir).reject {|file_path| File.directory?
|
11
|
+
files = Dir.glob(dir).reject {|file_path| File.directory?(file_path)}
|
12
12
|
|
13
13
|
files.each do |file|
|
14
|
-
path = File.join
|
14
|
+
path = File.join(Dir.pwd, file)
|
15
15
|
require path
|
16
16
|
file_name = File.basename(file).gsub(File.extname(file), '')
|
17
17
|
class_name = file_name.split('_').each(&:capitalize!).join('')
|
18
|
-
types <<
|
18
|
+
types << {
|
19
|
+
class: Object.const_get(class_name),
|
20
|
+
path: file.gsub(File.extname(file), '').gsub(directory + '/', '')
|
21
|
+
}
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -7,10 +7,15 @@ module Dandy
|
|
7
7
|
|
8
8
|
def read
|
9
9
|
path = File.join('./', @config[:path][:routes])
|
10
|
-
|
10
|
+
raw_content = File.read(path)
|
11
|
+
|
12
|
+
raw_content.gsub!(/\\\s*\n+\s*->/, '->')
|
13
|
+
raw_content.gsub!(/\\\s*\n+\s*=>/, '=>')
|
14
|
+
raw_content.gsub!(/\\\s*\n+\s*=\*/, '=>')
|
15
|
+
|
11
16
|
|
12
17
|
# use '^' instead spaces and tabs
|
13
|
-
raw_content =
|
18
|
+
raw_content = raw_content.gsub(/\t/, ' ')
|
14
19
|
.gsub(' ', '^')
|
15
20
|
.gsub(' ', '')
|
16
21
|
|
@@ -20,7 +25,7 @@ module Dandy
|
|
20
25
|
###
|
21
26
|
raw_content = raw_content.gsub('->', '*>').gsub('<-', '<*')
|
22
27
|
|
23
|
-
raw_content.gsub
|
28
|
+
raw_content.gsub("\n", ';') + ';'
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
data/lib/dandy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dandy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kalinkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hypo
|
@@ -210,12 +210,16 @@ files:
|
|
210
210
|
- lib/dandy/extensions/hash.rb
|
211
211
|
- lib/dandy/generators/cli.rb
|
212
212
|
- lib/dandy/generators/templates/Gemfile
|
213
|
+
- lib/dandy/generators/templates/Gemfile_jet_set
|
213
214
|
- lib/dandy/generators/templates/actions/common/handle_errors.rb
|
215
|
+
- lib/dandy/generators/templates/actions/common/open_db_session.rb
|
214
216
|
- lib/dandy/generators/templates/actions/welcome.tt
|
215
217
|
- lib/dandy/generators/templates/app/app.rb
|
216
218
|
- lib/dandy/generators/templates/app/app.routes
|
219
|
+
- lib/dandy/generators/templates/app/app_jet_set.rb
|
217
220
|
- lib/dandy/generators/templates/config.ru
|
218
|
-
- lib/dandy/generators/templates/
|
221
|
+
- lib/dandy/generators/templates/dandy.yml
|
222
|
+
- lib/dandy/generators/templates/db/mapping.rb
|
219
223
|
- lib/dandy/generators/templates/views/show_welcome.json.jbuilder
|
220
224
|
- lib/dandy/loaders/dependency_loader.rb
|
221
225
|
- lib/dandy/loaders/template_loader.rb
|