rmm5t-yarg 0.1.0 → 0.1.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.markdown CHANGED
@@ -1,7 +1,8 @@
1
1
  # yarg: Yet Another Ruby Generator
2
2
 
3
3
  Yarg is Yet Another Ruby Generator. It allows you to customize existing project
4
- generators to fit your personality or common scaffolding.
4
+ generators to fit your personality or common scaffolding. In other words, it
5
+ allows you to bootstrap new projects without the typical mundane setup.
5
6
 
6
7
  **Yarg is still in its infancy. It currently works for rails generation, but use it at your own risk.**
7
8
 
@@ -9,23 +10,21 @@ generators to fit your personality or common scaffolding.
9
10
 
10
11
  Install:
11
12
 
12
- gem install rmm5t-yarg --source http://gems.github.com
13
+ $ sudo gem install rmm5t-yarg --source http://gems.github.com
13
14
 
14
15
  Configure by placing a <tt>~/.yarg</tt> file in your home directory. Here's a simple example
15
16
 
16
17
  Yarg::Rails.new do |rg|
17
18
  rg.scm :git
18
19
  rg.delete "public/index.html"
19
- rg.delete "public/dispatch.*"
20
20
  rg.plugin "git://github.com/thoughtbot/shoulda.git"
21
- rg.plugin "git://github.com/nex3/haml.git"
22
- rg.freeze
23
21
  end
24
22
 
25
23
  Here's another example:
26
24
 
27
25
  Yarg::Rails.new do |rg|
28
26
  rg.scm :git, :using => :submodules
27
+ rg.template "~/.yarg.d/rails"
29
28
  rg.delete "public/index.html"
30
29
  rg.delete "public/dispatch.*"
31
30
  rg.plugin "git://github.com/thoughtbot/shoulda.git"
@@ -35,10 +34,14 @@ Here's another example:
35
34
  rg.freeze :version => :edge
36
35
  end
37
36
 
37
+ Afterwards, you should be able to launch a new Rails project easily:
38
+
39
+ $ yarg my_new_project
40
+
38
41
  ## TODO
39
42
 
40
- * Add better option parsing support in script
41
- * Add template directory support
43
+ * Add better option parsing support in script (including a template name option)
44
+ * Add better handling of error conditions
42
45
  * Add rails gem freezing support
43
46
  * Add newgem support
44
47
  * Add merb support
@@ -44,7 +44,10 @@ module Yarg
44
44
  end
45
45
 
46
46
  def apply_templates
47
- # TODO
47
+ self.templates.each do |path|
48
+ sources = Dir.glob(File.join(File.expand_path(path), "*"))
49
+ FileUtils.cp_r(sources, ".", :verbose => true)
50
+ end
48
51
  end
49
52
 
50
53
  def apply_scm_init
data/lib/yarg.rb CHANGED
@@ -3,7 +3,7 @@ require 'rake/tasklib'
3
3
  #require 'active_support'
4
4
 
5
5
  module Yarg
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.1"
7
7
 
8
8
  class Error < RuntimeError; end
9
9
  end
@@ -76,13 +76,27 @@ class FileActionsTest < Test::Unit::TestCase
76
76
  end
77
77
  end
78
78
 
79
- private
79
+ context "A Fake generator with a template" do
80
+ setup do
81
+ @generator = FakeGen.new do |rg|
82
+ rg.template "/tmp/.yarg.d/rails"
83
+ end
84
+ stub_fake_system_calls("my_app")
85
+ end
86
+
87
+ should_have_generator_attribute_of :templates, %w(/tmp/.yarg.d/rails)
80
88
 
81
- def stub_fake_system_calls(project_name)
82
- ENV["PROJECT_NAME"] = project_name
83
- @generator.stubs(:sh)
84
- Dir.stubs(:mkdir)
85
- Dir.stubs(:chdir)
86
- File.stubs(:delete)
89
+ context "once invoked" do
90
+ setup do
91
+ Rake::Task[:fake].invoke
92
+ end
93
+
94
+ should_cd_into "my_app"
95
+ should_not_delete_any_files
96
+
97
+ before_should "copy template files from" do
98
+ FileUtils.expects(:cp_r).with(["/tmp/.yarg.d/rails"], ".", :verbose => true)
99
+ end
100
+ end
87
101
  end
88
102
  end
data/test/rails_test.rb CHANGED
@@ -13,7 +13,7 @@ class RailsTest < Test::Unit::TestCase
13
13
  context "An empty default Rails generator" do
14
14
  setup do
15
15
  @generator = Yarg::Rails.new do |rg| end
16
- stub_rails_system_calls("my_app")
16
+ stub_fake_system_calls("my_app")
17
17
  end
18
18
 
19
19
  should_define_task :rails
@@ -46,10 +46,10 @@ class RailsTest < Test::Unit::TestCase
46
46
  rg.delete "public/dispatch.*"
47
47
  rg.plugin "git://github.com/thoughtbot/shoulda.git"
48
48
  rg.plugin "git://github.com/nex3/haml.git"
49
- rg.template "~/.yarg.d/rails"
49
+ rg.template "/tmp/.yarg.d/rails"
50
50
  rg.freeze :version => :edge
51
51
  end
52
- stub_rails_system_calls("my_rails_project")
52
+ stub_fake_system_calls("my_rails_project")
53
53
  end
54
54
 
55
55
  should_define_task :template
@@ -57,7 +57,7 @@ class RailsTest < Test::Unit::TestCase
57
57
  should_have_generator_attribute_of :scm_module, Yarg::Scm::Git
58
58
  should_have_generator_attribute_of :deletions, %w(public/index.html public/dispatch.*)
59
59
  should_have_generator_attribute_of :plugins, %w(git://github.com/thoughtbot/shoulda.git git://github.com/nex3/haml.git)
60
- should_have_generator_attribute_of :templates, %w(~/.yarg.d/rails)
60
+ should_have_generator_attribute_of :templates, %w(/tmp/.yarg.d/rails)
61
61
  should_have_generator_attribute_of :frozen, true
62
62
  should_have_generator_attribute_of :freeze_version, :edge
63
63
 
@@ -85,7 +85,7 @@ class RailsTest < Test::Unit::TestCase
85
85
  @generator = Yarg::Rails.new do |rg|
86
86
  rg.freeze
87
87
  end
88
- stub_rails_system_calls("my_app")
88
+ stub_fake_system_calls("my_app")
89
89
  end
90
90
 
91
91
  should_have_generator_attribute_of :frozen, true
@@ -111,7 +111,7 @@ class RailsTest < Test::Unit::TestCase
111
111
  rg.plugin "git://github.com/nex3/haml.git"
112
112
  rg.freeze :version => :edge
113
113
  end
114
- stub_rails_system_calls("my_app")
114
+ stub_fake_system_calls("my_app")
115
115
  end
116
116
 
117
117
  should_have_generator_attribute_of :scm_module, Yarg::Scm::Git
@@ -128,16 +128,4 @@ class RailsTest < Test::Unit::TestCase
128
128
  should_invoke %r{^git commit}
129
129
  end
130
130
  end
131
-
132
- private
133
-
134
- def stub_rails_system_calls(app_name)
135
- ENV["PROJECT_NAME"] = app_name
136
- @generator.stubs(:sh)
137
- Dir.stubs(:chdir)
138
- Dir.stubs(:glob)
139
- Dir.stubs(:glob).with("public/index.html").returns(%w(public/index.html))
140
- Dir.stubs(:glob).with("public/dispatch.*").returns(%w(public/dispatch.cgi public/dispatch.fcgi public/dispatch.rb))
141
- File.stubs(:delete)
142
- end
143
131
  end
data/test/test_helper.rb CHANGED
@@ -69,4 +69,17 @@ end
69
69
 
70
70
  class Test::Unit::TestCase
71
71
  extend ShouldaHelper::Macros
72
+
73
+ def stub_fake_system_calls(project_name)
74
+ ENV["PROJECT_NAME"] = project_name
75
+ @generator.stubs(:sh)
76
+ Dir.stubs(:mkdir)
77
+ Dir.stubs(:chdir)
78
+ Dir.stubs(:glob)
79
+ Dir.stubs(:glob).with("public/index.html").returns(%w(public/index.html))
80
+ Dir.stubs(:glob).with("public/dispatch.*").returns(%w(public/dispatch.cgi public/dispatch.fcgi public/dispatch.rb))
81
+ Dir.stubs(:glob).with("/tmp/.yarg.d/rails/*").returns(["/tmp/.yarg.d/rails"])
82
+ File.stubs(:delete)
83
+ FileUtils.stubs(:cp_r)
84
+ end
72
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmm5t-yarg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan McGeary
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-12 00:00:00 -08:00
12
+ date: 2008-11-13 00:00:00 -08:00
13
13
  default_executable: yarg
14
14
  dependencies: []
15
15