ki 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/ki CHANGED
@@ -3,4 +3,4 @@
3
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli'
5
5
 
6
- Cli.start
6
+ Ki::Cli.start
@@ -1,3 +1,5 @@
1
+ source :rubygems
2
+
1
3
  gem 'ki'
2
4
 
3
5
  group :development do
@@ -1,2 +1,2 @@
1
- gem 'ki'
1
+ gem 'ki', :path => '../../'
2
2
  gem 'shotgun'
@@ -2,7 +2,7 @@ require 'ki'
2
2
 
3
3
  class Phone < Ki::Model
4
4
  forbid :delete
5
- requires :foo, :bar
5
+ requires :number, :user_id
6
6
  end
7
7
 
8
8
  class User < Ki::Model
@@ -13,7 +13,3 @@ class User < Ki::Model
13
13
  @req.params[:password] = 'hashed password'
14
14
  end
15
15
  end
16
-
17
- class Post < Ki::Model
18
- requires :text
19
- end
data/lib/cli.rb CHANGED
@@ -1,43 +1,51 @@
1
1
  require 'thor'
2
2
  require 'thor/group'
3
3
 
4
- class AppGenerator < Thor::Group
5
- include Thor::Actions
4
+ module Ki
5
+ class AppGenerator < Thor::Group
6
+ include Thor::Actions
6
7
 
7
- argument :app_name
8
+ argument :app_name
8
9
 
9
- def self.source_root
10
- File.join(File.dirname(__FILE__), '..', 'examples', 'base')
11
- end
10
+ def self.source_root
11
+ File.join(File.dirname(__FILE__), '..', 'examples', 'base')
12
+ end
12
13
 
13
- def dest_root
14
- File.join(Dir.pwd, app_name)
15
- end
14
+ def dest_root
15
+ File.join(Dir.pwd, app_name)
16
+ end
16
17
 
17
- def prepare_dir
18
- if Dir.exists? dest_root
19
- unless yes? "#{app_name} already exists. Do you want to overwrite it?"
20
- say 'aborted'
21
- exit 1
18
+ def prepare_dir
19
+ if Dir.exists? dest_root
20
+ unless yes? "#{app_name} already exists. Do you want to overwrite it?"
21
+ say 'aborted'
22
+ exit 1
23
+ end
24
+ else
25
+ Dir.mkdir dest_root
22
26
  end
23
- else
24
- Dir.mkdir dest_root
25
27
  end
26
- end
27
28
 
28
- def create_app
29
- copy_file "Gemfile", "#{app_name}/Gemfile"
30
- copy_file "config.ru", "#{app_name}/config.ru"
31
- copy_file "config.yml", "#{app_name}/config.yml"
32
- copy_file "app.rb", "#{app_name}/app.rb"
29
+ def create_app
30
+ copy_file "Gemfile", "#{app_name}/Gemfile"
31
+ copy_file "config.ru", "#{app_name}/config.ru"
32
+ copy_file "config.yml", "#{app_name}/config.yml"
33
+ copy_file "app.rb", "#{app_name}/app.rb"
34
+ end
33
35
  end
34
- end
35
-
36
- class Cli < Thor
37
- register AppGenerator, :new, 'new', 'generate a new app'
38
36
 
39
- desc 'hello [NAME]', 'says hello'
40
- def hello(name)
41
- say "Hello #{name}"
37
+ class Cli < Thor
38
+ register AppGenerator, :new, 'new [APP_NAME]', 'generate a new app'
39
+
40
+ desc 'server', 'starts the app'
41
+ method_option :reload, :type => :boolean, :aliases => "-r", :desc => 'Recommended for development'
42
+ def server
43
+ if options[:reload]
44
+ say 'Starting with Shotgun', :green
45
+ system 'bundle exec shotgun'
46
+ else
47
+ system 'thin start'
48
+ end
49
+ end
42
50
  end
43
51
  end
data/lib/ki.rb CHANGED
@@ -16,11 +16,9 @@ module Ki
16
16
  class Ki
17
17
  def self.new
18
18
  Rack::Builder.new do
19
- static_path = File.join(Ki.root, 'lib/public/*')
20
- static_files = Dir.glob(static_path).collect{|c| File.basename(c)}
21
- static_files.each do |sf|
22
- map "/public/#{sf}" do
23
- run Rack::File.new(Util::public_dir(sf))
19
+ Util.static_files.each do |sf|
20
+ map "/public/#{File.basename(sf)}" do
21
+ run Rack::File.new(sf)
24
22
  end
25
23
  end
26
24
 
@@ -13,12 +13,11 @@ end
13
13
 
14
14
  module Ki
15
15
  class Util
16
- def self.public_dir name
17
- custom = File.join(Dir.pwd, 'public', name)
18
- unless File.exists? custom
19
- custom = File.join(Ki.root, 'lib', 'public', name)
20
- end
21
- custom
16
+ # the order in which files are loaded is important
17
+ def self.static_files
18
+ static_files = Dir.glob(File.join(Ki.root, 'lib/public/*'))
19
+ static_files << Dir.glob(File.join(Dir.pwd, 'public/*'))
20
+ static_files.flatten!
22
21
  end
23
22
 
24
23
  def self.partial s, hash={}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -240,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
240
  version: '0'
241
241
  segments:
242
242
  - 0
243
- hash: -4484784493879915658
243
+ hash: 2106213773731717633
244
244
  required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  none: false
246
246
  requirements: