kiss 1.7.2 → 1.7.4
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.
- data/LICENSE +1 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/kiss +49 -2
- data/data/scaffold.tgz +0 -0
- data/lib/kiss.rb +7 -2
- metadata +14 -2
data/LICENSE
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.4
|
data/bin/kiss
CHANGED
@@ -4,6 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'kiss'
|
5
5
|
require 'optparse'
|
6
6
|
require 'irb'
|
7
|
+
require 'highline'
|
7
8
|
|
8
9
|
def main
|
9
10
|
parse_options
|
@@ -13,7 +14,11 @@ def main
|
|
13
14
|
|
14
15
|
case command
|
15
16
|
when 'create'
|
16
|
-
|
17
|
+
if ARGV.shift == 'db'
|
18
|
+
create_db
|
19
|
+
else
|
20
|
+
create_app
|
21
|
+
end
|
17
22
|
when 'run'
|
18
23
|
run
|
19
24
|
when 'irb'
|
@@ -22,6 +27,14 @@ def main
|
|
22
27
|
set
|
23
28
|
when 'evolve'
|
24
29
|
evolve
|
30
|
+
when 'db'
|
31
|
+
db_command = ARGV.shift
|
32
|
+
case db_command
|
33
|
+
when 'create'
|
34
|
+
create_db
|
35
|
+
else
|
36
|
+
open_db_prompt
|
37
|
+
end
|
25
38
|
when 'help'
|
26
39
|
display_usage(ARGV[0])
|
27
40
|
else
|
@@ -74,7 +87,7 @@ rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
|
|
74
87
|
Kernel::exit 1
|
75
88
|
end
|
76
89
|
|
77
|
-
def
|
90
|
+
def create_app
|
78
91
|
archive_path = File.join(File.dirname(File.dirname(File.expand_path(__FILE__))),'data','scaffold.tgz')
|
79
92
|
|
80
93
|
Dir.mkdir($project_dir) unless File.directory?($project_dir)
|
@@ -85,6 +98,40 @@ def create
|
|
85
98
|
puts 'Kiss application scaffold created.'
|
86
99
|
end
|
87
100
|
|
101
|
+
def create_db
|
102
|
+
app = load_kiss_project
|
103
|
+
database_config = app.config.database
|
104
|
+
if database_config.adapter != 'mysql'
|
105
|
+
puts 'The Kiss command-line tool supports only MySQL databases.'
|
106
|
+
end
|
107
|
+
|
108
|
+
root_password = HighLine.new.ask("Enter MySQL root password: ") { |q| q.echo = false }
|
109
|
+
root_database_config = {
|
110
|
+
:adapter => 'mysql',
|
111
|
+
:host => database_config.host,
|
112
|
+
:database => 'mysql',
|
113
|
+
:user => 'root',
|
114
|
+
:password => root_password
|
115
|
+
}
|
116
|
+
|
117
|
+
root_db = app.new_database_connection(root_database_config)
|
118
|
+
root_db.execute("CREATE DATABASE IF NOT EXISTS `#{database_config.database}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci")
|
119
|
+
root_db.execute("GRANT ALL PRIVILEGES ON #{database_config.database}.* TO #{database_config.user}\@localhost IDENTIFIED BY '#{database_config.password}' WITH GRANT OPTION")
|
120
|
+
root_db.execute("FLUSH PRIVILEGES")
|
121
|
+
|
122
|
+
puts "Created MySQL database '#{database_config.database}' and user '#{database_config.user}'."
|
123
|
+
end
|
124
|
+
|
125
|
+
def open_db_prompt
|
126
|
+
app = load_kiss_project
|
127
|
+
database_config = app.config.database
|
128
|
+
if database_config.adapter != 'mysql'
|
129
|
+
puts 'The Kiss command-line tool supports only MySQL databases.'
|
130
|
+
end
|
131
|
+
|
132
|
+
Kernel.exec %Q(mysql -u #{database_config.user} #{"-p#{database_config.password}".inspect} #{database_config.database})
|
133
|
+
end
|
134
|
+
|
88
135
|
def load_kiss_project
|
89
136
|
Kiss.load
|
90
137
|
end
|
data/data/scaffold.tgz
CHANGED
Binary file
|
data/lib/kiss.rb
CHANGED
@@ -343,6 +343,12 @@ class Kiss
|
|
343
343
|
Kiss::Request.new(env, self, @_config).call(env)
|
344
344
|
end
|
345
345
|
|
346
|
+
def new_database_connection(database_config)
|
347
|
+
db = Sequel.connect database_config
|
348
|
+
load_db_class_extensions(db.class)
|
349
|
+
db
|
350
|
+
end
|
351
|
+
|
346
352
|
# Acquires and returns a database connection object from the connection pool,
|
347
353
|
# opening a new connection if the pool is empty.
|
348
354
|
def database
|
@@ -350,8 +356,7 @@ class Kiss
|
|
350
356
|
raise 'database config missing' unless @_database_config
|
351
357
|
|
352
358
|
# open database connection
|
353
|
-
db =
|
354
|
-
load_db_class_extensions(db.class)
|
359
|
+
db = new_database_connection(@_database_config)
|
355
360
|
|
356
361
|
# create model cache for this database connection
|
357
362
|
db.kiss_controller = self
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 1.7.
|
8
|
+
- 4
|
9
|
+
version: 1.7.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Shawn Van Ittersum
|
@@ -69,6 +69,18 @@ dependencies:
|
|
69
69
|
version: "0"
|
70
70
|
type: :runtime
|
71
71
|
version_requirements: *id004
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: highline
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: *id005
|
72
84
|
description:
|
73
85
|
email: shawn @nospam@ multiwidget.com
|
74
86
|
executables:
|