sprout 0.7.215-x86-linux → 0.7.217-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

@@ -0,0 +1,34 @@
1
+
2
+ # DynamicAccessors provides support for
3
+ # simply setting and getting values of any kind from
4
+ # any object that includes it.
5
+ #
6
+ # require 'dynamic_accessors'
7
+ #
8
+ # class Foo
9
+ # include DynamicAccessors
10
+ # end
11
+ #
12
+ # foo = Foo.new
13
+ # foo.bar = "Hello World"
14
+ # foo.friends = ['a', 'b', 'c']
15
+ # puts "foo.bar: #{foo.bar}"
16
+ # puts "foo.friends: #{foo.friends.join(', ')}"
17
+
18
+ module DynamicAccessors
19
+
20
+ def initialize(*params)
21
+ super
22
+ @missing_params_hash = Hash.new
23
+ end
24
+
25
+ def method_missing(method, *params, &block)
26
+ if(method.to_s.match(/=$/))
27
+ method = method.to_s.gsub('=', '').to_sym
28
+ return @missing_params_hash[method] = params.shift
29
+ else
30
+ return @missing_params_hash[method] if @missing_params_hash.keys.collect(&:to_sym).include?(method)
31
+ end
32
+ super
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # gem 'activesupport', '>= 2.0.2'
2
- gem 'rubigen', '= 1.3.3'
2
+ gem 'rubigen'
3
3
  require 'rubigen'
4
4
  require 'sprout/generator/base_mixins'
5
5
  require 'sprout/generator/named_base'
@@ -0,0 +1,118 @@
1
+ require 'erb'
2
+
3
+ # Rake task that makes it stupid-easy to render ERB templates
4
+ # to disk. Just add parameters to the yielded object, and
5
+ # they will be available to your Template.
6
+ #
7
+ # erb_resolver 'config/SomeFile.xml' do |t|
8
+ # t.param1 = 'value'
9
+ # t.other_param = 'other value'
10
+ # t.another_param = ['a', 'b', 'c']
11
+ # end
12
+ #
13
+ # Your erb template must be found at:
14
+ #
15
+ # [task_name].erb
16
+ #
17
+ # For the above example, this file would be:
18
+ #
19
+ # config/SomeFile.xml.erb
20
+ #
21
+ module Sprout
22
+
23
+ class ERBResolver < Rake::FileTask
24
+
25
+ # Path to the input ERB template. This
26
+ # value will default to the value of
27
+ # "#{ERBResolver.output}.erb"
28
+ attr_accessor :template
29
+
30
+ def initialize(name, app) # :nodoc:
31
+ super
32
+ @context = ERBContext.new
33
+ end
34
+
35
+ def define(args)
36
+ end
37
+
38
+ def prepare
39
+ prepare_prerequisites
40
+ end
41
+
42
+ # Modified from Rake::Task.execute
43
+ def execute(args=nil)
44
+ args ||= EMPTY_TASK_ARGS
45
+ if application.options.dryrun
46
+ puts "** Execute (dry run) #{name}"
47
+ return
48
+ end
49
+ if application.options.trace
50
+ puts "** Execute #{name}"
51
+ end
52
+ application.enhance_with_matching_rule(name) if @actions.empty?
53
+ @actions.each do |action|
54
+ execute_erb_task(action, args)
55
+ end
56
+ end
57
+
58
+ def execute_erb_task(action, args=nil)
59
+ case action.arity
60
+ when 1
61
+ action.call(@context)
62
+ else
63
+ action.call(@context, args)
64
+ end
65
+
66
+ @context.execute(template, output, args)
67
+ end
68
+
69
+ def self.define_task(*args, &block)
70
+ t = super
71
+ if(t.is_a?(ERBResolver))
72
+ t.define(args)
73
+ t.prepare
74
+ end
75
+ return t
76
+ end
77
+
78
+ def template
79
+ @template ||= "#{output}.erb"
80
+ end
81
+
82
+ def output
83
+ self.name
84
+ end
85
+
86
+ protected
87
+
88
+ def prepare_prerequisites
89
+ prerequisites << file(template)
90
+ CLEAN.add(output)
91
+ end
92
+
93
+ end
94
+
95
+ # An empty, dynamic object that will be yielded
96
+ # to the provided block and later supplied to the
97
+ # ERB template.
98
+ #
99
+ # Returning this empty object gives us the ability
100
+ # to use parameter names in our templates even if
101
+ # they are already used by Rake tasks (i.e. name).
102
+ class ERBContext
103
+ include DynamicAccessors
104
+
105
+ def execute(template, output, args=nil)
106
+ content = nil
107
+ File.open(template, 'r') { |f| content = f.read }
108
+ result = ERB.new(content, nil, '>').result(binding)
109
+ File.open(output, 'w') { |f| f.write(result) }
110
+ Log.puts ">> Created ERB output at: #{output} from: #{template}"
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ def erb_resolver(*args, &block)
117
+ Sprout::ERBResolver.define_task(args, &block)
118
+ end
@@ -3,7 +3,7 @@ module Sprout
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 215
6
+ TINY = 217
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  MAJOR_MINOR = [MAJOR, MINOR].join('.')
data/lib/sprout.rb CHANGED
@@ -14,6 +14,7 @@ if(Gem::Version.new(Gem::RubyGemsVersion) != Gem::Version.new('1.0.1'))
14
14
  end
