Class: ActionScriptVersion::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- ActionScriptVersion::Task
- Defined in:
- lib/shed/rake/version.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#output ⇒ Object
Returns the value of attribute output.
-
#patch ⇒ Object
Returns the value of attribute patch.
-
#strip_xml_comments ⇒ Object
Returns the value of attribute strip_xml_comments.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :version) {|_self| ... } ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(name = :version) {|_self| ... } ⇒ Task
Returns a new instance of Task.
12 13 14 15 16 17 18 19 20 |
# File 'lib/shed/rake/version.rb', line 12 def initialize name = :version @name = name @output = 'Version.as' @strip_xml_comments = false yield self if block_given? define end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
5 6 7 |
# File 'lib/shed/rake/version.rb', line 5 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
5 6 7 |
# File 'lib/shed/rake/version.rb', line 5 def minor @minor end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/shed/rake/version.rb', line 5 def output @output end |
#patch ⇒ Object
Returns the value of attribute patch.
5 6 7 |
# File 'lib/shed/rake/version.rb', line 5 def patch @patch end |
#strip_xml_comments ⇒ Object
Returns the value of attribute strip_xml_comments.
5 6 7 |
# File 'lib/shed/rake/version.rb', line 5 def strip_xml_comments @strip_xml_comments end |
#template ⇒ Object
Returns the value of attribute template.
5 6 7 |
# File 'lib/shed/rake/version.rb', line 5 def template @template end |
Instance Method Details
#define ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shed/rake/version.rb', line 22 def define desc "Generate a ActionScript class containing application version details" task @name do revision = `git rev-parse HEAD`.chomp rescue 'no-git-rev' t = File.read(@template) t.gsub!('@major@', major.to_s) t.gsub!('@minor@', minor.to_s) t.gsub!('@patch@', patch.to_s) t.gsub!('@revision@', revision) t = Stripper.xml_comments(t) if @strip_xml_comments File.open(@output, 'w') {|f| f.write(t) } puts "Created #{output}, v#{major}.#{minor}.#{patch} [#{revision[0..10]}]" end end |