atomic_assets 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails/generators/atomic_assets/component/component_generator.rb +41 -0
- data/lib/rails/generators/atomic_assets/templates/component.rb +24 -0
- data/lib/rails/generators/atomic_assets/templates/component.scss +0 -0
- data/lib/rails/generators/atomic_assets/templates/component.slim +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a82339e3f90aa58164448f395ef8c4ab665c638c
|
4
|
+
data.tar.gz: 737cef54aa1dc811e04c89a13067cb2aa6fbfb84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da60daeda8f5ee4c27812d5c51d44d42bd79be0226b6d3d63e93ff1418c103479e8fbbb8c49d16d46cc12d635c085e6247a19a2af0026319db3521eba19de54b
|
7
|
+
data.tar.gz: 491f009aeabf0876dd1f09b6eac198bccafd9454f988e6ff70a8d155633c0607cf6c38fe6b832724a366176c76e9360e5ffc611c08717b6780383add1d366d59
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module AtomicAssets
|
2
|
+
module Generators
|
3
|
+
class ComponentGenerator < Rails::Generators::Base
|
4
|
+
argument :component_name, required: true
|
5
|
+
|
6
|
+
desc <<-DESC.strip_heredoc
|
7
|
+
Creates all files requred when generating a new atomic asset component
|
8
|
+
DESC
|
9
|
+
|
10
|
+
source_root File.expand_path("../../templates", __FILE__)
|
11
|
+
|
12
|
+
def create_component_file
|
13
|
+
@component = OpenStruct.new(
|
14
|
+
class_prefix: class_prefix,
|
15
|
+
key: file_prefix
|
16
|
+
)
|
17
|
+
template "component.rb", "app/components/#{file_prefix}_component.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_scss_file
|
21
|
+
fullpath = "app/assets/stylesheets/components/_#{file_prefix}.scss"
|
22
|
+
template "component.scss", fullpath
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_slim_file
|
26
|
+
fullpath = "app/views/components/#{file_prefix}.html.slim"
|
27
|
+
template "component.slim", fullpath
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def file_prefix
|
33
|
+
component_name.underscore
|
34
|
+
end
|
35
|
+
|
36
|
+
def class_prefix
|
37
|
+
component_name.camelize
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class <%= @component.class_prefix %>Component < AtomicAssets::Component
|
2
|
+
def edit
|
3
|
+
rtn = cms_fields(field_types)
|
4
|
+
rtn << h.component(<%= ":#{@component.key}" %>, field_previews).render
|
5
|
+
rtn.html_safe
|
6
|
+
end
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def field_previews
|
11
|
+
{
|
12
|
+
header: "{{preview.header}}",
|
13
|
+
content: markdown_preview('preview.content')
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def field_types
|
18
|
+
{
|
19
|
+
header: { field_type: "text" },
|
20
|
+
content: { field_type: "markdown" }
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Humphreys
|
@@ -95,6 +95,10 @@ files:
|
|
95
95
|
- lib/atomic_assets/options.rb
|
96
96
|
- lib/atomic_assets/render.rb
|
97
97
|
- lib/atomic_assets/serialize.rb
|
98
|
+
- lib/rails/generators/atomic_assets/component/component_generator.rb
|
99
|
+
- lib/rails/generators/atomic_assets/templates/component.rb
|
100
|
+
- lib/rails/generators/atomic_assets/templates/component.scss
|
101
|
+
- lib/rails/generators/atomic_assets/templates/component.slim
|
98
102
|
homepage: http://github.com/dhumphreys/atomic_assets
|
99
103
|
licenses: []
|
100
104
|
metadata: {}
|
@@ -114,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
118
|
version: '0'
|
115
119
|
requirements: []
|
116
120
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.4.
|
121
|
+
rubygems_version: 2.4.7
|
118
122
|
signing_key:
|
119
123
|
specification_version: 4
|
120
124
|
summary: Atomic Assets
|