simple_cells 0.0.1 → 0.0.2

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: 92aaa145891421df9098947f1be0ba1fad58f5e3
4
- data.tar.gz: 415466c1c78c5d8efbfaad5d2d05749dd0ab3980
3
+ metadata.gz: 9510806b02f56aefe87490e1d0d55a3322ead98d
4
+ data.tar.gz: b0dac1a496bf9ac9f532a441aca60eb9d745d5f8
5
5
  SHA512:
6
- metadata.gz: d7f979a52dfd7583508b5cdb103ec9e44da5218647fdaf3bc72454297299780649a07ac07af93f60375f2d55d2e65b0aeb44cd944d058ca92da435d170c0fc0b
7
- data.tar.gz: 1c83db460ab11c0169957005ffa0cb005fee0663c26c8a782c2533bb76307986aaef9b2a9621650201da54a098fe9cca1a853c4ab707ebb473d2817869fb49ad
6
+ metadata.gz: 20d520f12656c6d07578ba067bf323eff1aa1b3860e761dd48bd08f1fb18bc103f1b3709829225c9ba5219031d698e3d1a2f40358e6771c60a238a36ecaf2701
7
+ data.tar.gz: 89e9cd9ac75cdaf845343204e505581e0f749ee238697334bf026a87f539da7386fd8998e0c940ca3198951d4d20708736772a175615c198325dc5eb55d6fc85
data/README.md CHANGED
@@ -1,3 +1,45 @@
1
- = SimpleCells
1
+ # SimpleCells
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ ## Install
4
+
5
+ Add to your Gemfile and bundle:
6
+ ```ruby
7
+ gem "simple_cells"
8
+ ```
9
+
10
+ Add the render method by including the helper in your ApplicationHelper:
11
+ ```ruby
12
+ module ApplicationHelper
13
+ include SimpleCells::ViewsHelper
14
+ end
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Add a cells-class to your application in "app/simple_cells/users_simple_cell.rb":
20
+ ```ruby
21
+ class UsersSimpleCell < SimpleCells::BaseCell
22
+ def my_action
23
+ end
24
+
25
+ def helper_method
26
+ "Hello from helper method"
27
+ end
28
+ end
29
+ ```
30
+
31
+ Then add a view file for the action in "app/views/simple_cells/users/my_action.html.erb":
32
+ ```erb
33
+ Hello world
34
+ Content of my variable: <%= simple_cell[:my_variable] %>
35
+ Helper method: <%= simple_cell.helper_method %>
36
+ ```
37
+
38
+ You can now render it like this from another ERB file:
39
+ ```erb
40
+ <%= render_simple_cell :users, :my_action, my_variable: "Test" %>
41
+ ```
42
+
43
+ ## License
44
+
45
+ This project rocks and uses MIT-LICENSE.
@@ -5,11 +5,29 @@ class SimpleCells::BaseCell
5
5
  end
6
6
 
7
7
  def render_simple_cell_view(cell_name, action_name)
8
- @_simple_cell_view_context.render(
9
- file: Rails.root.join("app", "simple_cells", cell_name.to_s, action_name.to_s).to_s,
10
- locals: {
11
- simple_cell: self
8
+ @_simple_cell_name = cell_name
9
+ @_simple_cell_action_name = action_name
10
+
11
+ if @_simple_cell_view_to_render
12
+ if @_simple_cell_view_to_render[:view]
13
+ cell_to_render = {
14
+ file: File.join("/", "simple_cells", cell_name.to_s, @_simple_cell_view_to_render[:view]).to_s
15
+ }
16
+ else
17
+ cell_to_render = @_simple_cell_view_to_render
18
+ end
19
+ else
20
+ cell_to_render = {
21
+ file: File.join("/", "simple_cells", cell_name.to_s, action_name.to_s).to_s
12
22
  }
23
+ end
24
+
25
+ @_simple_cell_view_context.render(
26
+ {
27
+ locals: {
28
+ simple_cell: self
29
+ }
30
+ }.merge(cell_to_render)
13
31
  )
14
32
  end
15
33
 
@@ -17,6 +35,22 @@ class SimpleCells::BaseCell
17
35
  @_simple_cell_arguments.fetch(key)
18
36
  end
19
37
 
38
+ def []=(key, value)
39
+ @_simple_cell_arguments[key] = value
40
+ end
41
+
42
+ def render(args)
43
+ @_simple_cell_view_to_render = args
44
+ end
45
+
46
+ def simple_cell_argument?(argument_name)
47
+ @_simple_cell_arguments.key?(argument_name)
48
+ end
49
+
50
+ def simple_cell_arguments
51
+ @_simple_cell_arguments
52
+ end
53
+
20
54
  def view_context
21
55
  @_simple_cell_view_context
22
56
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleCells
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cells
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,14 +28,28 @@ dependencies:
28
28
  name: auto_autoloader
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.0.4
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: string-cases
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: 0.0.4
41
55
  - !ruby/object:Gem::Dependency
@@ -167,7 +181,6 @@ files:
167
181
  - app/helpers/simple_cells/views_helper.rb
168
182
  - app/views/layouts/simple_cells/application.html.erb
169
183
  - config/routes.rb
170
- - db/migrate/20160415055019_create_users.rb
171
184
  - lib/simple_cells.rb
172
185
  - lib/simple_cells/base_cell.rb
173
186
  - lib/simple_cells/engine.rb
@@ -193,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
206
  version: '0'
194
207
  requirements: []
195
208
  rubyforge_project:
196
- rubygems_version: 2.2.2
209
+ rubygems_version: 2.4.0
197
210
  signing_key:
198
211
  specification_version: 4
199
212
  summary: An attempt at writing a very simple cells gem.
@@ -1,11 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- t.string :first_name
5
- t.string :last_name
6
- t.string :email
7
- t.string :encrypted_password
8
- t.timestamps
9
- end
10
- end
11
- end