simba 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ gem "sequel"
7
7
  gem "sinatra"
8
8
  gem "coffee-script"
9
9
  gem "sinatra-contrib"
10
+ gem "sinatra-flash"
10
11
  gem "sinatra-assetpack", :require => "sinatra/assetpack"
11
12
 
12
13
  group :development, :test do
@@ -22,3 +23,8 @@ group :test do
22
23
  gem "factory_girl"
23
24
  gem "database_cleaner"
24
25
  end
26
+
27
+ group :deploy do
28
+ gem "uglifier"
29
+ gem "capistrano"
30
+ end
@@ -1,6 +1,7 @@
1
- #load rake tasks
1
+ # load rake tasks
2
2
  Dir["./lib/tasks/**/*.rake"].sort.each { |ext| load ext }
3
- #load assetpacket tasks
3
+
4
+ # load assetpacket tasks
4
5
  APP_FILE = './config/boot.rb'
5
6
  APP_CLASS = 'Sinatra::Application'
6
7
  require 'sinatra/assetpack/rake'
@@ -1,3 +1,3 @@
1
1
  helpers do
2
2
  #dummy
3
- end
3
+ end
@@ -1,19 +1,25 @@
1
1
  require "rubygems"
2
2
  require "bundler"
3
- #require "bundle gems"
3
+ require "yaml"
4
+
5
+ # require "bundle gems"
4
6
  ENV["RACK_ENV"] ||= "development"
5
7
  Bundler.require(:default, ENV["RACK_ENV"].to_sym)
8
+
6
9
  # init database
7
- DB = Sequel.sqlite("./db/#{ENV["RACK_ENV"]}.db")
10
+ DB = Sequel.connect(YAML.load_file("./config/database.yml")["default"]["url"])
11
+
8
12
  # init sinatra
9
13
  set :sessions, true
10
14
  set :root, File.expand_path(".")
11
15
  set :views, settings.root + "/app/views"
16
+
12
17
  # sinatra reloader
13
18
  if development?
14
19
  require "sinatra/reloader"
15
20
  also_reload "lib/**/*.rb", "app/{models,helpers}/**/*.rb"
16
21
  end
22
+
17
23
  # assetpack support
18
24
  assets do
19
25
  serve "/js", :from => "app/assets/js"
@@ -26,7 +32,8 @@ assets do
26
32
  js :application, ["/js/*.js"]
27
33
  css :application, ["/css/*.css"]
28
34
  end
29
- # require sinatra files
35
+
36
+ # require project files
30
37
  Dir.glob "./{lib,app/models,app/helpers,app/controllers}/**/*.rb" do |f|
31
38
  require f
32
39
  end
@@ -0,0 +1,2 @@
1
+ default:
2
+ url: sqlite://db/development.db #postgres://user:password@host:port/database_name
@@ -1,12 +1,13 @@
1
+ require "yaml"
2
+
1
3
  namespace :db do
2
- require "sequel"
3
- Sequel.extension :migration
4
- DB = Sequel.sqlite('db/test.db')
4
+
5
+ database_url = YAML.load_file("./config/database.yml")["default"]["url"]
5
6
 
6
7
  desc "Perform migration reset (full erase and migration up)"
7
8
  task :setup do
8
- Sequel::Migrator.run(DB, "db/migrations", :target => 0)
9
- Sequel::Migrator.run(DB, "db/migrations")
9
+ puts `sequel -Etm ./db/migrations -M 0 #{database_url}`
10
+ puts `sequel -Etm ./db/migrations #{database_url}`
10
11
  puts "<= sq:migrate:reset executed"
11
12
  end
12
13
 
@@ -14,19 +15,19 @@ namespace :db do
14
15
  task :version do
15
16
  version = ENV['VERSION'].to_i
16
17
  raise "No VERSION was provided" if version.nil?
17
- Sequel::Migrator.run(DB, "db/migrations", :target => version)
18
+ puts `sequel -Etm db/migrations -M #{version} #{database_url}`
18
19
  puts "<= sq:migrate:to version=[#{version}] executed"
