minigen 0.0.2.1 → 0.0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,6 @@ require "minigen/generator"
11
11
 
12
12
  module Minigen
13
13
 
14
- VERSION = "0.0.2.1"
14
+ VERSION = "0.0.2.2"
15
15
 
16
16
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minigen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.1
4
+ version: 0.0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -22,13 +22,13 @@ files:
22
22
  - README.md
23
23
  - lib/templates/tsm/test_helper.rb
24
24
  - lib/templates/tsm/test_project.rb
25
+ - lib/templates/base/test/deleteme
25
26
  - lib/templates/base/README.md
26
27
  - lib/templates/base/lib/project.rb
27
28
  - lib/templates/base/project.gemspec
28
29
  - lib/templates/shoulda/helper.rb
29
30
  - lib/templates/shoulda/test_project.rb
30
31
  - lib/minigen.rb~
31
- - lib/minigen/generator.rb~
32
32
  - lib/minigen/generator.rb
33
33
  - lib/minigen.rb
34
34
  - test/test_helper.rb
@@ -1,89 +0,0 @@
1
- module Minigen
2
-
3
- # Various methods to create the project skel
4
- class Generator
5
-
6
- # Public: Initialize a new Project
7
- def initialize options = {}
8
- @options = options
9
- @name = @options[:name].downcase
10
-
11
- # The test suite, abort if empty
12
- # Note: this is stupid
13
- if not @options[:test].nil?
14
- @test = @options[:test]
15
- else
16
- abort "You must specify a test suite"
17
- end
18
-
19
- # Checks if a folder exists with the name @name
20
- # if false, exits with a message
21
- abort "A folder with that name already exists" if File.directory? @name
22
-
23
- puts " - \033[32mGenerating\033[0m your project: #{@name}"
24
-
25
- # Runs the method that copies the template
26
- copy!
27
-
28
- end
29
-
30
- # Private: Copies the default template to @name dir,
31
- # the chosen test suite, and runs gsub'n'rename
32
- #
33
- # Returns nothing
34
- def copy!
35
- # Create the project diretory
36
- Dir.mkdir @name
37
-
38
- # Copies the base template files (e.g. readme, gemspec, etc)
39
- FileUtils.cp_r(Dir.glob(File.join(LIBDIR, "templates/base/*")), @name)
40
-
41
- # Copies the test suite ( see @options[:test] )
42
- FileUtils.cp_r(Dir.glob(File.join(LIBDIR, "templates/#{@test}/*")), "#{@name}/test/")
43
-
44
- gnr!
45
- end
46
-
47
- # Private: gsub'n'rename
48
- # Joins the new project directory,
49
- # gsubs the content of all files with the new project name
50
- # 'nd renames all
51
- #
52
- # Returns nothing
53
- def gnr!
54
- Dir.chdir @name
55
- Dir.glob("**/*.{rb,md,gemspec}").each {|f| ore f, "project", @name}
56
- Dir.glob("**/*.{rb,md,gemspec}").each {|f| ore f, "Project", @name.capitalize}
57
- File.rename "test/test_project.rb", "test/test_#{@name}.rb"
58
- File.rename "lib/project.rb", "lib/#{@name}.rb"
59
- File.rename "project.gemspec", "#{@name}.gemspec"
60
- puts " - done!"
61
- end
62
-
63
- # Private: Opens, Reads and Edits a file
64
- #
65
- # file - The file to edit
66
- # old - The term to be replaced
67
- # new - The new term
68
- #
69
- # Examples
70
- #
71
- # ore('README.md', 'Minigen', 'Rubygems')
72
- # # => True
73
- #
74
- # Returns True if everything went well :D
75
- def ore file, old, new
76
- o = File.read(file)
77
- o.gsub! /#{old}/, new
78
- n = File.new(file, "w+")
79
- n.puts(o)
80
- n.close
81
- return true
82
- end
83
-
84
- private :copy!, :gnr!, :ore
85
-
86
- end #Generator
87
-
88
- end #Minigen
89
-