ki 0.0.1 → 0.0.2
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/VERSION +1 -1
- data/bin/ki +1 -1
- data/examples/base/Gemfile +2 -0
- data/examples/example/Gemfile +1 -1
- data/examples/example/app.rb +1 -5
- data/lib/cli.rb +37 -29
- data/lib/ki.rb +3 -5
- data/lib/util.rb +5 -6
- metadata +2 -2
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.2
         | 
    
        data/bin/ki
    CHANGED
    
    
    
        data/examples/base/Gemfile
    CHANGED
    
    
    
        data/examples/example/Gemfile
    CHANGED
    
    | @@ -1,2 +1,2 @@ | |
| 1 | 
            -
            gem 'ki'
         | 
| 1 | 
            +
            gem 'ki', :path => '../../'
         | 
| 2 2 | 
             
            gem 'shotgun'
         | 
    
        data/examples/example/app.rb
    CHANGED
    
    | @@ -2,7 +2,7 @@ require 'ki' | |
| 2 2 |  | 
| 3 3 | 
             
            class Phone < Ki::Model
         | 
| 4 4 | 
             
              forbid :delete
         | 
| 5 | 
            -
              requires : | 
| 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 | 
            -
             | 
| 5 | 
            -
               | 
| 4 | 
            +
            module Ki
         | 
| 5 | 
            +
              class AppGenerator < Thor::Group
         | 
| 6 | 
            +
                include Thor::Actions
         | 
| 6 7 |  | 
| 7 | 
            -
             | 
| 8 | 
            +
                argument :app_name
         | 
| 8 9 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 10 | 
            +
                def self.source_root
         | 
| 11 | 
            +
                  File.join(File.dirname(__FILE__), '..', 'examples', 'base')
         | 
| 12 | 
            +
                end
         | 
| 12 13 |  | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 14 | 
            +
                def dest_root
         | 
| 15 | 
            +
                  File.join(Dir.pwd, app_name)
         | 
| 16 | 
            +
                end
         | 
| 16 17 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 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 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 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 | 
            -
               | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 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 | 
            -
                     | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 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 |  | 
    
        data/lib/util.rb
    CHANGED
    
    | @@ -13,12 +13,11 @@ end | |
| 13 13 |  | 
| 14 14 | 
             
            module Ki
         | 
| 15 15 | 
             
              class Util
         | 
| 16 | 
            -
                 | 
| 17 | 
            -
             | 
| 18 | 
            -
                   | 
| 19 | 
            -
             | 
| 20 | 
            -
                   | 
| 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. | 
| 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:  | 
| 243 | 
            +
                  hash: 2106213773731717633
         | 
| 244 244 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 245 245 | 
             
              none: false
         | 
| 246 246 | 
             
              requirements:
         |