redux_gen 0.2.1 → 0.3.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/redux_gen.rb +21 -3
- data/lib/redux_gen/template.rb +9 -4
- data/lib/redux_gen/validations.rb +14 -0
- data/lib/redux_gen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5afd57bddd4117bcb86a648a4e3c82aa6fce07f4
|
4
|
+
data.tar.gz: c15670b5b82514e6b80735d2e7be101797dde058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22e9d389d03f18e769f649ef2cea09870543916eef0e35b2f749b03423c2356c3561af07a6959f08b92f44ae857cf5b2f87a2414481bbfe340cf6647d685badc
|
7
|
+
data.tar.gz: 55a1717a55953d9ec8d31d0d0f69973eb8fe322dabb07525bd807742ed92609e565177ddb6357c3c58087da4273b9e8c4459e5c162957d8800131c099aee290a
|
data/Gemfile.lock
CHANGED
data/lib/redux_gen.rb
CHANGED
@@ -10,11 +10,29 @@ module ReduxGen
|
|
10
10
|
def new(component, name)
|
11
11
|
Validations.validate component
|
12
12
|
Validations.validate_directory_for component
|
13
|
-
|
14
|
-
|
13
|
+
Validations.validate_test_directory_for component
|
14
|
+
make component, name
|
15
|
+
make_test component, name
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def write_out(path, content)
|
15
21
|
open(path, 'w') do |output|
|
16
|
-
output.write
|
22
|
+
output.write content
|
17
23
|
end
|
18
24
|
end
|
25
|
+
|
26
|
+
def make(component, name)
|
27
|
+
path = Validations.component_path component, name
|
28
|
+
template = Template.new(component, name).render
|
29
|
+
write_out(path, template)
|
30
|
+
end
|
31
|
+
|
32
|
+
def make_test(component, name)
|
33
|
+
test_path = Validations.test_path component, name
|
34
|
+
test_template = Template.new(component, name, test: true).render
|
35
|
+
write_out(test_path, test_template)
|
36
|
+
end
|
19
37
|
end
|
20
38
|
end
|
data/lib/redux_gen/template.rb
CHANGED
@@ -2,8 +2,8 @@ module ReduxGen
|
|
2
2
|
class Template
|
3
3
|
attr_accessor :name
|
4
4
|
|
5
|
-
def initialize(component, name)
|
6
|
-
@renderer = Template.renderer_for component
|
5
|
+
def initialize(component, name, test: false)
|
6
|
+
@renderer = Template.renderer_for component, test: test
|
7
7
|
@name = Validations.sanitize component, name
|
8
8
|
end
|
9
9
|
|
@@ -19,8 +19,13 @@ module ReduxGen
|
|
19
19
|
"#{template_directory}/#{component}.js.erb"
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.
|
23
|
-
|
22
|
+
def self.test_path component
|
23
|
+
"#{template_directory}/#{component}.spec.js.erb"
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.renderer_for component, test: false
|
27
|
+
path = test ? Template.test_path(component) : Template.path(component)
|
28
|
+
ERB.new(open(path).read)
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -9,14 +9,28 @@ module ReduxGen
|
|
9
9
|
component == "middleware" ? component : "#{component}s"
|
10
10
|
end
|
11
11
|
|
12
|
+
def self.test_directory component
|
13
|
+
"#{directory(component)}/tests"
|
14
|
+
end
|
15
|
+
|
12
16
|
def self.validate_directory_for component
|
13
17
|
Dir.mkdir directory(component) unless Dir.exists? directory(component)
|
14
18
|
end
|
15
19
|
|
20
|
+
def self.validate_test_directory_for component
|
21
|
+
unless Dir.exists? test_directory(component)
|
22
|
+
Dir.mkdir test_directory(component)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
def self.component_path(component, name)
|
17
27
|
"#{directory(component)}/#{sanitize(component, name)}.js"
|
18
28
|
end
|
19
29
|
|
30
|
+
def self.test_path(component, name)
|
31
|
+
"#{directory(component)}/tests/#{sanitize(component, name)}.spec.js"
|
32
|
+
end
|
33
|
+
|
20
34
|
def self.sanitize component, name
|
21
35
|
first = name.split.first
|
22
36
|
rest = name.split[1..-1].map(&:capitalize).join
|
data/lib/redux_gen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redux_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esteban Hernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|