15
15
 
16
16
  $:.push(File.dirname(__FILE__))
17
+ require 'sprout/dynamic_accessors'
17
18
  require 'progress_bar'
18
19
  require 'sprout/log'
19
20
  require 'sprout/user'
@@ -33,6 +34,7 @@ require 'sprout/project_model'
33
34
  require 'sprout/builder'
34
35
  require 'sprout/version'
35
36
  require 'sprout/tasks/tool_task'
37
+ require 'sprout/tasks/erb_resolver'
36
38
  require 'sprout/general_tasks'
37
39
  require 'sprout/generator'
38
40
 
data/rakefile.rb CHANGED
@@ -55,7 +55,7 @@ def apply_shared_spec(s)
55
55
 
56
56
  s.add_dependency('rubyzip', '>= 0.9.1')
57
57
  s.add_dependency('archive-tar-minitar', '>= 0.5.1')
58
- s.add_dependency('rubigen', '= 1.5.2')
58
+ s.add_dependency('rubigen', '>= 1.5.2')
59
59
  s.add_dependency('net-sftp')
60
60
  s.add_dependency('net-ssh')
61
61
  s.add_dependency('rake')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.215
4
+ version: 0.7.217
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Luke Bayes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-07 00:00:00 -07:00
12
+ date: 2009-10-28 00:00:00 -04:00
13
13
  default_executable: sprout
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -38,7 +38,7 @@ dependencies:
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "="
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.5.2
44
44
  version:
@@ -101,6 +101,7 @@ files:
101
101
  - lib/sprout/archive_unpacker.rb
102
102
  - lib/sprout/builder.rb
103
103
  - lib/sprout/commands/generate.rb
104
+ - lib/sprout/dynamic_accessors.rb
104
105
  - lib/sprout/general_tasks.rb
105
106
  - lib/sprout/generator/base_mixins.rb
106
107
  - lib/sprout/generator/named_base.rb
@@ -111,6 +112,7 @@ files:
111
112
  - lib/sprout/remote_file_loader.rb
112
113
  - lib/sprout/remote_file_target.rb
113
114
  - lib/sprout/simple_resolver.rb
115
+ - lib/sprout/tasks/erb_resolver.rb
114
116
  - lib/sprout/tasks/gem_wrap_task.rb
115
117
  - lib/sprout/tasks/git_task.rb
116
118
  - lib/sprout/tasks/library_task.rb