stirling 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66bcbcd9beab8b9ac4986c198c9936b4217080b2
4
- data.tar.gz: c965ebe5eeac323fd746dcff4daa7ff0a6b03102
3
+ metadata.gz: 2cb7a741aaccb47580fcd902e537f3b808e5b03e
4
+ data.tar.gz: 4a1f95316ddde35ab1b27edbffb8788d6ccc6814
5
5
  SHA512:
6
- metadata.gz: 72c77ba02fdc0bd6379dc29665dbdb8279dad2f9f0948bbddeee0e0fe791030674246db6e114c46df38da569f1d8a7faa3ff7ae73251977493ac36f654a0093e
7
- data.tar.gz: f56042044d589ce8724d524b3be69dcb35eb114d2ee868f7ae45a643c6ac7640d953a276762a00d364bb320fad71d89072193a8490dd57d9890b75a5b0194927
6
+ metadata.gz: 5446fc9ab9363769b22a3d0b03471a3e70b6eeca7b3465620b72f5cb7f3324bd5877f28fb010364e90d0a9335e858c5ec3deceae662ef145fee24f8d5a780c46
7
+ data.tar.gz: acd039663a36a36fe636884e9b5e96742ff6b474d8122811b74ad92560c7743f318f1d65f70d572662d0b5e80024b87469b3dc5070171d4e68bb0f4fa6c67e26
@@ -1,6 +1,7 @@
1
1
  class Stirling::BaseController < ApplicationController
2
2
  before_filter :build_instance, only: [:new, :create]
3
3
  before_filter :set_instance, only: [:show, :destroy, :edit, :update]
4
+ before_filter :set_instances, only: [:index]
4
5
  before_filter :assign_params, only: [:update]
5
6
 
6
7
  def index; end
@@ -12,12 +13,27 @@ class Stirling::BaseController < ApplicationController
12
13
  def destroy; end
13
14
 
14
15
  private
16
+ def set_instances
17
+ instances = if Stirling::Gem.load? "ransack"
18
+ @q = model.search params[:q]
19
+ @q.result
20
+ else
21
+ model.all
22
+ end
23
+
24
+ if Stirling::Gem.load? "kaminari" || Stirling::Gem.load? "will_paginate"
25
+ instances = instances.page params[:page]
26
+ end
27
+
28
+ instance_variable_set "@#{model_name.pluralize}", instances
29
+ end
30
+
15
31
  def set_instance
16
- instance = model.find params[:id]
32
+ self.instance = model.find params[:id]
17
33
  end
18
34
 
19
35
  def build_instance
20
- instance = model.new model_params
36
+ self.instance = model.new model_params
21
37
  end
22
38
 
23
39
  def instance
@@ -0,0 +1,11 @@
1
+ module Stirling
2
+ class Gem
3
+ @@loading_gem = Bundler.load.specs.map {|spec| spec.name}
4
+
5
+ class << self
6
+ def load? gem
7
+ @@loading_gem.include? gem
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,7 +3,7 @@ require_dependency "<%= namespaced_path %>/application_controller"
3
3
 
4
4
  <% end -%>
5
5
  <% module_namespacing do -%>
6
- class <%= class_name %>Controller < Stirling::BaseControlle
6
+ class <%= class_name %>Controller < Stirling::BaseController
7
7
  <% actions.each do |action| -%>
8
8
  def <%= action %>
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Stirling
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/stirling.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "stirling/engine"
2
+ require "stirling/gem"
2
3
 
3
4
  module Stirling
4
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stirling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Framgia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: eager_decorator
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Rails extension tool
14
28
  email:
15
29
  - oss@framgia.com
@@ -24,6 +38,7 @@ files:
24
38
  - config/routes.rb
25
39
  - lib/stirling.rb
26
40
  - lib/stirling/engine.rb
41
+ - lib/stirling/gem.rb
27
42
  - lib/stirling/templates/active_record/model/model.rb
28
43
  - lib/stirling/templates/rails/controller/controller.rb
29
44
  - lib/stirling/templates/rails/scaffold_controller/controller.rb