cuba_genie 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6624364f60d76b389eeea559ac1a897fa1e53bd9
4
- data.tar.gz: f5d9ab4465ccac5b2a5b630bf07107fe1d56aab5
3
+ metadata.gz: 6ea6de37fd537e0cf2a0022b2c449fba4d4b95dd
4
+ data.tar.gz: 519edffa9fc41d3e2cd2474e7d13c4854e4feef8
5
5
  SHA512:
6
- metadata.gz: 5cd8abba5fdacbad51d48e190ff675a1a44a2ef67894b6455fe34a5ac7216d645c37696cdaf6caf7f5370dba7928c8cf8b749b10e2ff038b5c8a2a1a075b1459
7
- data.tar.gz: 38ba324e8a7464564a321e99025852de160f4745c16fcb9201a480641868a15f03acab068957c620675e1497c6fd9370df7cc3725d82f0fb7671d562662481ae
6
+ metadata.gz: 440620a683669ad330137c3dcdf041a9a4ce8e7ea7197c253179b6c6401f8c7605b95d7f49b91a489c068add9b848be01602aa620f7929f2e7481807f4a15196
7
+ data.tar.gz: 3f5d48e6d95fa781d99df3e9bacae3fb90dbc6bfd961f853030ad1469ce821855ddff6fb114c9a3e11eba759fc6223d087120ccd8ed7a3f8c74d2c485a7aac82
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+
4
+ ## 0.1.0 (2016-04-10)
5
+
6
+ -- Initial release
7
+
8
+ ## 0.1.1 (2016-04-11)
9
+
10
+ -- Fixed bug by 'require pry' line left in code
11
+
12
+ ## 0.1.2 (2016-04-11)
13
+
14
+ -- Some serious code refactoring
15
+
16
+
@@ -1,6 +1,6 @@
1
1
  require "cuba_genie/version"
2
- require "cuba_genie/content"
3
- require "cuba_genie/content_helpers"
2
+ require "cuba_genie/content/content"
3
+ require "cuba_genie/content/content_helpers"
4
4
 
5
5
  require 'thor'
6
6
  require_relative 'cuba_genie/command_list'
@@ -24,9 +24,9 @@ module CubaGenie
24
24
  minitest = want_minitest?
25
25
  reporter = (minitest ? choose_reporter : 'n')
26
26
  capybara = (minitest ? want_capybara? : false)
27
- @cmds.add_command CubaSetup.new(project_name, minitest, capybara)
28
- @cmds.add_command ViewsSetup.new(project_name, choose_bootstrap_version)
29
- @cmds.add_command MinitestSetup.new(project_name, reporter, capybara) if minitest
27
+ @cmds.add_command CubaSetup.new(project_name: project_name, minitest: minitest, capybara: capybara)
28
+ @cmds.add_command ViewsSetup.new(project_name: project_name, bootstrap_version: choose_bootstrap_version)
29
+ @cmds.add_command MinitestSetup.new(project_name: project_name, reporter: reporter, capybara_setup: capybara) if minitest
30
30
  puts closing_message(project_name) if @cmds.execute
31
31
  end
32
32
 
@@ -0,0 +1,29 @@
1
+ module CubaGenie
2
+
3
+ class Command
4
+
5
+ attr_reader :description, :error, :project_name
6
+
7
+ def initialize(**args)
8
+ @files_created, @dirs_created = [], []
9
+ end
10
+
11
+ def execute
12
+ yield
13
+ true
14
+ rescue Exception => e
15
+ puts e.message and false
16
+ end
17
+
18
+ def unexecute(message)
19
+ puts message unless ENV['RACK_ENV'] == 'test'
20
+ @files_created.each do |file_path|
21
+ File.delete file_path if File.exist? file_path
22
+ end
23
+ @dirs_created.each do |dir_name|
24
+ FileUtils.rm_rf(dir_name) if Dir.exist? dir_name
25
+ end
26
+ end
27
+
28
+ end #class
29
+ end #CubaGenie
@@ -108,10 +108,17 @@ gem "mote-render"
108
108
  group :development, :test do
109
109
  gem 'pry-byebug'
