prigner 0.1.1 → 0.2.0

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.
Files changed (36) hide show
  1. data/CHANGELOG +29 -0
  2. data/README.rdoc +32 -42
  3. data/Rakefile +12 -8
  4. data/lib/prigner/builder.rb +8 -3
  5. data/lib/prigner/cli/new.rb +30 -8
  6. data/lib/prigner/cli.rb +1 -2
  7. data/lib/prigner/extensions.rb +14 -2
  8. data/lib/prigner/template.rb +31 -7
  9. data/lib/prigner.rb +2 -2
  10. data/prigner.gemspec +14 -5
  11. data/share/templates/bash/default/models/script.sh +45 -0
  12. data/share/templates/bash/default/models/scriptrc +2 -0
  13. data/share/templates/bash/default/specfile +18 -0
  14. data/share/templates/ruby/default/models/executable +23 -0
  15. data/share/templates/ruby/default/models/testhelper.rb +23 -0
  16. data/share/templates/ruby/default/specfile +20 -4
  17. data/share/templates/ruby/gem/models/README.rdoc +4 -0
  18. data/share/templates/ruby/gem/models/Rakefile +81 -148
  19. data/share/templates/ruby/gem/models/cli.rb +43 -0
  20. data/share/templates/ruby/gem/models/executable +23 -0
  21. data/share/templates/ruby/gem/models/gemspec +10 -8
  22. data/share/templates/ruby/gem/models/module.rb +24 -9
  23. data/share/templates/ruby/gem/models/testhelper.rb +23 -0
  24. data/share/templates/ruby/gem/specfile +20 -8
  25. data/test/builder_test.rb +15 -0
  26. data/test/fixtures/templates/shared/templates/ruby/default/models/cli.rb +0 -0
  27. data/test/fixtures/templates/shared/templates/ruby/default/models/executable +23 -0
  28. data/test/fixtures/templates/shared/templates/ruby/default/models/testhelper.rb +0 -0
  29. data/test/fixtures/templates/shared/templates/ruby/default/specfile +21 -9
  30. data/test/helpers.rb +8 -8
  31. data/test/spec_test.rb +18 -4
  32. data/test/template_test.rb +21 -6
  33. metadata +19 -10
  34. data/share/templates/ruby/gem/models/README.mkd +0 -5
  35. data/share/templates/ruby/gem/models/empty_test.rb +0 -16
  36. data/test/fixtures/templates/shared/templates/ruby/default/README.mkd +0 -2
data/test/helpers.rb CHANGED
@@ -27,7 +27,7 @@ module Test::HTTPUtils
27
27
  require "webrick"
28
28
 
29
29
  def localhost_ip
30
- raise "Please, set the HOSTIP variable for tests" unless ENV["HOSTIP"]
30
+ abort "Please, set the HOSTIP variable for tests" if ENV["HOSTIP"].nil?
31
31
  @localhost_ip ||= ENV["HOSTIP"]
32
32
  end
33
33
 
@@ -41,16 +41,16 @@ module Test::HTTPUtils
41
41
  end
42
42
 
43
43
  def webrick(&block)
44
- @pid = fork do
45
- server = WEBrick::HTTPServer.new(self.config)
46
- thread = Thread.new { server.start }
44
+ @server = WEBrick::HTTPServer.new(self.config)
45
+ @pid = fork do
46
+ @thread = Thread.new do
47
+ @server.start
48
+ end
47
49
  trap "INT" do
48
- server.shutdown
50
+ @server.shutdown
49
51
  end
50
- thread.join
52
+ @thread.join
51
53
  end
52
- yield
53
- ensure
54
54
  system "kill -INT #{@pid}" if @pid
55
55
  end
56
56
 
data/test/spec_test.rb CHANGED
@@ -13,7 +13,21 @@ class SpecTest < Test::Unit::TestCase
13
13
  }
