10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/generators/feature_pack/add_feature/add_feature_generator.rb', line 10
def add_feature
raise "Feature name couldn't have more than one bar '/'" if name.count('/') > 1
@group_name, @feature_name = name.split('/')
@group = FeaturePack.group(@group_name.to_sym)
@group_class_name = @group_name.camelcase
@feature_class_name = @feature_name.camelcase
raise "Group '#{@group_name}' doesn't exist. First, create it." if @group.nil?
raise "Feature '#{@group_class_name}::#{@feature_class_name}' already Exist." if FeaturePack.feature(@group_name.to_sym, @feature_name.to_sym).present?
@feature_id = @feature_name.gsub('_', '-') + '-' + '999'
@feature_dir = @group.relative_path.join("feature_#{@feature_id}_#{@feature_name}")
template './controller.rb.tt', @feature_dir.join('controller.rb')
template './manifest.yaml.tt', @feature_dir.join('manifest.yaml')
template './routes.rb.tt', @feature_dir.join('routes.rb')
template './views/index.html.slim.tt', @feature_dir.join('views/index.html.slim')
template './views/partials/_header.html.slim.tt', @feature_dir.join('views/partials/_header.html.slim')
template './views/partials/_footer.html.slim.tt', @feature_dir.join('views/partials/_footer.html.slim')
template './doc/readme.md.tt', @feature_dir.join('doc/readme.md')
create_file @feature_dir.join('queries', '.gitkeep')
end
|