siphon 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51bfb661a1ed609248473ff45e69e817022fbc25
4
- data.tar.gz: c896428ba84008b95fe610bc65ccc1a27b37f608
3
+ metadata.gz: 34c845861e6abe5b2263f3b80f9d141018488cde
4
+ data.tar.gz: 39d6aa3786df2ae75e6be3225d1494ae156ce805
5
5
  SHA512:
6
- metadata.gz: 442f96c18a00c1b582b35b893275cb097f01093191091b2ea2605a27f599e9fad0459cac841326d0bf0b18f1f2d09927793251d7ba60488374d2fcf13265728e
7
- data.tar.gz: 2464e22a87bec7d26a58f32af5d605925f5927dad9df2e778ddaf07ebc8686f5fdc8a874eecc88602c8030a792202e635db0887ef0c315e1b6497319dd188002
6
+ metadata.gz: 4150765a974955d4324f8cab5858496343015e7fe8c4085d5af84b9000bc511d84195bb2f2c373e3a42f28976be02dfbbde09a304e47280e8c10df04a1f00040
7
+ data.tar.gz: b5052dc2ff65f240318b7120ce51157f3dab2d85bc395e071c9ea63e4f7bdb25b972e932dedabf8d79ceb1edf2f93d8a9fb8634ea72a17778d2a21975e2c54b6
@@ -4,4 +4,22 @@ class SiphonGenerator < Rails::Generators::NamedBase
4
4
  def create_search_file
5
5
  template "search.rb", File.join('app/siphon', class_path, "#{file_name}_search.rb")
6
6
  end
7
+
8
+ def create_controller
9
+ template "controller.rb", File.join('app/controllers', class_path, "#{file_name.pluralize}_controller.rb")
10
+ end
11
+
12
+ def create_view
13
+ template "view.rb", File.join('app/views', class_path, "#{file_name.pluralize}", "_search.html.haml")
14
+ end
15
+
16
+
17
+ def class_mate
18
+ classy = begin
19
+ Object.const_get(class_name) ||
20
+ Object.const_get( file_name.classify)
21
+ rescue
22
+ end
23
+ end
24
+
7
25
  end
@@ -0,0 +1,28 @@
1
+ class <%= class_name.pluralize %>Controller < ApplicationController
2
+ # include Paramount::Controller
3
+
4
+ def new
5
+ @<%= file_name %> ||= <%= class_mate %>.new
6
+ end
7
+
8
+ private
9
+ def collection
10
+ @<%= file_name.pluralize %> ||= get_search.result.page(params[:page])
11
+ end
12
+
13
+ def resource
14
+ @<%= file_name %> ||= <%= class_mate %>.find(params[:id])
15
+ end
16
+
17
+ def get_search
18
+ @<%= file_name %>_search ||= <%= class_mate %>Search.new(params[:<%= file_name %>_search])
19
+ end
20
+
21
+ def resource_params
22
+ params.require(:<%= file_name %>).permit!
23
+ end
24
+
25
+ def redirection(action:)
26
+ redirect_to [resource], notice: "Successfuly #{action} !"
27
+ end
28
+ end
@@ -2,7 +2,7 @@
2
2
  class <%= class_name %>Search
3
3
 
4
4
  include Siphon::Boilerplate
5
- siphonize class_name
5
+ siphonize <%= class_mate %>
6
6
 
7
7
  #
8
8
  # Scope attributes
@@ -0,0 +1,6 @@
1
+ = simple_form_for @<%= file_name %>_search, url: "/admin/<%= file_name.pluralize %>" do |f|
2
+ .col-md-3= f.input :name_cont
3
+ .col-md-2= f.input :order_by, collection: <%= class_mate %>Search.order_by
4
+ .col-md-2
5
+ %br
6
+ = f.button :submit, value: "search"
@@ -1,3 +1,3 @@
1
1
  module Siphon
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siphon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Sistovaris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -128,7 +128,9 @@ files:
128
128
  - Rakefile
129
129
  - TODO.md
130
130
  - lib/generators/siphon_generator.rb
131
+ - lib/generators/templates/controller.rb
131
132
  - lib/generators/templates/search.rb
133
+ - lib/generators/templates/view.rb
132
134
  - lib/siphon.rb
133
135
  - lib/siphon/adapter.rb
134
136
  - lib/siphon/base.rb