rails-subpartial 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bbf4191ff5270ca09bbc8ddf9312bcb1435552d8
4
+ data.tar.gz: ff28e834bf36fda55a1f3ba3fff08949607afbdc
5
+ SHA512:
6
+ metadata.gz: 6910426ca359b93104d22504123d5770c7ee9cee1f5b5cb3d463b5a0de1139e2261f7e8a46941970107b4243d8cc0d96034449d8b4532260a3f7a62595edfbe2
7
+ data.tar.gz: 4ebe7ad0207cd5cbbd77995d3bf9eb737811aa3a3c471d981356dd8455f0d179f6ec893748ed52eb62aef3c466ccf551b005e48c9017b32479b3bf3caf31b5f9
@@ -0,0 +1,3 @@
1
+ module Rails
2
+ require_relative "rails/subpartial"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "action_view"
2
+ require "active_model"
3
+
4
+ module Rails
5
+ module Subpartial
6
+ require_relative "subpartial/version"
7
+ require_relative "subpartial/action_view/renderer/partial_renderer"
8
+ require_relative "subpartial/active_model/conversion"
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ module ActionView
2
+ class PartialRenderer < AbstractRenderer
3
+ def find_template(path, locals)
4
+ prefixes = path.start_with?("/") ? [] : @lookup_context.prefixes
5
+ @lookup_context.find_template(path, prefixes, true, locals, @details)
6
+ end
7
+
8
+ def merge_prefix_into_object_path(prefix, object_path)
9
+ if prefix.start_with?("/") && object_path.start_with?("/")
10
+ prefixes = []
11
+ prefix_array = File.dirname(prefix).split('/')
12
+ object_path_array = object_path.split('/')[0..-3] # skip model dir & partial
13
+
14
+ prefix_array.each_with_index do |dir, index|
15
+ break if dir == object_path_array[index]
16
+ prefixes << dir
17
+ end
18
+
19
+ (prefixes << object_path).join("/")
20
+ else
21
+ object_path
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module ActiveModel #:nodoc:
2
+ module Conversion #:nodoc:
3
+ module ClassMethods #:nodoc:
4
+ # Provide a class level cache for #to_partial_path. This is an
5
+ # internal method and should not be accessed directly.
6
+ def _to_partial_path #:nodoc:
7
+ @_to_partial_path ||= begin
8
+ element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(name))
9
+ collection = ActiveSupport::Inflector.tableize(name)
10
+ "/#{collection}/#{element}".freeze
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Rails
2
+ module Subpartial
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Rails::Subpartial::VERSION do
4
+ it "should be a string" do
5
+ expect(Rails::Subpartial::VERSION).to be_kind_of(String)
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ require "pry"
5
+ require "rspec"
6
+ require "rails/subpartial"
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-subpartial
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kurtis Rainbolt-Greene
8
+ - Alexey Osipenko
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-12-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 4.2.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 4.2.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.3'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.1'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.1'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.9'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.9'
84
+ - !ruby/object:Gem::Dependency
85
+ name: pry-doc
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.6'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.6'
98
+ - !ruby/object:Gem::Dependency
99
+ name: codeclimate-test-reporter
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.4'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.4'
112
+ description: Allowing rails to look in subfolders first for partials
113
+ email:
114
+ - me@kurtisrainboltgreene.name
115
+ - alexey@osipenko.in.ua
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - lib/rails-subpartial.rb
121
+ - lib/rails/subpartial.rb
122
+ - lib/rails/subpartial/action_view/renderer/partial_renderer.rb
123
+ - lib/rails/subpartial/active_model/conversion.rb
124
+ - lib/rails/subpartial/version.rb
125
+ - spec/lib/rails/subpartial/version_spec.rb
126
+ - spec/spec_helper.rb
127
+ homepage: http://krainboltgreene.github.io/rails-subpartial
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.4.3
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Allowing rails to look in subfolders first for partials
151
+ test_files:
152
+ - spec/lib/rails/subpartial/version_spec.rb
153
+ - spec/spec_helper.rb
154
+ has_rdoc: