minigen 0.0.1

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 ADDED
@@ -0,0 +1,80 @@
1
+ minigen
2
+ =======
3
+
4
+ > just another projects generator
5
+
6
+ installation
7
+ ------------
8
+
9
+ $: [sudo] gem install minigen
10
+
11
+ description
12
+ -----------
13
+
14
+ a project generator that creates a tree like this (eg.):
15
+
16
+ .
17
+ ├── project.gemspec
18
+ ├── lib
19
+ │   └── project.rb
20
+ ├── README.md
21
+ └── test
22
+ ├── project_test.rb
23
+ └── test_helper.rb
24
+
25
+ ### PROJECT.gemspec
26
+
27
+ a simple gemspec that takes the variable "version" from the constant "VERSION" present in "lib/project.rb"
28
+
29
+ ### lib/PROJECT.rb
30
+
31
+ contains something like:
32
+
33
+ module YourProject
34
+ VERSION = "0.0.0"
35
+ end
36
+
37
+ ### README.md
38
+
39
+ a simple, markdown formatted, readme that contains some essential points (see paragraph one of: [pengwynn's](http://twitter/pengwynn) [awesome post](http://thechangelog.com/post/3032074343/top-ten-reasons-why-i-wont-use-your-open-source-project))
40
+
41
+ ### test/test_helper.rb
42
+
43
+ This contains the supercool [defunkt's](http://twitter.com/defunkt) [test/spec/mini](https://gist.github.com/307649)
44
+
45
+ ### test/project_test.rb
46
+
47
+ a failing test
48
+
49
+
50
+ synopsis
51
+ --------
52
+
53
+ $: mgen mycoolproject
54
+
55
+ >: - Generating your project: mycoolproject
56
+
57
+ license
58
+ -------
59
+
60
+ This program is distributed under the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl.html)
61
+
62
+ contribution and issues
63
+ -----------------------
64
+
65
+ Want to contribute?
66
+
67
+ [Fork][0] minigen
68
+
69
+ Have issues?
70
+
71
+ Create an [Issue][1]
72
+
73
+
74
+ author
75
+ ------
76
+
77
+ Gildo Fiorito (fyskij@gmail.com)
78
+
79
+ [0]: http://help.github.com/forking/
80
+ [1]: http://github.com/fyskij/minigen/issues
data/bin/mgen ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
+
4
+ require 'minigen'
5
+
6
+ Minigen::Generator.new(ARGV[0])
data/lib/minigen.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+
3
+ LIBDIR = File.dirname(__FILE__)
4
+
5
+ dir = File.dirname(File.expand_path(__FILE__))
6
+ $LOAD_PATH.unshift(File.join('minigen'))
7
+ $LOAD_PATH.unshift(dir)
8
+
9
+ require "minigen/generator"
10
+
11
+ module Minigen
12
+
13
+ VERSION = "0.0.1"
14
+
15
+ end
@@ -0,0 +1,58 @@
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 name
8
+ @name = name.downcase
9
+
10
+ # Checks if a folder exists with the name @name
11
+ # if false, exits with a message
12
+ abort "A folder with that name already exists" if File.directory? @name
13
+
14
+ # Runs the method that copies the template
15
+ copy!
16
+
17
+ end
18
+
19
+ # Private: Copies the default template to @name dir
20
+ def copy!
21
+ puts " - \033[32mGenerating\033[0m your project: #{@name}"
22
+ Dir.mkdir @name
23
+ FileUtils.cp_r( Dir.glob(File.join(LIBDIR, 'template/*')), @name )
24
+ Dir.chdir @name
25
+ Dir.glob("**/*.{rb,md,gemspec}").each {|f| ore f, "project", @name}
26
+ Dir.glob("**/*.{rb,md,gemspec}").each {|f| ore f, "Project", @name.capitalize}
27
+ File.rename "test/project_test.rb", "test/#{@name}_test.rb"
28
+ File.rename "lib/project.rb", "lib/#{@name}.rb"
29
+ File.rename "project.gemspec", "#{@name}.gemspec"
30
+ end
31
+
32
+ # Private: Opens, Reads and Edits a file
33
+ #
34
+ # file - The file to edit
35
+ # old - The term to be replaced
36
+ # new - The new term
37
+ #
38
+ # Examples
39
+ #
40
+ # ore('README.md', 'Minigen', 'Rubygems')
41
+ # # => True
42
+ #
43
+ # Returns True if everything went well :D
44
+ def ore file, old, new
45
+ o = File.read(file).gsub! /#{old}/, new
46
+ n = File.new(file, "w+")
47
+ n.puts(o)
48
+ n.close
49
+ return true
50
+ end
51
+
52
+
53
+
54
+ private :copy!, :ore
55
+
56
+ end #Generator
57
+
58
+ end #Minigen
@@ -0,0 +1,24 @@
1
+ project
2
+ =======
3
+
4
+ > mini description
5
+
6
+ installation
7
+ ------------
8
+
9
+ $: [sudo] gem install project
10
+
11
+ description
12
+ -----------
13
+
14
+
15
+ license
16
+ -------
17
+
18
+ This program is distributed under GPL
19
+
20
+ contribution and issues
21
+ -----------------------
22
+
23
+ author
24
+ ------
@@ -0,0 +1,9 @@
1
+ dir = File.dirname(File.expand_path(__FILE__))
2
+ $LOAD_PATH.unshift(File.join('project'))
3
+ $LOAD_PATH.unshift(dir)
4
+
5
+ module Project
6
+
7
+ VERSION = "0.0.0"
8
+
9
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path("../lib/project", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+
5
+ s.name = 'project'
6
+ s.version = Project::VERSION
7
+
8
+ s.summary = ""
9
+ s.description = ""
10
+
11
+ s.authors = [""]
12
+ s.homepage = ''
13
+
14
+ s.require_paths = %w[lib]
15
+ s.files = %w( README.md )
16
+ s.files += Dir.glob("lib/**/*")
17
+ s.files += Dir.glob("test/*")
18
+
19
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
20
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ context "Project" do
4
+
5
+ test "this test fails" do
6
+ assert_equal 0, 1
7
+ end
8
+
9
+ end
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'project'
4
+
5
+ ##
6
+ # test/spec/mini 5
7
+ # http://gist.github.com/307649
8
+ # chris@ozmm.org
9
+ #
10
+ def context(*args, &block)
11
+ return super unless (name = args.first) && block
12
+ require 'test/unit'
13
+ klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
14
+ def self.test(name, &block)
15
+ define_method("test_#{name.to_s.gsub(/\W/,'_')}", &block) if block
16
+ end
17
+ def self.xtest(*args) end
18
+ def self.context(*args, &block) instance_eval(&block) end
19
+ def self.setup(&block)
20
+ define_method(:setup) { self.class.setups.each { |s| instance_eval(&s) } }
21
+ setups << block
22
+ end
23
+ def self.setups; @setups ||= [] end
24
+ def self.teardown(&block) define_method(:teardown, &block) end
25
+ end
26
+ (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
27
+ klass.class_eval &block
28
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ context "Minigen" do
4
+
5
+ context "generator" do
6
+ setup do
7
+ @project = "simplegem"
8
+ Minigen::Generator.new(@project)
9
+ end
10
+
11
+ test "dir exists" do
12
+ assert File.directory? @project
13
+ end
14
+
15
+ test "files exists" do
16
+ Dir.chdir @project
17
+ assert File.exist? "README.md"
18
+ assert File.exist? "test/#{@project}_test.rb"
19
+ assert File.exist? "test/test_helper.rb"
20
+ assert File.exist? "#{@project}.gemspec"
21
+ assert File.exist? "lib/#{@project}.rb"
22
+ end
23
+
24
+ test "correct names in files" do
25
+ Dir.chdir("#{@project}")
26
+ assert ref "#{@project}.gemspec" @project.to_s
27
+ end
28
+
29
+ end
@@ -0,0 +1,37 @@
1
+ begin; require 'turn'; rescue LoadError; end
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ require 'minigen'
5
+
6
+ ##
7
+ # test/spec/mini 5
8
+ # http://gist.github.com/307649
9
+ # chris@ozmm.org
10
+ #
11
+ def context(*args, &block)
12
+ return super unless (name = args.first) && block
13
+ require 'test/unit'
14
+ klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
15
+ def self.test(name, &block)
16
+ define_method("test_#{name.to_s.gsub(/\W/,'_')}", &block) if block
17
+ end
18
+ def self.xtest(*args) end
19
+ def self.context(*args, &block) instance_eval(&block) end
20
+ def self.setup(&block)
21
+ define_method(:setup) { self.class.setups.each { |s| instance_eval(&s) } }
22
+ setups << block
23
+ end
24
+ def self.setups; @setups ||= [] end
25
+ def self.teardown(&block) define_method(:teardown, &block) end
26
+ end
27
+ (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
28
+ klass.class_eval &block
29
+ end
30
+
31
+ #
32
+ # Opens the file, reads the file, splits the file,
33
+ # and searches for a term in the array
34
+ #
35
+ def ref(f,t)
36
+ File.read(f).split("\n").grep /#{t}/
37
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minigen
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Ermenegildo Fiorito
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-02-10 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: a project generator that creates a simple ruby library skel
18
+ email:
19
+ executables:
20
+ - mgen
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - README.md
27
+ - lib/minigen/generator.rb
28
+ - lib/minigen.rb
29
+ - lib/template/test/project_test.rb
30
+ - lib/template/test/test_helper.rb
31
+ - lib/template/README.md
32
+ - lib/template/lib/project.rb
33
+ - lib/template/project.gemspec
34
+ - test/test_helper.rb
35
+ - test/minigen_test.rb
36
+ - bin/mgen
37
+ has_rdoc: true
38
+ homepage: http://github.com/fyskij/minigen#readme
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.5.0
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: just another projects generator
65
+ test_files:
66
+ - test/test_helper.rb