rapp 0.2.1 → 0.2.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c296df48d1c482b07ddf0e3d09092bad7966b3e7
|
4
|
+
data.tar.gz: 5d4a5c69a4b7a0fd42cc8baaadf4ab4950de7e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4212bda2d439e05d0c0ade2d93aa2c9cc47996483a83d63cfd9ffdb403897fd1aeb3b8cb762a9e47ceb6279e976e48721d4ed93dc4fcfe60d9a7cdfaf9163d7a
|
7
|
+
data.tar.gz: cac8b975f8e35fb4ff8261152e4a8ac9b7219716a1a52fe1b799328459722652d3020fbedd5fbd2534275792ea5109a8a9399e0f2c02c7741f8769db49021e9f
|
data/lib/rapp/builder.rb
CHANGED
@@ -33,12 +33,7 @@ module Rapp
|
|
33
33
|
# Build the directory structure first
|
34
34
|
Dir.mkdir(root_dir)
|
35
35
|
|
36
|
-
DirectoryStructure
|
37
|
-
dir_name = "#{root_dir}/#{dir}"
|
38
|
-
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
39
|
-
end
|
40
|
-
|
41
|
-
# For each template, render it, place it in the folder structure it corresponds to
|
36
|
+
add_directories(DirectoryStructure, app_name, root_dir)
|
42
37
|
|
43
38
|
# Construct the data object
|
44
39
|
template_binding = OpenStruct.new(
|
@@ -47,18 +42,11 @@ module Rapp
|
|
47
42
|
:rapp_version=>Rapp::VERSION
|
48
43
|
})
|
49
44
|
|
45
|
+
# For each template, render it, place it in the folder structure it corresponds to
|
50
46
|
# Skip spec dirs unless they said they wanted it
|
51
47
|
# My intention here is to use "or" specifically, because it does not short-circuit. The second check is very important
|
52
48
|
Dir["#{template_root}/**/*"].reject { |p| File.directory? p or p.include?('spec') }.each do |template|
|
53
|
-
|
54
|
-
relative_name = template.split("templates/")[1][0..-5]
|
55
|
-
# Hack to make the entry point ruby file share the same name as the app
|
56
|
-
# Need to clean this up, make it more extensible...
|
57
|
-
relative_name = "#{app_name}.rb" if relative_name == "app.rb"
|
58
|
-
relative_name = "#{app_name}_base.rb" if relative_name == "app_base.rb"
|
59
|
-
|
60
|
-
result = ERB.new(template_data).result(template_binding.instance_eval {binding})
|
61
|
-
File.write("#{root_dir}/#{relative_name}", result)
|
49
|
+
write_file(template, template_binding, app_name, root_dir)
|
62
50
|
end
|
63
51
|
|
64
52
|
# If set on the cli, build the spec stuff
|
@@ -68,6 +56,24 @@ module Rapp
|
|
68
56
|
puts "#{`find ./#{app_name}`}"
|
69
57
|
end
|
70
58
|
|
59
|
+
def add_directories(directories, app_name, root_dir)
|
60
|
+
directories.each do |dir|
|
61
|
+
dir.gsub!('app_name', app_name) if dir.include?("app_name")
|
62
|
+
dir_name = "#{root_dir}/#{dir}"
|
63
|
+
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def write_file(template_name, template_binding, app_name, root_dir)
|
68
|
+
template_data = File.read(template_name)
|
69
|
+
relative_name = template_name.split("templates/")[1][0..-5]
|
70
|
+
# Hack to make the entry point ruby file share the same name as the app
|
71
|
+
relative_name.gsub!("app_name", app_name)
|
72
|
+
|
73
|
+
result = ERB.new(template_data).result(template_binding.instance_eval {binding})
|
74
|
+
File.write("#{root_dir}/#{relative_name}", result)
|
75
|
+
end
|
76
|
+
|
71
77
|
def add_specs(root_dir, options)
|
72
78
|
app_name = options[:name]
|
73
79
|
#add rspec to the gemfile
|
@@ -75,12 +81,8 @@ module Rapp
|
|
75
81
|
f.puts 'gem "rspec", "~>3.1.0"'
|
76
82
|
end
|
77
83
|
|
78
|
-
#
|
79
|
-
SpecStructure
|
80
|
-
name = dir.gsub!('app_name', app_name) if dir.include?("app_name")
|
81
|
-
dir_name = "#{root_dir}/#{name}"
|
82
|
-
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
83
|
-
end
|
84
|
+
# Add the spec specific directories
|
85
|
+
add_directories(SpecStructure, app_name, root_dir)
|
84
86
|
|
85
87
|
# Construct the data object
|
86
88
|
template_binding = OpenStruct.new(
|
@@ -91,11 +93,7 @@ module Rapp
|
|
91
93
|
|
92
94
|
# Get all the spec templates
|
93
95
|
Dir["#{template_root}/spec/**/*"].reject {|p| File.directory? p }.each do |template|
|
94
|
-
|
95
|
-
relative_name = template.split("templates/")[1][0..-5]
|
96
|
-
relative_name = relative_name.gsub!('app_name', app_name) if relative_name.include?("app_name")
|
97
|
-
result = ERB.new(template_data).result(template_binding.instance_eval {binding})
|
98
|
-
File.write("#{root_dir}/#{relative_name}", result)
|
96
|
+
write_file(template, template_binding, app_name, root_dir)
|
99
97
|
end
|
100
98
|
end
|
101
99
|
|
data/lib/rapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StabbyCutyou
|
@@ -72,8 +72,8 @@ files:
|
|
72
72
|
- lib/rapp/cli.rb
|
73
73
|
- lib/rapp/templates/Gemfile.erb
|
74
74
|
- lib/rapp/templates/Rakefile.erb
|
75
|
-
- lib/rapp/templates/
|
76
|
-
- lib/rapp/templates/
|
75
|
+
- lib/rapp/templates/app_name.rb.erb
|
76
|
+
- lib/rapp/templates/app_name_base.rb.erb
|
77
77
|
- lib/rapp/templates/config/environments/development.rb.erb
|
78
78
|
- lib/rapp/templates/config/environments/production.rb.erb
|
79
79
|
- lib/rapp/templates/config/environments/test.rb.erb
|
File without changes
|
File without changes
|