ritual 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/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.1.1 2011-01-21
2
+
3
+ * Support custom code in version file. Only the "VERSION =" line is
4
+ updated on bump.
5
+
1
6
  == 0.1.0 2011-01-17
2
7
 
3
8
  * Subtasks are now public, and namespaced under repo: and gem:.
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
1
  $:.unshift File.expand_path('lib', File.dirname(__FILE__))
2
2
  require 'ritual'
3
+
4
+ spec_task :spec
@@ -1,5 +1,5 @@
1
1
  module Ritual
2
- VERSION = [0, 1, 0]
2
+ VERSION = [0, 1, 1]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
@@ -1,5 +1,7 @@
1
1
  module Ritual
2
2
  class VersionFile
3
+ VERSION_REGEXP = /^\s*VERSION\s*=\s*(\[.*?\])/
4
+
3
5
  def initialize(path, library_name)
4
6
  @path = path
5
7
  @library_name = library_name
@@ -13,21 +15,28 @@ module Ritual
13
15
  end
14
16
 
15
17
  def write
16
- FileUtils.mkdir_p File.dirname(path)
17
- open(path, 'w') do |file|
18
- file.puts <<-EOS.gsub(/^ *\|/, '')
19
- |module #{module_name}
20
- | VERSION = #{value.inspect}
21
- |
22
- | class << VERSION
23
- | include Comparable
24
- |
25
- | def to_s
26
- | join('.')
27
- | end
28
- | end
29
- |end
30
- EOS
18
+ if File.exist?(path)
19
+ source = File.read(path).sub(VERSION_REGEXP) do |s|
20
+ "#{s[/\s*/]}VERSION = [#{@value.join(', ')}]"
21
+ end
22
+ open(path, 'w') { |f| f.puts source}
23
+ else
24
+ FileUtils.mkdir_p File.dirname(path)
25
+ open(path, 'w') do |file|
26
+ file.puts <<-EOS.gsub(/^ *\|/, '')
27
+ |module #{module_name}
28
+ | VERSION = #{value.inspect}
29
+ |
30
+ | class << VERSION
31
+ | include Comparable
32
+ |
33
+ | def to_s
34
+ | join('.')
35
+ | end
36
+ | end
37
+ |end
38
+ EOS
39
+ end
31
40
  end
32
41
  end
33
42
 
@@ -41,7 +50,7 @@ module Ritual
41
50
 
42
51
  def read
43
52
  if File.exist?(path)
44
- File.read(path) =~ /^\s*VERSION\s*=\s*(\[.*?\])/ and
53
+ File.read(path) =~ VERSION_REGEXP and
45
54
  eval $1
46
55
  else
47
56
  [0, 0, 0]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ritual
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - George Ogata
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-17 00:00:00 -05:00
18
+ date: 2011-01-21 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency