gator 0.0.2.pre → 0.0.3.pre

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2.pre
1
+ 0.0.3.pre
data/gator.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gator}
8
- s.version = "0.0.2.pre"
8
+ s.version = "0.0.3.pre"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dominic Graefen"]
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  "lib/core/configuration/configuration.rb",
37
37
  "lib/core/plugin.rb",
38
38
  "lib/core/project.rb",
39
+ "lib/core/project/layout.rb",
39
40
  "lib/core/project/project.rb",
40
41
  "lib/gator.rb",
41
42
  "test/helper.rb",
@@ -30,13 +30,8 @@ module Gator
30
30
 
31
31
  class << self
32
32
 
33
- def application
34
- @application
35
- end
36
-
37
- def application=(app)
38
- @application = app
39
- end
33
+ attr_accessor :application
34
+ attr_accessor :base_dir
40
35
 
41
36
  def configuration
42
37
  application.configuration
@@ -24,6 +24,7 @@ module Gator
24
24
  def load_project_configuration
25
25
  config_file = File.find_file_upwards("gator_config.rb") || File.join( ".gator","gator_config.rb")
26
26
  ConfigurationGenerator.new.create_configuration config_file unless File.exists? config_file
27
+ Gator.project.base_dir = File.dirname( File.dirname( config_file ) )
27
28
  load config_file
28
29
  end
29
30
 
data/lib/core/project.rb CHANGED
@@ -1 +1,2 @@
1
+ require File.dirname(__FILE__) + '/project/layout'
1
2
  require File.dirname(__FILE__) + '/project/project'
@@ -0,0 +1,87 @@
1
+ # THIS CLASS IS STOLEN FROM BUILDR
2
+
3
+ # Symbolic mapping for directory layout. Used for both the default and custom layouts.
4
+ #
5
+ # For example, the default layout maps [:source, :main, :java] to 'src/main/java', and
6
+ # [:target, :main, :classes] to 'target/classes'. You can use this to change the layout
7
+ # of your projects.
8
+ #
9
+ # To map [:source, :main] into the 'sources' directory:
10
+ # my_layout = Layout.new
11
+ # my_layout[:source, :main] = 'sources'
12
+ #
13
+ # define 'foo', :layout=>my_layout do
14
+ # ...
15
+ # end
16
+ #
17
+ # To map [:source, :main, :java] to 'java/main':
18
+ # class MainLast < Layout
19
+ # def expand(*args)
20
+ # if args[0..1] == [:source, :main]
21
+ # super args[2], :main, *args[3,]
22
+ # else
23
+ # super
24
+ # end
25
+ # end
26
+ # end
27
+ #
28
+ # define 'foo', :layout=>MainLast do
29
+ # ...
30
+ # end
31
+ class Layout
32
+
33
+ class << self
34
+
35
+ # Default layout used by new projects.
36
+ attr_accessor :default
37
+
38
+ end
39
+
40
+ def initialize #:nodoc:
41
+ @mapping = {}
42
+ end
43
+
44
+ # Expands list of symbols and path names into a full path, for example:
45
+ # puts default.expand(:source, :main, :java)
46
+ # => "src/main/java"
47
+ def expand(*args)
48
+ args = args.compact.reject { |s| s.to_s.empty? }.map(&:to_sym)
49
+ return '' if args.empty?
50
+ @mapping[args] ||= File.join(*[expand(*args[0..-2]), args.last.to_s].reject(&:empty?)) if args.size > 1
51
+ return @mapping[args] || args.first.to_s
52
+ end
53
+
54
+ # Resolves a list of symbols into a path.
55
+ def [](*args)
56
+ @mapping[args.map(&:to_sym)]
57
+ end
58
+
59
+ # Specifies the path resolved from a list of symbols.
60
+ def []=(*args)
61
+ @mapping[args[0...-1].map(&:to_sym)] = args.last
62
+ end
63
+
64
+ def initialize_copy(copy)
65
+ copy.instance_variable_set :@mapping, @mapping.clone
66
+ end
67
+
68
+ # Default layout has the following properties:
69
+ # * :source maps to the 'src' directory.
70
+ # * Anything under :source maps verbatim (e.g. :source, :main becomes 'src/main')
71
+ # * :target maps to the 'target' directory.
72
+ # * :target, :main maps to the 'target' directory as well.
73
+ # * Anything under :target, :main maps verbatim (e.g. :target, :main, :classes becomes 'target/classes')
74
+ # * Anything else under :target also maps verbatim (e.g. :target, :test becomes 'target/test')
75
+ class Default < Layout
76
+
77
+ def initialize
78
+ super
79
+ self[:source] = 'src'
80
+ self[:target, :main] = 'target'
81
+ end
82
+
83
+ end
84
+
85
+ self.default = Default.new
86
+
87
+ end
@@ -5,6 +5,27 @@ module Gator
5
5
 
6
6
  def initialize( name )
7
7
  @name = name
8
+ @layout = Layout.default
9
+ end
10
+
11
+ def base_dir
12
+ @base_dir
13
+ end
14
+
15
+ def base_dir=( dir )
16
+ @base_dir = dir
17
+ end
18
+
19
+ def path(*args)
20
+ File.join( Gator.base_dir, layout.expand(*args) )
21
+ end
22
+
23
+ def layout
24
+ @layout
25
+ end
26
+
27
+ def layout=( l )
28
+ @layout = l
8
29
  end
9
30
 
10
31
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gator
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.0.2.pre
5
+ version: 0.0.3.pre
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dominic Graefen
@@ -95,6 +95,7 @@ files:
95
95
  - lib/core/configuration/configuration.rb
96
96
  - lib/core/plugin.rb
97
97
  - lib/core/project.rb
98
+ - lib/core/project/layout.rb
98
99
  - lib/core/project/project.rb
99
100
  - lib/gator.rb
100
101
  - test/helper.rb
@@ -113,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - ">="
115
116
  - !ruby/object:Gem::Version
116
- hash: 301234331673452016
117
+ hash: 1808113828780164832
117
118
  segments:
118
119
  - 0
119
120
  version: "0"