14
14
  @options = {
15
15
  "svn" => "Include Subversion keywords in code.",
16
- "git" => "Enable Git flags in templates."
16
+ "git" => "Enable Git flags in templates.",
17
+ "bin" => {
18
+ "description" => "Include executable file in bin/<name>.",
19
+ "files" => {
20
+ "executable" => "bin/(project)",
21
+ "cli.rb" => "lib/(project)/cli.rb"
22
+ }
23
+ },
24
+ "test" => {
25
+ "description" => "Include test files.",
26
+ "files" => {
27
+ "empty_test.rb" => "test/(project)_test.rb",
28
+ "testhelper.rb" => "test/helper.rb"
29
+ }
30
+ }
17
31
  }
18
32
  @directories = [
19
33
  "test/fixtures",
@@ -22,13 +36,12 @@ class SpecTest < Test::Unit::TestCase
22
36
  @files = {
23
37
  "README.mkd" => nil,
24
38
  "module.rb" => "lib/(project).rb",
25
- "empty_test.rb" => "test/(project)_test.rb"
26
39
  }
27
40
  specfile = "#{FIXTURES}/templates/shared/templates/ruby/default/specfile"
28
41
  @spec = Prigner::Spec.load(specfile)
29
42
  end
30
43
 
31
- should "check basic informatio about template" do
44
+ should "check basic information about template" do
32
45
  @info.each do |attribute, value|
33
46
  assert_equal value, @spec.send(attribute)
34
47
  end
@@ -37,7 +50,8 @@ class SpecTest < Test::Unit::TestCase
37
50
 
38
51
  %w{options files}.each do |checker|
39
52
  instance_variable_get("@#{checker}").each do |attribute, value|
40
- assert_equal value, @spec.send(checker)[attribute]
53
+ checking = @spec.send(checker)[attribute]
54
+ assert_equal value, checking
41
55
  end
42
56
  end
43
57
  end
@@ -2,7 +2,6 @@ require "test/unit"
2
2
  require "test/helpers"
3
3
  require "lib/prigner"
4
4
 
5
-
6
5
  def Prigner.shared_path
7
6
  [ "#{ENV['HOME']}/.prigner/templates",
8
7
  "#{FIXTURES}/templates/shared/templates" ]
@@ -12,8 +11,9 @@ class TemplateTest < Test::Unit::TestCase
12
11
 
13
12
  def setup
14
13
  @options = {
15
- :svn => "Include Subversion keywords in code.",
16
- :git => "Enable Git flags in templates."
14
+ :svn => { :description => "Include Subversion keywords in code." },
15
+ :git => { :description => "Enable Git flags in templates." },
16
+ :bin => { :description => "Include executable file in bin/<name>." }
17
17
  }
18
18
  @path = "#{FIXTURES}/templates/shared/templates/ruby/default"
19
19
  @project_path = "#{FIXTURES}/project/foo"
@@ -30,8 +30,12 @@ class TemplateTest < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  should "load options" do
33
- @options.keys.each do |option|
34
- assert_equal @options[option], @template.options[option].description
33
+ template = Prigner::Template.load(:ruby)
34
+ @options.each do |option, members|
35
+ members.each do |name, value|
36
+ assert_equal value, @template.options[option].send(name)
37
+ assert_equal value, template.options[option].send(name)
38
+ end
35
39
  end
36
40
  end
37
41
 
@@ -56,7 +60,7 @@ class TemplateTest < Test::Unit::TestCase
56
60
 
57
61
  should "check number of models and directories" do
58
62
  assert_equal 2, @template.directories.size
59
- assert_equal 3, @template.models.size, "Models size not matched"
63
+ assert_equal 2, @template.models[:required].size
60
64
  end
61
65
 
62
66
  should "list all template paths from shared path" do
@@ -82,5 +86,16 @@ class TemplateTest < Test::Unit::TestCase
82
86
  end
83
87
  end
84
88
 
89
+ should "initialize all optional models" do
90
+ [:bin, :test].each do |option|
91
+ assert @template.options.respond_to?(option)
92
+ @template.initialize_models_for_option(option)
93
+ assert_equal 2, @template.models[option].size
94
+ @template.models[option].each do |model, file|
95
+ assert model.path.exist?
96
+ end
97
+ end
98
+ end
99
+
85
100
  end
86
101
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prigner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hallison Batista
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-21 00:00:00 -04:00
18
+ date: 2010-10-27 00:00:00 -04:00
19
19
  default_executable: prign
20
20
  dependencies: []
21
21
 
@@ -46,26 +46,35 @@ files:
46
46
  - lib/prigner/project.rb
47
47
  - lib/prigner/template.rb
48
48
  - prigner.gemspec
49
+ - share/templates/bash/default/models/script.sh
50
+ - share/templates/bash/default/models/scriptrc
51
+ - share/templates/bash/default/specfile
49
52
  - share/templates/ruby/default/models/CHANGELOG
50
53
  - share/templates/ruby/default/models/COPYING
51
54
  - share/templates/ruby/default/models/README.rdoc
55
+ - share/templates/ruby/default/models/executable
52
56
  - share/templates/ruby/default/models/module.rb
57
+ - share/templates/ruby/default/models/testhelper.rb
53
58
  - share/templates/ruby/default/specfile
54
59
  - share/templates/ruby/gem/models/CHANGELOG
55
60
  - share/templates/ruby/gem/models/COPYING
56
- - share/templates/ruby/gem/models/README.mkd
61
+ - share/templates/ruby/gem/models/README.rdoc
57
62
  - share/templates/ruby/gem/models/Rakefile
58
- - share/templates/ruby/gem/models/empty_test.rb
63
+ - share/templates/ruby/gem/models/cli.rb
64
+ - share/templates/ruby/gem/models/executable
59
65
  - share/templates/ruby/gem/models/gemspec
60
66
  - share/templates/ruby/gem/models/module.rb
67
+ - share/templates/ruby/gem/models/testhelper.rb
61
68
  - share/templates/ruby/gem/specfile
62
69
  - test/builder_test.rb
63
70
  - test/fixtures/model.rb.erb
64
- - test/fixtures/templates/shared/templates/ruby/default/README.mkd
65
71
  - test/fixtures/templates/shared/templates/ruby/default/models/README.mkd
66
72
  - test/fixtures/templates/shared/templates/ruby/default/models/Rakefile
73
+ - test/fixtures/templates/shared/templates/ruby/default/models/cli.rb
67
74
  - test/fixtures/templates/shared/templates/ruby/default/models/empty_test.rb
75
+ - test/fixtures/templates/shared/templates/ruby/default/models/executable
68
76
  - test/fixtures/templates/shared/templates/ruby/default/models/module.rb
77
+ - test/fixtures/templates/shared/templates/ruby/default/models/testhelper.rb
69
78
  - test/fixtures/templates/shared/templates/ruby/default/specfile
70
79
  - test/fixtures/templates/shared/templates/ruby/sinatra/models/README.mkd
71
80
  - test/fixtures/templates/shared/templates/ruby/sinatra/models/Rakefile
@@ -93,7 +102,7 @@ licenses: []
93
102
 
94
103
  post_install_message: |
95
104
  ------------------------------------------------------------------------------
96
- Prigner v0.1.1
105
+ Prigner v0.2.0
97
106
 
98
107
  Thanks for use Prigner. See all shared templates running:
99
108
 
@@ -108,7 +117,7 @@ rdoc_options:
108
117
  - --main
109
118
  - Prigner
110
119
  - --title
111
- - Prigner v0.1.1 API Documentation
120
+ - Prigner v0.2.0 API Documentation
112
121
  require_paths:
113
122
  - lib
114
123
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,5 +0,0 @@
1
- <%=project.class_name%>
2
- <%="="*project.class_name.size%>
3
-
4
- This is my great Ruby project.
5
-
@@ -1,16 +0,0 @@
1
- require "test/unit"
2
- require "test/helpers"
3
- require "lib/<%=project.name%>"
4
-
5
- class <%=project.class_name%>Test < Test::Unit::TestCase
6
-
7
- def setup
8
- # start here
9
- end
10
-
11
- should "check the truth" do
12
- assert true
13
- end
14
-
15
- end
16
-