erb_component 0.1.4 → 0.1.5

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
  SHA256:
3
- metadata.gz: 40483d823e533c0e6f706d8691d1e8a5e26a3f5ef15654b7e31c3c7531c07a2e
4
- data.tar.gz: 647bccf54f21a52b81824057d845145607ef60a335536234fd6f56c73870d99b
3
+ metadata.gz: 9e48ccbfc0ce46abcce8ecedab8dd8b56e64254b242ba52e919429c4aba0e362
4
+ data.tar.gz: c976659b689ad129f06160d1423af4f4ad168209af878c81cf647f4c0257b9b8
5
5
  SHA512:
6
- metadata.gz: e5b1ee9b8daf98072cdfc949ad78189f8c6edb8d8159a79b49c57f41be5b94fce8412a29c64c838eed9b720042fffd0f348a81532338e4027c0918bfcf4ec659
7
- data.tar.gz: dd2dbc6e8b2311054dfa0b39e5588493b11804aeb91d1ccaf4a6d33ff5b37f69e008e1428c247ace942a6df420a7d663a6d8c5998106ff52b33273120271361c
6
+ metadata.gz: df51f06dd8f67c0dbeacbee4267de9107268b29b4b7bfbedaae273774924940d5c3f5de767e8c31e9fa2f6157a0d5dae80e363ca9cabaff62dbeaabbc233b190
7
+ data.tar.gz: 0b54f5577b6ee16e915dd33cd0931d950bd8726a59091c0e2dc471cc327b3af4df4eb3f88fe968a6ad61c32ca9467e4b7dabbd492f3a9c93255d74ca185d03d9
@@ -29,13 +29,24 @@ class ErbComponent
29
29
  new(opts).render
30
30
  end
31
31
 
32
+ def template_file_path
33
+ @template_file_path ||= begin
34
+ file_name = "#{self.class.name.underscore}.erb"
35
+ if File.exists? "components/#{file_name}"
36
+ return "components/#{file_name}"
37
+ elsif File.exists? "pages/#{file_name}"
38
+ return "pages/#{file_name}"
39
+ else
40
+ nil
41
+ end
42
+ end
43
+ end
44
+
32
45
  def template
33
- file_name = "#{self.class.name.underscore}.erb"
34
- a = "components/#{file_name}"
35
- return File.read a if File.exists? a
36
- a = "pages/#{file_name}"
37
- return File.read a if File.exists? a
38
- fail "not found: #{file_name}"
46
+ if template_file_path
47
+ File.read template_file_path
48
+ end
49
+ fail "not found: #{template_file_path}"
39
50
  end
40
51
 
41
52
  def method_missing(m, *args, &block)
@@ -1,3 +1,3 @@
1
1
  class ErbComponent
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Karganyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: React-style front-end components but for ERB?
14
14
  email: