yesman 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -28,6 +28,23 @@ There are several optional parameters you can use that will adjust the following
28
28
 
29
29
  -e C++ extension to use for generated files (defaults to "cpp")
30
30
 
31
+ To generate class files (along with headers and tests) from inside of your project directory run:
32
+
33
+ $ yesman generate "jsk::SuperClass<jsk::BaseClass"
34
+
35
+ The string passed to generate (also aliased to 'g') will create your class file, header, and test file. The format is:
36
+
37
+ "namespace::ClassName<namespace::ParentClass"
38
+
39
+ Namespaces and inheritance are optional, so you could just as easily run:
40
+
41
+ $ yesman g "SuperClass<BaseClass
42
+
43
+ or
44
+
45
+ $ yesman g "SuperClass"
46
+
47
+
31
48
  ## Requirements
32
49
 
33
50
  Under the hood there are several technologies that Yesman relies on. In order to run you will need the following:
data/bin/yesman CHANGED
@@ -13,7 +13,6 @@ def new_project
13
13
  parser = CliParser.new
14
14
  parser.run ARGV
15
15
  parser.config[:project_name] = project_name
16
- puts "Generating new project: #{parser.config[:project_name]}"
17
16
 
18
17
  y = Yesman.new parser.config
19
18
  end
data/lib/yesman.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'yesman/cpp_creator'
2
2
  require 'yesman/file_util'
3
3
  require 'yesman/gtest_installer'
4
+ require 'yesman/logger'
4
5
 
5
6
  class Yesman
6
7
  attr_reader :params
@@ -8,6 +9,7 @@ class Yesman
8
9
  def initialize options = {}
9
10
  create_defaults options
10
11
  @cp = ConfigProxy.new
12
+ @log = Logger.new
11
13
  init
12
14
  end
13
15
 
@@ -21,6 +23,8 @@ class Yesman
21
23
  end
22
24
 
23
25
  def init
26
+ @log.line_break
27
+ @log.log_heading "Creating initial directories and files"
24
28
  FileUtil.ensure_path params[:project_name]
25
29
  Dir.chdir( params[:project_name] )
26
30
  create_all
@@ -30,11 +34,12 @@ class Yesman
30
34
  @cp.create_config params
31
35
  p = CppCreator.new params
32
36
  p.create_project
33
- puts "Project directories created"
34
-
37
+ @log.log_message "Initial project files created"
38
+ @log.line_break
35
39
  g = GTestInstaller.new params
36
40
  g.download_and_install
37
-
41
+ @log.line_break
42
+ @log.log_emphasis "Setup complete!", "You are clear for take off."
38
43
  end
39
44
 
40
45
  end
@@ -2,6 +2,7 @@ require 'yesman/class_type'
2
2
  require 'yesman/templater'
3
3
  require 'yesman/file_util'
4
4
  require 'yesman/config_proxy'
5
+ require 'yesman/logger'
5
6
 
6
7
  class ClassGenerator
7
8
 
@@ -21,6 +22,7 @@ class ClassGenerator
21
22
  @gtest_main_path = create_path "gtest_main.cxx.erb"
22
23
 
23
24
  @templater = Templater.new
25
+ @log = Logger.new
24
26
  end
25
27
 
26
28
  def create_class_files input
@@ -28,7 +30,9 @@ class ClassGenerator
28
30
  files = [header_path, class_path, test_path]
29
31
  files.each do |path|
30
32
  file_contents = @templater.merge c, path
31
- FileUtil.write_to_file create_file_name( c, path ), file_contents
33
+ file_name = create_file_name(c,path)
34
+ FileUtil.write_to_file file_name, file_contents
35
+ @log.log_creation "created", file_name
32
36
  end
33
37
 
34
38
  end
@@ -37,12 +41,15 @@ class ClassGenerator
37
41
  c = create_class_type "Main"
38
42
  output_file_path = "#{params[:source]}/#{params[:project_name]}.#{params[:extension]}"
39
43
  FileUtil.write_to_file( output_file_path, ( @templater.merge c, main_path) )
44
+ @log.log_creation "created", output_file_path
40
45
  end
41
46
 
42
47
  def create_gtest_main
43
48
  c = create_class_type "GTestMain"
44
49
  file_contents = @templater.merge c, gtest_main_path
45
- FileUtil.write_to_file "#{params[:tests]}/#{params[:project_name]}Tests.#{params[:extension]}", file_contents
50
+ file_path = "#{params[:tests]}/#{params[:project_name]}Tests.#{params[:extension]}"
51
+ FileUtil.write_to_file file_path , file_contents
52
+ @log.log_creation "created", file_path
46
53
  end
47
54
 
48
55
  private
@@ -1,4 +1,5 @@
1
1
  require 'yesman/file_util'
2
+ require 'yesman/logger'
2
3
  require 'yesman/class_generator'
3
4
 
4
5
  class CppCreator
@@ -11,6 +12,7 @@ class CppCreator
11
12
  def initialize(params = {})
12
13
  set_defaults params
13
14
  @gen = ClassGenerator.new
15
+ @log = Logger.new
14
16
  end
15
17
 
16
18
  def create_project
@@ -30,9 +32,11 @@ private
30
32
  end
31
33
 
32
34
  def create_dirs
33
- FileUtil.ensure_path source
34
- FileUtil.ensure_path tests
35
- FileUtil.ensure_path output
35
+ paths = [source, tests, output]
36
+ paths.each do |path|
37
+ FileUtil.ensure_path path
38
+ @log.log_creation "created", "#{path}/"
39
+ end
36
40
  end
37
41
 
38
42
  def create_source_main
@@ -1,4 +1,5 @@
1
1
  require 'yesman/file_util'
2
+ require 'yesman/logger'
2
3
 
3
4
  class GTestInstaller
4
5
 
@@ -12,7 +13,7 @@ class GTestInstaller
12
13
  @gtest_dir = "gtest"
13
14
  @gtest_path = "http://googletest.googlecode.com/svn/trunk/"
14
15
  @gtest_local_repo_name = "googletest-read-only"
15
-
16
+ @log = Logger.new
16
17
  end
17
18
 
18
19
  def download_and_install
@@ -28,16 +29,16 @@ class GTestInstaller
28
29
  private
29
30
 
30
31
  def print_start
31
- puts "Google Test Setup"
32
+ @log.log_heading "Setting up Google Test Framework"
32
33
  end
33
34
 
34
35
  def pull_source
35
- puts "svn checkout of GTest source code..."
36
+ @log.log_message "svn checkout of GTest (could take a minute)..."
36
37
  `svn checkout #{gtest_path} #{repo_path}`
37
38
  end
38
39
 
39
40
  def compile_source
40
- puts "compiling GTest source code..."
41
+ @log.log_message "compiling GTest source code..."
41
42
  `g++ -I #{repo_path}/include/ -I #{repo_path}/ -c #{repo_path}/src/gtest-all.cc -o #{params[:tests]}/gtest/gtest-all.o`
42
43
  end
43
44
 
@@ -47,7 +48,7 @@ private
47
48
 
48
49
 
49
50
  def copy_needed_gtest_files
50
- puts "copying needed GTest files to tests dir"
51
+ @log.log_message "copying needed GTest files to tests dir"
51
52
  FileUtil.recursive_copy "#{repo_path}/include/gtest", "#{params[:tests]}/gtest/include"
52
53
  end
53
54
 
@@ -0,0 +1,23 @@
1
+ require 'paint'
2
+
3
+ class Logger
4
+
5
+ def log_emphasis heading, message
6
+ puts "#{Paint[heading, :green]} #{Paint[message, :cyan]}"
7
+ end
8
+
9
+ def log_creation heading, file_path
10
+ puts "... #{Paint[heading, :green]} #{file_path}"
11
+ end
12
+
13
+ def log_heading heading
14
+ puts "#{Paint[heading, :yellow]}"
15
+ end
16
+
17
+ def log_message message
18
+ puts "#{message}"
19
+ end
20
+ def line_break
21
+ puts ""
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Yesman
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/yesman.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = ""
14
14
 
15
15
  gem.add_dependency 'mixlib-cli'
16
+ gem.add_dependency 'paint'
16
17
 
17
18
  gem.files = `git ls-files`.split($/)
18
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yesman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2012-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mixlib-cli
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: paint
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: CLI for quick creation of C++ projects using GTest
31
47
  email:
32
48
  - knomedia@gmail.com
@@ -50,6 +66,7 @@ files:
50
66
  - lib/yesman/file_util.rb
51
67
  - lib/yesman/global_config.rb
52
68
  - lib/yesman/gtest_installer.rb
69
+ - lib/yesman/logger.rb
53
70
  - lib/yesman/templater.rb
54
71
  - lib/yesman/templates/class.cxx.erb
55
72
  - lib/yesman/templates/gtest_main.cxx.erb