110
110
  gem 'minitest-reporters'
111
+ %s
111
112
  gem 'shotgun'
112
113
  end
113
114
  )
114
115
 
116
+ GEM_FILE_CAPYBARA_CONTENT = %Q(
117
+ gem 'rack-test'
118
+ gem 'minitest-capybara'
119
+ gem 'selenium-webdriver'
120
+ )
121
+
115
122
 
116
123
  RAKE_FILE_CONTENT = %q(
117
124
  require 'rake/testtask'
@@ -1,4 +1,6 @@
1
- HOME_VIEW_CONTENT = %Q(
1
+ module Content
2
+
3
+ HOME_VIEW_CONTENT = %Q(
2
4
  <div class="jumbotron">
3
5
  <div class="container">
4
6
  <h1>Hello from Cuba Genie!</h1>
@@ -35,4 +37,6 @@ generated by <a href="https://gitlab.com/RedFred7/cuba-genie">Cuba Genie</a>. Wh
35
37
  <p>&copy; your company name here </p>
36
38
  </footer>
37
39
  </div> <!-- /container -->
38
- )
40
+ )
41
+
42
+ end
@@ -1,3 +1,6 @@
1
+ module Content
2
+
3
+
1
4
  LAYOUT_VIEW_CONTENT = %Q(
2
5
  <!DOCTYPE html>
3
6
  <html lang="en">
@@ -49,6 +52,7 @@
49
52
 
50
53
  </body>
51
54
  </html>
52
-
53
-
54
55
  )
56
+
57
+
58
+ end
@@ -1,44 +1,37 @@
1
1
  require 'fileutils'
2
- require_relative 'content'
2
+ require_relative 'content/content'
3
+ require_relative 'command'
3
4
 
4
5
  module CubaGenie
5
6
 
6
- class CubaSetup
7
+ class CubaSetup < Command
7
8
  include Content
8
- attr_reader :description, :error, :project_name
9
9
 
10
- def initialize(project_name, minitest, capybara)
10
+ def initialize(**args)
11
+ @project_name = args[:project_name]
12
+ @minitest = args[:minitest]
13
+ @capybara = args[:capybara]
11
14
  @description = "Creating Cuba setup"
12
- @project_name = project_name
13
- @minitest = minitest
14
- @capybara = capybara
15
- @files_created = []
16
- @dirs_created = []
15
+ super
16
+
17
17
  end
18
18
 
19
19
  def execute
20
-
21
- FileUtils.mkdir @project_name
22
- @dirs_created << @project_name
23
- FileUtils.chdir @project_name
24
- create_app_file
25
- create_rack_file
26
- create_gem_file
27
- create_ruby_version_file
28
- create_ruby_gemset_file
29
- true
30
- rescue Exception => e
31
- @error = e.message and false
20
+ super do
21
+ FileUtils.mkdir @project_name
22
+ @dirs_created << @project_name
23
+ FileUtils.chdir @project_name
24
+ create_app_file
25
+ create_rack_file
26
+ create_gem_file
27
+ create_ruby_version_file
28
+ create_ruby_gemset_file
29
+ end
32
30
  end
33
31
 
32
+
34
33
  def unexecute
35
- puts "rolling back Cuba basic setup" unless ENV['RACK_ENV'] == 'test'
36
- @files_created.each do |file_path|
37
- File.delete file_path if File.exist? file_path
38
- end
39
- @dirs_created.each do |dir_name|
40
- FileUtils.rm_rf(dir_name) if Dir.exist? dir_name
41
- end
34
+ super("rolling back Cuba basic setup")
42
35
  end
43
36
 
44
37
  private
@@ -57,15 +50,11 @@ module CubaGenie
57
50
 
58
51
  def create_gem_file
59
52
  File.open('Gemfile', 'w') do |f|
60
- if @minitest
61
- gems_to_add = "\s\sgem 'rack-test'"
62
- if @capybara
63
- gems_to_add = "\s\sgem 'rack-test'" \
64
- "\n\s\sgem 'minitest-capybara'" \
65
- "\n\s\sgem 'selenium-webdriver'"
66
- end
67
- f.write GEM_FILE_CONTENT.split("\n").insert(8, gems_to_add).join("\n")
68
- else
53
+ if @minitest && !@capybara
54
+ f.write GEM_FILE_CONTENT % "gem 'rack-test'"
55
+ elsif @minitest && @capybara
56
+ f.write GEM_FILE_CONTENT % GEM_FILE_CAPYBARA_CONTENT
57
+ elsif !@minitest
69
58
  f.write GEM_FILE_CONTENT
70
59
  end
71
60
  end
@@ -1,50 +1,44 @@
1
1
  require 'fileutils'
2
- require_relative 'content'
2
+ require_relative 'content/content'
3
+ require_relative 'command'
4
+
3
5
 
4
6
  module CubaGenie
5
7
 
6
- class MinitestSetup
8
+ class MinitestSetup < Command
7
9
  include Content
8
10
 
9
- attr_reader :description, :error
10
11
  attr_writer :test_helper
11
12
 
12
- def initialize(project_name, reporter='Default', capybara_setup=false)
13
- @description = (capybara_setup ?
13
+ def initialize(**args)
14
+ @description = (args[:capybara_setup] ?
14
15
  "Setting up Minitest functional and acceptance tests" :
15
16
  "Setting up Minitest functional tests")
16
- @capybara_setup = capybara_setup
17
- @project_name = project_name
18
- @reporter = reporter
19
- @files_created, @dirs_created = [], []
17
+ @capybara_setup = args[:capybara_setup]
18
+ @project_name = args[:project_name]
19
+ @reporter = args[:reporter] || 'Default'
20
20
  @test_helper = "test/test_helper.rb"
21
+ super
21
22
  end
22
23
 
23
24
  def execute
24
- FileUtils.mkdir_p "test/functional"
25
- @dirs_created << "test" << "test/functional"
26
- if @capybara_setup
27
- FileUtils.mkdir_p "test/acceptance"
28
- @dirs_created << "test/acceptance"
25
+ super do
26
+ FileUtils.mkdir_p "test/functional"
27
+ @dirs_created << "test" << "test/functional"
28
+ if @capybara_setup
29
+ FileUtils.mkdir_p "test/acceptance"
30
+ @dirs_created << "test/acceptance"
31
+ end
32
+ create_test_helper
33
+ create_rake_file
34
+ create_functional_test
35
+ create_acceptance_test if @capybara_setup
29
36
  end
30
- create_test_helper
31
- create_rake_file
32
- create_functional_test
33
- create_acceptance_test if @capybara_setup
34
- true
35
- rescue Exception => e
36
- @error = e.message and false
37
37
  end
38
38
 
39
+
39
40
  def unexecute
40
- puts "rolling back test" unless ENV['RACK_ENV'] == 'test'
41
- # FileUtils.chdir @parent_dir
42
- @files_created.each do |file_path|
43
- File.delete file_path if File.exist? file_path
44
- end
45
- @dirs_created.each do |dir_name|
46
- FileUtils.rm_rf(dir_name) if Dir.exist? dir_name
47
- end
41
+ super("rolling back Minitest")
48
42
  end
49
43
 
50
44
 
@@ -1,3 +1,3 @@
1
1
  module CubaGenie
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,54 +1,48 @@
1
1
  require 'fileutils'
2
- require_relative 'content'
3
- require_relative 'home_view_content'
4
- require_relative 'layout_view_content'
2
+ require_relative 'content/content'
3
+ require_relative 'content/home_view_content'
4
+ require_relative 'content/layout_view_content'
5
+ require_relative 'command'
6
+
5
7
 
6
8
  module CubaGenie
7
9
 
8
10
  ALLOWED_BOOTSTRAP_VERSIONS = %w(3.3.0 3.3.5 3.3.6 4.0.0-alpha.2)
9
11
 
10
- class ViewsSetup
12
+ class ViewsSetup < Command
11
13
  require 'open-uri'
12
14
  require 'zip'
13
15
 
14
16
  include Content
15
- attr_reader :description, :error, :project_name
16
17
 
17
- def initialize(project_name, bootstrap_version='n', template_engine=:mote)
18
- @project_name = project_name
18
+ def initialize(**args)
19
+ @project_name = args[:project_name]
19
20
  #TODO: allow for choice of different template engines
20
21
  @description = 'Setting up views'
21
- @files_created = []
22
- @dirs_created = []
23
- @bootstrap_version = bootstrap_version
22
+ @bootstrap_version = args[:bootstrap_version] || 'n'
23
+ super
24
24
  end
25
25
 
26
26
  def execute
27
- layout_view_formatters = [nil, @project_name.capitalize, nil]
28
-
29
- if ALLOWED_BOOTSTRAP_VERSIONS.include? @bootstrap_version
30
- bootstrap_location =
31
- "https://github.com/twbs/bootstrap/releases/download/v#{@bootstrap_version}/bootstrap-#{@bootstrap_version}-dist.zip"
32
- download_bootstrap_from bootstrap_location
33
- extract_bootstrap_to 'public'
34
- layout_view_formatters = [BOOTSTRAP_CSS, @project_name.capitalize, BOOTSTRAP_JS]
27
+ super do
28
+ layout_view_formatters = [nil, @project_name.capitalize, nil]
29
+
30
+ if ALLOWED_BOOTSTRAP_VERSIONS.include? @bootstrap_version
31
+ bootstrap_location =
32
+ "https://github.com/twbs/bootstrap/releases/download/v#{@bootstrap_version}/bootstrap-#{@bootstrap_version}-dist.zip"
33
+ download_bootstrap_from bootstrap_location
34
+ extract_bootstrap_to 'public'
35
+ layout_view_formatters = [BOOTSTRAP_CSS, @project_name.capitalize, BOOTSTRAP_JS]
36
+ end
37
+ create_view_files(layout_view_formatters)
35
38
  end
36
- create_view_files(layout_view_formatters)
37
- true
38
- rescue Exception => e
39
- @error = e.message and false
40
39
  end
41
40
 
42
41
  def unexecute
43
- puts "rolling back views" unless ENV['RACK_ENV'] == 'test'
44
- @files_created.each do |file_path|
45
- File.delete file_path if File.exist? file_path
46
- end
47
- @dirs_created.each do |dir_name|
48
- FileUtils.rm_rf(dir_name) if Dir.exist? dir_name
49
- end
42
+ super("rolling back views")
50
43
  end
51
44
 
45
+
52
46
  private
53
47
  def create_view_files(layout_view_formatters)
54
48
  FileUtils.mkdir "views"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuba_genie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Heath
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ extra_rdoc_files: []
163
163
  files:
164
164
  - ".gitignore"
165
165
  - ".travis.yml"
166
+ - CHANGELOG.md
166
167
  - Gemfile
167
168
  - LICENSE.txt
168
169
  - README.md
@@ -172,12 +173,13 @@ files:
172
173
  - exe/cuba_genie
173
174
  - exe/setup
174
175
  - lib/cuba_genie.rb
176
+ - lib/cuba_genie/command.rb
175
177
  - lib/cuba_genie/command_list.rb
176
- - lib/cuba_genie/content.rb
177
- - lib/cuba_genie/content_helpers.rb
178
+ - lib/cuba_genie/content/content.rb
179
+ - lib/cuba_genie/content/content_helpers.rb
180
+ - lib/cuba_genie/content/home_view_content.rb
181
+ - lib/cuba_genie/content/layout_view_content.rb
178
182
  - lib/cuba_genie/cuba_setup.rb
179
- - lib/cuba_genie/home_view_content.rb
180
- - lib/cuba_genie/layout_view_content.rb
181
183
  - lib/cuba_genie/minitest_setup.rb
182
184
  - lib/cuba_genie/version.rb
183
185
  - lib/cuba_genie/views_setup.rb
@@ -201,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
203
  version: '0'
202
204
  requirements: []
203
205
  rubyforge_project:
204
- rubygems_version: 2.4.8
206
+ rubygems_version: 2.4.6
205
207
  signing_key:
206
208
  specification_version: 4
207
209
  summary: CubaGenie is a generator gem that sets up all the infrastructure you need