19
20
  end
20
21
 
21
22
  desc "Perform migration up to latest migration available"
22
23
  task :migrate do
23
- Sequel::Migrator.run(DB, "db/migrations")
24
+ puts `sequel -Etm ./db/migrations #{database_url}`
24
25
  puts "<= sq:migrate:up executed"
25
26
  end
26
27
 
27
28
  desc "Perform migration down (erase all data)"
28
29
  task :rollback do
29
- Sequel::Migrator.run(DB, "db/migrations", :target => 0)
30
+ puts `sequel -Etm ./db/migrations -M 0 #{database_url}`
30
31
  puts "<= sq:migrate:down executed"
31
32
  end
32
33
  end
@@ -6,3 +6,10 @@
6
6
  end
7
7
  end
8
8
  end
9
+
10
+ desc "run all tests"
11
+ task "test" do
12
+ Dir.glob "./test/**/*_test.rb" do |f|
13
+ require f
14
+ end
15
+ end
@@ -1,3 +1,6 @@
1
- Factory.define :user do |u|
2
- u.name "simba"
1
+ # https://github.com/thoughtbot/factory_girl/wiki/Usage
2
+ FactoryGirl.define do
3
+ factory :user do
4
+ name "simba"
5
+ end
3
6
  end
@@ -0,0 +1,4 @@
1
+ require_relative "../test_helper"
2
+
3
+ class UserControllerTest < FunctionalTestCase
4
+ end
@@ -1,18 +1,18 @@
1
1
  ENV['RACK_ENV'] ||= "test"
2
2
  require_relative "../config/boot.rb"
3
+
3
4
  # factory_girl
4
5
  dir = File.expand_path File.dirname(__FILE__)
5
6
  Dir.glob "#{dir}/factory/**/*_factory.rb" do |f|
6
7
  require f
7
8
  end
8
- # minitest
9
+
9
10
  require "minitest/autorun"
10
- # rack test
11
11
  require "rack/test"
12
- # database_clean
13
12
  DatabaseCleaner.strategy = :truncation
14
13
 
15
14
  class TestCase < MiniTest::Unit::TestCase
15
+ include FactoryGirl::Syntax::Methods
16
16
  def initialize *xs
17
17
  super
18
18
  DatabaseCleaner.clean
@@ -24,4 +24,4 @@ class FunctionalTestCase < TestCase
24
24
  def app
25
25
  Sinatra::Application
26
26
  end
27
- end
27
+ end
@@ -2,10 +2,10 @@ require_relative "../test_helper"
2
2
 
3
3
  class UserTest < TestCase
4
4
  def setup
5
- Factory(:user)
5
+ @user = build :user
6
6
  end
7
-
7
+
8
8
  def test_user_name
9
- #dummy
9
+ # dummy
10
10
  end
11
- end
11
+ end
data/lib/simba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Simba
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-22 00:00:00.000000000 Z
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70296540820220 !ruby/object:Gem::Requirement
16
+ requirement: &70255967802680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70296540820220
24
+ version_requirements: *70255967802680
25
25
  description: simba is a generator for sinatra applications.
26
26
  email:
27
27
  - saitowu@gmail.com
@@ -50,6 +50,7 @@ files:
50
50
  - lib/simba/base_app/app/views/layout.slim.tt
51
51
  - lib/simba/base_app/config.ru
52
52
  - lib/simba/base_app/config/boot.rb
53
+ - lib/simba/base_app/config/database.yml
53
54
  - lib/simba/base_app/db/migrations/1_create_users.rb
54
55
  - lib/simba/base_app/lib/tasks/db.rake
55
56
  - lib/simba/base_app/lib/tasks/stat.rake
@@ -85,3 +86,4 @@ signing_key:
85
86
  specification_version: 3
86
87
  summary: simba aim to set up ruby off rails best practice.
87
88
  test_files: []
89
+ has_rdoc: