rabal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/COPYING +339 -0
  2. data/LICENSE +54 -0
  3. data/README +172 -0
  4. data/README.PLUGIN +276 -0
  5. data/bin/rabal +12 -0
  6. data/lib/rabal/action_tree.rb +42 -0
  7. data/lib/rabal/application.rb +209 -0
  8. data/lib/rabal/directory_tree.rb +59 -0
  9. data/lib/rabal/error.rb +7 -0
  10. data/lib/rabal/file_tree.rb +89 -0
  11. data/lib/rabal/logger.rb +18 -0
  12. data/lib/rabal/plugin/bin.rb +8 -0
  13. data/lib/rabal/plugin/core.rb +24 -0
  14. data/lib/rabal/plugin/foundation.rb +154 -0
  15. data/lib/rabal/plugin/license.rb +36 -0
  16. data/lib/rabal/plugin/spec.rb +8 -0
  17. data/lib/rabal/plugin/test.rb +8 -0
  18. data/lib/rabal/plugin.rb +5 -0
  19. data/lib/rabal/plugin_tree.rb +61 -0
  20. data/lib/rabal/project_tree.rb +17 -0
  21. data/lib/rabal/tree.rb +231 -0
  22. data/lib/rabal/usage.rb +100 -0
  23. data/lib/rabal/util.rb +62 -0
  24. data/lib/rabal/version.rb +18 -0
  25. data/lib/rabal.rb +49 -0
  26. data/resources/trees/bin/rabal.project +10 -0
  27. data/resources/trees/core/CHANGES +4 -0
  28. data/resources/trees/core/README +15 -0
  29. data/resources/trees/core/Rakefile +0 -0
  30. data/resources/trees/core/lib/rabal.project/version.rb.erb +17 -0
  31. data/resources/trees/core/lib/rabal.project.rb.erb +27 -0
  32. data/resources/trees/license/COPYING.gpl +339 -0
  33. data/resources/trees/license/COPYING.lgpl +504 -0
  34. data/resources/trees/license/COPYING.ruby +339 -0
  35. data/resources/trees/license/LICENSE.bsd +31 -0
  36. data/resources/trees/license/LICENSE.mit +19 -0
  37. data/resources/trees/license/LICENSE.ruby +54 -0
  38. data/resources/trees/spec/rabal.project_spec.rb.erb +16 -0
  39. data/resources/trees/spec/spec_helper.rb.erb +5 -0
  40. data/resources/trees/test/rabal.project_test.rb.erb +10 -0
  41. data/resources/trees/test/test_helper.rb.erb +3 -0
  42. data/spec/action_tree_spec.rb +28 -0
  43. data/spec/bin_plugin_spec.rb +23 -0
  44. data/spec/core_plugin_spec.rb +29 -0
  45. data/spec/directory_tree_spec.rb +28 -0
  46. data/spec/file_tree_spec.rb +48 -0
  47. data/spec/license_plugin_spec.rb +39 -0
  48. data/spec/plugin_tree_spec.rb +53 -0
  49. data/spec/project_tree_spec.rb +39 -0
  50. data/spec/spec_helper.rb +59 -0
  51. data/spec/spec_plugin_spec.rb +23 -0
  52. data/spec/test_plugin_spec.rb +23 -0
  53. data/spec/tree_spec.rb +80 -0
  54. data/spec/utils_spec.rb +45 -0
  55. data/spec/version_spec.rb +26 -0
  56. metadata +134 -0
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+ describe Rabal::Plugin::License do
3
+ before(:each) do
4
+ @working_dir = my_temp_dir
5
+ @before = Dir.pwd
6
+ @core = Rabal::Plugin::Core.new({:project => "new-spec-proj", :author => "Foo Bar", :email => "foobar@example.com"})
7
+ @base_tree = Set.new(%w(README Rakefile CHANGES COPYING LICENSE lib lib/new-spec-proj lib/new_spec_proj.rb lib/new-spec-proj/version.rb))
8
+ Dir.chdir(@working_dir)
9
+ end
10
+
11
+ after(:each) do
12
+ Dir.chdir(@before)
13
+ FileUtils.rm_rf @working_dir
14
+ end
15
+
16
+ it "should raise an error if the flavor is missing" do
17
+ lambda { Rabal::Plugin::License.new({}) }.should raise_error(PluginParameterMissingError)
18
+ end
19
+
20
+ it "should create a valid tree structure" do
21
+ lic = Rabal::Plugin::License.new({:flavor => "BSD"})
22
+ @core.tree << lic.tree
23
+ @core.tree.process
24
+ find_in("new-spec-proj").sort.should be_include("LICENSE")
25
+ end
26
+
27
+ it "should create a valid tree structure with COPYING and LICENSE for ruby" do
28
+ lic = Rabal::Plugin::License.new({:flavor => "Ruby"})
29
+ @core.tree << lic.tree
30
+ @core.tree.process
31
+ find_in("new-spec-proj").sort.should == @base_tree.sort
32
+ end
33
+
34
+
35
+ it "should raise an error if the flavor is incorrect" do
36
+ lambda { Rabal::Plugin::License.new({:flavor => "BLAH"}) }.should raise_error(PluginParameterMissingError)
37
+ end
38
+
39
+ end
@@ -0,0 +1,53 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+
3
+ require 'find'
4
+ require 'set'
5
+ describe Rabal::PluginTree do
6
+ before(:each) do
7
+ @working_dir = my_temp_dir
8
+ @tree = ProjectTree.new('new-spec-proj', {:author => "Some Author", :email => "author@example.com"})
9
+ @tree << PluginTree.new({:data1 => "some_data" },resource_handle("core"))
10
+
11
+ @base_tree = Set.new(%w(README Rakefile CHANGES lib lib/new-spec-proj lib/new_spec_proj.rb lib/new-spec-proj/version.rb))
12
+
13
+ @before = Dir.pwd
14
+ Dir.chdir(@working_dir)
15
+ end
16
+
17
+ after(:each) do
18
+ Dir.chdir(@before)
19
+ FileUtils.rm_rf @working_dir
20
+ end
21
+
22
+ it "should create a basic project" do
23
+ @tree.process
24
+ find_in("new-spec-proj").sort.should == @base_tree.sort
25
+ end
26
+
27
+ it "should allow for insertion into the Plugin Tree" do
28
+ @tree << PluginTree.new({},resource_handle("test"),"test")
29
+ @tree.process
30
+ find_in('new-spec-proj').sort.should == (@base_tree + %w(test test/new_spec_proj_test.rb test/test_helper.rb)).sort
31
+ end
32
+
33
+ it "should allow for insertion into the Plugin Tree somewhere other than the root" do
34
+ d1 = DirectoryTree.new("misc")
35
+ d1 << DirectoryTree.new("stuff")
36
+ @tree << d1
37
+ d1d2 = %w(misc misc/stuff)
38
+
39
+ @tree.add_at_path("misc/stuff", PluginTree.new({},resource_handle("spec"),"spec"))
40
+ spec = %w(misc/stuff/spec misc/stuff/spec/spec_helper.rb misc/stuff/spec/new_spec_proj_spec.rb)
41
+
42
+ @tree.process
43
+ find_in('new-spec-proj').sort.should == (@base_tree + d1d2 + spec).sort
44
+ end
45
+
46
+ it "should raise an exception if an attempt is made to add to a location that does not exist" do
47
+ d = DirectoryTree.new("foo")
48
+ d << DirectoryTree.new("bar")
49
+ d.children["bar"] << DirectoryTree.new("baz")
50
+ @tree << d
51
+ lambda { @tree.add_at_path("foo/bar/blah", DirectoryTree.new("lkj")) }.should raise_error(PathNotFoundError)
52
+ end
53
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+ describe ProjectTree do
3
+ before(:each) do
4
+ @proj_tree = ProjectTree.new("spec-test",{ :author => "Foo Bar",:email => "foo@example.com"})
5
+ @working_dir = my_temp_dir
6
+ @before = Dir.pwd
7
+ Dir.chdir(@working_dir)
8
+ end
9
+
10
+ after(:each) do
11
+ Dir.chdir(@before)
12
+ FileUtils.rm_rf @working_dir
13
+ end
14
+
15
+ it "should have a project name" do
16
+ @proj_tree.project_name.should == "spec-test"
17
+ end
18
+
19
+ it "should have an author " do
20
+ @proj_tree.author.should == "Foo Bar"
21
+ end
22
+
23
+ it "should have an email " do
24
+ @proj_tree.email.should == "foo@example.com"
25
+ end
26
+
27
+ it "should create a project under the working directory" do
28
+ @proj_tree.process
29
+ File.directory?(File.join(@working_dir,"spec-test")).should == true
30
+ end
31
+
32
+ it "should do nothing if the Project already exists" do
33
+ d = File.join(@working_dir,"spec-test")
34
+ Dir.mkdir(d)
35
+ x = File.directory?(d)
36
+ @proj_tree.process
37
+ File.directory?(d).should == x
38
+ end
39
+ end
@@ -0,0 +1,59 @@
1
+ begin
2
+ require 'rabal'
3
+ rescue LoadError
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
+ require 'rabal'
6
+ end
7
+ require 'rubygems'
8
+ require 'tmpdir'
9
+ require 'mktemp'
10
+ require 'fileutils'
11
+
12
+ include Rabal
13
+
14
+ # generate a temporary directory and create it
15
+
16
+ def my_temp_dir
17
+ MkTemp.mktempdir(File.join(Dir.tmpdir,"rabal-spec.XXXXXXXX"))
18
+ end
19
+
20
+ # return a list of all the files and directories in a location
21
+ # minus anything leading up to that directory in the path
22
+ def find_in(path)
23
+ found = Set.new
24
+ path = path.chomp("/") + "/"
25
+ path = path.reverse.chomp(".").chomp("/").reverse
26
+ Find.find(path) do |f|
27
+ if File.file?(f) or File.directory?(f) then
28
+ f.gsub!(/\A#{path}/,"")
29
+ next if f.size == 0
30
+ found << f
31
+ end
32
+ end
33
+ found
34
+ end
35
+
36
+ def resource_tree_dir
37
+ File.expand_path(File.join(File.dirname(__FILE__),'..',"resources","trees"))
38
+ end
39
+
40
+ def resource_handle(item)
41
+ File.join(resource_tree_dir,item)
42
+ end
43
+
44
+
45
+ #
46
+ # Tree used to validate that actions are called
47
+ #
48
+ class ValidatingActionTree < ActionTree
49
+ @@action_count = 0
50
+ class << self
51
+ def action_count
52
+ @@action_count
53
+ end
54
+ end
55
+ def action
56
+ @@action_count += 1
57
+ end
58
+ end
59
+
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+ describe Rabal::Plugin::Spec do
3
+ before(:each) do
4
+ @app = Rabal.application
5
+ @working_dir = my_temp_dir
6
+ @before = Dir.pwd
7
+ @core = Rabal::Plugin::Core.new({:project => "new-spec-proj", :author => "Foo Bar", :email => "foobar@example.com"})
8
+ @base_tree = Set.new(%w(README Rakefile CHANGES lib lib/new-spec-proj lib/new_spec_proj.rb lib/new-spec-proj/version.rb spec spec/new_spec_proj_spec.rb spec/spec_helper.rb))
9
+ Dir.chdir(@working_dir)
10
+ end
11
+
12
+ after(:each) do
13
+ Dir.chdir(@before)
14
+ FileUtils.rm_rf @working_dir
15
+ end
16
+
17
+ it "should produce a valid bin directory and executable " do
18
+ spec_plugin = Rabal::Plugin::Spec.new({})
19
+ @core.tree << spec_plugin.tree
20
+ @core.tree.process
21
+ find_in("new-spec-proj").sort.should == @base_tree.sort
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+ describe Rabal::Plugin::Test do
3
+ before(:each) do
4
+ @app = Rabal.application
5
+ @working_dir = my_temp_dir
6
+ @before = Dir.pwd
7
+ @core = Rabal::Plugin::Core.new({:project => "new-spec-proj", :author => "Foo Bar", :email => "foobar@example.com"})
8
+ @base_tree = Set.new(%w(README Rakefile CHANGES lib lib/new-spec-proj lib/new_spec_proj.rb lib/new-spec-proj/version.rb test test/new_spec_proj_test.rb test/test_helper.rb))
9
+ Dir.chdir(@working_dir)
10
+ end
11
+
12
+ after(:each) do
13
+ Dir.chdir(@before)
14
+ FileUtils.rm_rf @working_dir
15
+ end
16
+
17
+ it "should produce a valid bin directory and executable " do
18
+ test_plugin = Rabal::Plugin::Test.new({})
19
+ @core.tree << test_plugin.tree
20
+ @core.tree.process
21
+ find_in("new-spec-proj").sort.should == @base_tree.sort
22
+ end
23
+ end
data/spec/tree_spec.rb ADDED
@@ -0,0 +1,80 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+
3
+ describe Tree do
4
+ before(:each) do
5
+ @tree = Tree.new("root")
6
+ @blank_tree = Tree.new("blank")
7
+ @tree_with_leaves = Tree.new("root")
8
+ @tree_with_leaves << Tree.new("c1")
9
+ @tree_with_leaves << Tree.new("c2")
10
+
11
+ @tree_with_leaves.children["c1"] << Tree.new("c1-c1")
12
+ subtree = Tree.new("c1-c2")
13
+ subtree << Tree.new("c1-c2-c1")
14
+ subtree << Tree.new("c1-c2-c2")
15
+ subtree << Tree.new("c1-c2-c3")
16
+ @tree_with_leaves.children['c1'] << subtree
17
+ @tree_with_leaves.children["c1"] << Tree.new("c1-c3")
18
+ @tree_with_leaves.children["c2"] << Tree.new("c2-c1")
19
+ @tree_with_leaves.children["c1"] << Tree.new("c2-c2")
20
+ end
21
+
22
+ it "should say if it is root" do
23
+ @tree.should be_is_root
24
+ end
25
+
26
+ it "should say if it is a leaf" do
27
+ @tree.should be_is_leaf
28
+ end
29
+
30
+ it "should have 0 children when created" do
31
+ @blank_tree.children.should have(0).items
32
+ end
33
+
34
+ it "should not have a parent when created" do
35
+ @blank_tree.parent.should be_nil
36
+ end
37
+
38
+ it "should wrap children as Tree" do
39
+ @tree << "child 1"
40
+ @tree.children["child 1"].should be_kind_of(Tree)
41
+ end
42
+
43
+ it "should wrap children as Tree and data should give access to the original" do
44
+ @tree << "child 1"
45
+ @tree.children["child 1"].name.should == "child 1"
46
+ end
47
+
48
+ it "should only wrap children as Tree's if they are not already" do
49
+ @tree << Tree.new("child 1")
50
+ @tree.children["child 1"].name.should_not be_kind_of(Tree)
51
+ end
52
+
53
+ it "should be able to accept children" do
54
+ @tree << "child 1"
55
+ @tree << "child 2"
56
+ @tree.children.should have(2).items
57
+ end
58
+
59
+ it "should have the children return the parent as the root" do
60
+ child = Tree.new('child 1')
61
+ @tree << child
62
+ child.root.should == @tree
63
+ end
64
+
65
+ it "should have a size (number of nodes)" do
66
+ @tree_with_leaves.size.should == 11
67
+ end
68
+
69
+ it "should be iteratable" do
70
+ @tree_with_leaves.collect { |n| n.name }.size.should == 11
71
+ end
72
+
73
+ it "should say how deep an item is in the tree" do
74
+ @tree_with_leaves.children["c1"].children["c1-c1"].depth.should == 2
75
+ end
76
+
77
+ it "should cascade a method call up the tree" do
78
+
79
+ end
80
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+ require 'main'
3
+
4
+ describe "Utility functions" do
5
+ before(:each) do
6
+ @camel_before = %w(thisIsCamelCase ThisIsCamelCase IDoNotWantThis README Core)
7
+ @camel_final = %w(ThisIsCamelCase ThisIsCamelCase IDoNotWantThis Readme Core)
8
+
9
+ @dashed_before = %w(this-is-camel-case this-Is-camel-case i-do-nOt-want-this README core)
10
+ @dashed_final = %w(this-is-camel-case this-is-camel-case i-do-not-want-this README core)
11
+
12
+ @underscores_before = %w(this_is_Camel_Case this_is_caMel_case i_do_not_want_thiS README core)
13
+ @underscores_final = %w(this_is_camel_case this_is_camel_case i_do_not_want_this README core)
14
+ end
15
+
16
+ it "should convert camel case to dashified" do
17
+ r = @camel_before.collect { |c| c.dashify }
18
+ r.should == @dashed_final
19
+ end
20
+
21
+ it "should convert camel case to underscores" do
22
+ r = @camel_before.collect { |c| c.underscore }
23
+ r.should == @underscores_final
24
+ end
25
+
26
+ it "should convert dashes to underscores" do
27
+ r = @dashed_before.collect { |c| c.underscore }
28
+ r.should == @underscores_final
29
+ end
30
+
31
+ it "should convert dashes to camel" do
32
+ r = @dashed_before.collect { |c| c.camelize }
33
+ r.should == @camel_final
34
+ end
35
+
36
+ it "should convert underscores to camel" do
37
+ r = @underscores_before.collect { |c| c.camelize }
38
+ r.should == @camel_final
39
+ end
40
+
41
+ it "should convert underscores to dashes" do
42
+ r = @underscores_before.collect { |c| c.dashify }
43
+ r.should == @dashed_final
44
+ end
45
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper"))
2
+ describe "Rabal::Version" do
3
+ it "should have a major numbers that is >= 0" do
4
+ Rabal::Version::MAJOR.should >= 0
5
+ end
6
+
7
+ it "should have a minor number that is >= 0" do
8
+ Rabal::Version::MINOR.should >= 0
9
+ end
10
+
11
+ it "should have a build number that is >= 0" do
12
+ Rabal::Version::BUILD.should >= 0
13
+ end
14
+
15
+ it "should have an array representation" do
16
+ Rabal::Version.to_a.should have(3).items
17
+ end
18
+
19
+ it "should have a string representation" do
20
+ Rabal::Version.to_s.should match(/\d+\.\d+\.\d+/)
21
+ end
22
+
23
+ it "should be accessable as a constant" do
24
+ Rabal::VERSION.should match(/\d+\.\d+\.\d+/)
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: rabal
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-06-12 00:00:00 -06:00
8
+ summary: A tool for bootstrapping project development
9
+ require_paths:
10
+ - lib
11
+ email: jeremy@hinegardner.org
12
+ homepage: http://copiousfreetime.rubyforge.org/rabal/
13
+ rubyforge_project: copiousfreetime
14
+ description: Ruby Architecture for Building Applications and Libraries. Rabal is a commandline application for bootstrapping, packaging and distributing ruby projects.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Jeremy Hinegardner
31
+ files:
32
+ - lib/rabal.rb
33
+ - lib/rabal/util.rb
34
+ - lib/rabal/plugin/bin.rb
35
+ - lib/rabal/plugin/license.rb
36
+ - lib/rabal/plugin/core.rb
37
+ - lib/rabal/plugin/foundation.rb
38
+ - lib/rabal/plugin/spec.rb
39
+ - lib/rabal/plugin/test.rb
40
+ - lib/rabal/directory_tree.rb
41
+ - lib/rabal/application.rb
42
+ - lib/rabal/version.rb
43
+ - lib/rabal/error.rb
44
+ - lib/rabal/plugin.rb
45
+ - lib/rabal/file_tree.rb
46
+ - lib/rabal/tree.rb
47
+ - lib/rabal/plugin_tree.rb
48
+ - lib/rabal/usage.rb
49
+ - lib/rabal/logger.rb
50
+ - lib/rabal/project_tree.rb
51
+ - lib/rabal/action_tree.rb
52
+ - resources/trees
53
+ - resources/trees/ext
54
+ - resources/trees/ext/rabal.project
55
+ - resources/trees/spec
56
+ - resources/trees/spec/spec_helper.rb.erb
57
+ - resources/trees/spec/rabal.project_spec.rb.erb
58
+ - resources/trees/test
59
+ - resources/trees/test/rabal.project_test.rb.erb
60
+ - resources/trees/test/test_helper.rb.erb
61
+ - resources/trees/license
62
+ - resources/trees/license/LICENSE.ruby
63
+ - resources/trees/license/COPYING.ruby
64
+ - resources/trees/license/LICENSE.mit
65
+ - resources/trees/license/LICENSE.bsd
66
+ - resources/trees/license/COPYING.gpl
67
+ - resources/trees/license/COPYING.lgpl
68
+ - resources/trees/core
69
+ - resources/trees/core/Rakefile
70
+ - resources/trees/core/README
71
+ - resources/trees/core/CHANGES
72
+ - resources/trees/core/lib
73
+ - resources/trees/core/lib/rabal.project
74
+ - resources/trees/core/lib/rabal.project/version.rb.erb
75
+ - resources/trees/core/lib/rabal.project.rb.erb
76
+ - resources/trees/bin
77
+ - resources/trees/bin/rabal.project
78
+ - bin/rabal
79
+ - LICENSE
80
+ - README
81
+ - COPYING
82
+ - README.PLUGIN
83
+ test_files:
84
+ - spec/plugin_tree_spec.rb
85
+ - spec/core_plugin_spec.rb
86
+ - spec/version_spec.rb
87
+ - spec/test_plugin_spec.rb
88
+ - spec/bin_plugin_spec.rb
89
+ - spec/directory_tree_spec.rb
90
+ - spec/action_tree_spec.rb
91
+ - spec/utils_spec.rb
92
+ - spec/license_plugin_spec.rb
93
+ - spec/spec_plugin_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/file_tree_spec.rb
96
+ - spec/tree_spec.rb
97
+ - spec/project_tree_spec.rb
98
+ rdoc_options:
99
+ - - --line-numbers
100
+ - --inline-source
101
+ - --title
102
+ - Rabal -- Ruby Architecture for Building Applications and Libraries
103
+ - --main
104
+ - README
105
+ extra_rdoc_files:
106
+ - LICENSE
107
+ - README
108
+ - COPYING
109
+ - README.PLUGIN
110
+ executables:
111
+ - rabal
112
+ extensions: []
113
+
114
+ requirements: []
115
+
116
+ dependencies:
117
+ - !ruby/object:Gem::Dependency
118
+ name: main
119
+ version_requirement:
120
+ version_requirements: !ruby/object:Gem::Version::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.2
125
+ version:
126
+ - !ruby/object:Gem::Dependency
127
+ name: gem_plugin
128
+ version_requirement:
129
+ version_requirements: !ruby/object:Gem::Version::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 0.2.1
134
+ version: