gravitext-devtools 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.3.0 (2012-9-13)
2
+ * Add gt-version script for aiding common version bump,date tasks.
3
+ * Fix gt-header usage text
4
+ * Ruby 1.9/charset relates fixes
5
+
1
6
  === 1.2.0 (2012-1-13)
2
7
  * Use rjack-tarpit ~> 2.0.0 (build)
3
8
  * Convert to use of hooker ~> 1.0.0 for config support.
data/Manifest.txt CHANGED
@@ -6,11 +6,13 @@ bin/gt-cleanws
6
6
  bin/gt-count
7
7
  bin/gt-header
8
8
  bin/gt-manifest
9
+ bin/gt-version
9
10
  lib/gravitext-devtools/base.rb
10
11
  lib/gravitext-devtools.rb
11
12
  lib/gravitext-devtools/header_writer.rb
12
13
  lib/gravitext-devtools/line_counter.rb
13
14
  lib/gravitext-devtools/manifest_writer.rb
15
+ lib/gravitext-devtools/version_writer.rb
14
16
  templates/format/format.java
15
17
  templates/format/format.rb
16
18
  templates/format/format.txt
data/README.rdoc CHANGED
@@ -10,6 +10,7 @@ gt-manifest:: Maintain manifest from git ls-files minus exclusions.
10
10
  gt-cleanws:: Cleanup whitespace in files.
11
11
  gt-header:: Add and maintain file license headers.
12
12
  gt-count:: Count lines of code by type.
13
+ gt-version:: Bump versions and set release dates.
13
14
 
14
15
  == License
15
16
 
data/bin/gt-cleanws CHANGED
@@ -147,7 +147,7 @@ class CleanWS
147
147
 
148
148
  fout = @do_write ? open( ofile, 'w' ) : @fout
149
149
 
150
- result = open( ifile, 'r' ) do |fin|
150
+ result = open( ifile, 'rb' ) do |fin|
151
151
  filter( fin, fout )
152
152
  end
153
153
 
data/bin/gt-version ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby
2
+ #--
3
+ # Copyright (c) 2008-2012 David Kellum
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
6
+ # may not use this file except in compliance with the License. You may
7
+ # obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
+ # implied. See the License for the specific language governing
15
+ # permissions and limitations under the License.
16
+ #++
17
+
18
+ $LOAD_PATH.unshift File.join( File.dirname( __FILE__ ), "..", "lib" )
19
+
20
+ require 'gravitext-devtools/version_writer'
21
+
22
+ module Gravitext::DevTools
23
+
24
+ load_config_from_pwd
25
+
26
+ VersionWriter.new.run
27
+
28
+ end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Gravitext
18
18
  module DevTools
19
- VERSION = "1.2.0"
19
+ VERSION = "1.3.0"
20
20
  end
21
21
  end
@@ -62,9 +62,9 @@ module Gravitext
62
62
  def parse_options( args = ARGV )
63
63
 
64
64
  @git_lister.parse_options( args ) do |opts|
65
- opts.banner = "Usage: gt-manifest [dir|file] ..."
65
+ opts.banner = "Usage: gt-header [dir|file] ..."
66
66
  opts.on( "-v", "--verbose",
67
- "Output full manifest details" ) do
67
+ "Output full details" ) do
68
68
  @verbose = true
69
69
  end
70
70
  opts.on( "-w", "--write",
@@ -116,7 +116,8 @@ module Gravitext
116
116
  end
117
117
 
118
118
  def expand( template, bnd )
119
- ERB.new( template, nil, '%' ).result( bnd ).map { |l| l.rstrip }
119
+ ERB.new( template, nil, '%' ).result( bnd ).
120
+ split( $/ ).map { |l| l.rstrip }
120
121
  end
121
122
 
122
123
  def years
@@ -69,7 +69,7 @@ module Gravitext
69
69
  lines = codelines = 0
70
70
  is_java = ( filename =~ /\.java$/ )
71
71
 
72
- open( filename, 'r' ) { |f|
72
+ open( filename, 'rb' ) { |f|
73
73
  f.each do |line|
74
74
  lines += 1
75
75
  next if line =~ /^\s*$/
@@ -0,0 +1,189 @@
1
+ #--
2
+ # Copyright (c) 2008-2012 David Kellum
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
5
+ # may not use this file except in compliance with the License. You may
6
+ # obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+ # implied. See the License for the specific language governing
14
+ # permissions and limitations under the License.
15
+ #++
16
+
17
+ require 'gravitext-devtools'
18
+ require 'fileutils'
19
+ require 'rainbow'
20
+
21
+ module Gravitext
22
+ module DevTools
23
+
24
+ class VersionWriter
25
+ include FileUtils
26
+
27
+ attr_accessor :local_dep_prefix
28
+ attr_accessor :exclusions
29
+ attr_accessor :inclusions
30
+ attr_accessor :patterns
31
+
32
+ def initialize
33
+
34
+ @local_dep_prefix = nil
35
+
36
+ @git_lister = GitFileLister.new
37
+ @inclusions = []
38
+ @exclusions = @git_lister.exclusions.dup
39
+ @version = nil
40
+
41
+ @patterns = {
42
+ :history => [ /History\./,
43
+ /^=== ([0-9a-z.]+) \((TBD|[0-9\-]+)\)/ ],
44
+ :pom => [ /pom\.xml$/,
45
+ /<version>([0-9a-z.]+)<\/version>/ ],
46
+ :rb => [ /(version|base)\.rb$/,
47
+ /VERSION\s*=\s*['"]([0-9a-z.]+)['"]/ ],
48
+ :init => [ /init\//,
49
+ /^gem.+,\s*['"]=\s*([0-9a-z.]+)['"]/ ],
50
+ :gemspec => [ /\.gemspec$/,
51
+ /RJack::TarPit\.specify/ ]
52
+ }
53
+
54
+ Hooker.apply( [ :gt, :version ], self )
55
+ end
56
+
57
+ def parse_options( args = ARGV )
58
+
59
+ @git_lister.parse_options( args ) do |opts|
60
+ opts.banner = "Usage: gt-version [options] dir|files ..."
61
+ opts.on( "-v", "--version V", "Specify new version", String ) do |v|
62
+ @version = v
63
+ end
64
+ opts.on( "-d", "--depend-prefix P",
65
+ "Also adjust local dependencies with prefix" ) do |p|
66
+ @local_dep_prefix = p
67
+ end
68
+ end
69
+ end
70
+
71
+ def run( args = ARGV )
72
+ parse_options( args )
73
+
74
+ @git_lister.inclusions = @inclusions
75
+ @git_lister.exclusions = @exclusions
76
+
77
+ @git_lister.files.each do |fname|
78
+ process( fname )
79
+ end
80
+ end
81
+
82
+ def process( fname )
83
+ type, (_,vline) = @patterns.find { |_,(fp,_)| fname =~ fp }
84
+ return false unless type
85
+
86
+ # With no version specified, only process history for release date
87
+ return false unless @version || type == :history
88
+
89
+ lines = IO.readlines( fname )
90
+ first_match = true
91
+ lines.each_index do |i|
92
+ line = lines[i]
93
+ if line =~ vline
94
+ case type
95
+ when :history
96
+ if $2 == 'TBD'
97
+ lines[i] = if @version.nil? || $1 == @version
98
+ "=== #{$1} (#{release_date})"
99
+ else
100
+ "=== #{@version} (TBD)"
101
+ end
102
+ else
103
+ lines.insert( i, [ "=== #{@version} (TBD)", '' ] )
104
+ end
105
+ when :pom
106
+ lines[i] = line.sub( /^(\s*<version>)([0-9a-z.]+)(<\/version>)/,
107
+ "\\1#{@version}\\3" )
108
+ adjust_pom_local( lines, i+1 ) if @local_dep_prefix
109
+ when :rb
110
+ lines[i] = line.sub( /^(\s*VERSION\s*=\s*['"])([0-9a-z.]+)/,
111
+ "\\1#{@version}" )
112
+ when :init
113
+ lines[i] = line.sub( /^(gem.+,\s*['"]=\s*)([0-9a-z.]+)/,
114
+ "\\1#{@version}" )
115
+ when :gemspec
116
+ adjust_gemspec_local( lines, i+1 ) if @local_dep_prefix
117
+ end
118
+ break
119
+ end
120
+ end
121
+ rewrite_file( fname, lines )
122
+ true
123
+ end
124
+
125
+ def adjust_pom_local( lines, start )
126
+ parent = false
127
+ local = false
128
+ lines.each_index do |i|
129
+ next unless i >= start
130
+ line = lines[i]
131
+ case line
132
+ when /<parent>/
133
+ local = true
134
+ parent = true
135
+ when /<\/parent>/
136
+ local = false
137
+ parent = false
138
+ when /<artifactId>/
139
+ local = ( line =~ /<artifactId>\s*#{@local_dep_prefix}/ )
140
+ when /<version>([\[\]\(\)0-9a-z.,]+)(<\/version>)/
141
+ if local
142
+ if parent
143
+ lines[i] = line.sub( /^(\s*<version>)([0-9a-z.]+)/,
144
+ "\\1#{@version}" )
145
+ else
146
+ lines[i] = line.sub( /^(\s*<version>)([\[\]\(\)0-9a-z.,]+)/,
147
+ "\\1#{maven_version_range}" )
148
+ end
149
+ end
150
+ when /<\/dependencies>/
151
+ break
152
+ end
153
+ end
154
+ end
155
+
156
+ def adjust_gemspec_local( lines, start )
157
+ parent = false
158
+ local = false
159
+ lines.each_index do |i|
160
+ next unless i >= start
161
+ line = lines[i]
162
+ if line =~ /\.depend.+['"]#{@local_dep_prefix}/
163
+ lines[i] = line.sub( /(\.depend.*,\s*['"])([^'"]+)(['"])/,
164
+ "\\1#{gem_version_range}\\3" )
165
+ end
166
+ end
167
+ end
168
+
169
+ def release_date
170
+ Time.now.strftime( "%Y-%-m-%-d" )
171
+ end
172
+
173
+ def rewrite_file( file, lines )
174
+ open( file, "w" ) { |fout| fout.puts( lines ) }
175
+ end
176
+
177
+ def maven_version_range
178
+ minor_v = @version =~ /^(\d+\.\d+)/ && $1
179
+ "[#{@version},#{minor_v}.999)"
180
+ end
181
+
182
+ def gem_version_range
183
+ "~> #{@version}"
184
+ end
185
+
186
+ end
187
+
188
+ end
189
+ end
metadata CHANGED
@@ -1,82 +1,78 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gravitext-devtools
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 0
10
- version: 1.2.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - David Kellum
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-13 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rainbow
16
+ requirement: !ruby/object:Gem::Requirement
22
17
  none: false
23
- requirements:
18
+ requirements:
24
19
  - - ~>
25
- - !ruby/object:Gem::Version
26
- hash: 13
27
- segments:
28
- - 1
29
- - 1
30
- version: "1.1"
31
- version_requirements: *id001
32
- name: rainbow
33
- prerelease: false
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
34
22
  type: :runtime
35
- - !ruby/object:Gem::Dependency
36
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
37
25
  none: false
38
- requirements:
26
+ requirements:
39
27
  - - ~>
40
- - !ruby/object:Gem::Version
41
- hash: 23
42
- segments:
43
- - 1
44
- - 0
45
- - 0
46
- version: 1.0.0
47
- version_requirements: *id002
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - !ruby/object:Gem::Dependency
48
31
  name: hooker
49
- prerelease: false
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.0
50
38
  type: :runtime
51
- - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
53
41
  none: false
54
- requirements:
42
+ requirements:
55
43
  - - ~>
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 2
60
- - 0
61
- version: "2.0"
62
- version_requirements: *id003
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ - !ruby/object:Gem::Dependency
63
47
  name: rjack-tarpit
64
- prerelease: false
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
65
54
  type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
66
62
  description:
67
- email:
63
+ email:
68
64
  - dek-oss@gravitext.com
69
- executables:
65
+ executables:
70
66
  - gt-cleanws
71
67
  - gt-count
72
68
  - gt-header
73
69
  - gt-manifest
70
+ - gt-version
74
71
  extensions: []
75
-
76
- extra_rdoc_files:
72
+ extra_rdoc_files:
77
73
  - History.rdoc
78
74
  - README.rdoc
79
- files:
75
+ files:
80
76
  - History.rdoc
81
77
  - Manifest.txt
82
78
  - README.rdoc
@@ -85,11 +81,13 @@ files:
85
81
  - bin/gt-count
86
82
  - bin/gt-header
87
83
  - bin/gt-manifest
84
+ - bin/gt-version
88
85
  - lib/gravitext-devtools/base.rb
89
86
  - lib/gravitext-devtools.rb
90
87
  - lib/gravitext-devtools/header_writer.rb
91
88
  - lib/gravitext-devtools/line_counter.rb
92
89
  - lib/gravitext-devtools/manifest_writer.rb
90
+ - lib/gravitext-devtools/version_writer.rb
93
91
  - templates/format/format.java
94
92
  - templates/format/format.rb
95
93
  - templates/format/format.txt
@@ -99,37 +97,34 @@ files:
99
97
  - templates/license/mit
100
98
  homepage: http://github.com/dekellum/gravitext-devtools
101
99
  licenses: []
102
-
103
100
  post_install_message:
104
- rdoc_options:
101
+ rdoc_options:
105
102
  - --main
106
103
  - README.rdoc
107
- require_paths:
104
+ require_paths:
108
105
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
106
+ required_ruby_version: !ruby/object:Gem::Requirement
110
107
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ segments:
116
113
  - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
114
+ hash: 317307963780800362
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
116
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ segments:
125
122
  - 0
126
- version: "0"
123
+ hash: 317307963780800362
127
124
  requirements: []
128
-
129
125
  rubyforge_project:
130
- rubygems_version: 1.8.11
126
+ rubygems_version: 1.8.21
131
127
  signing_key:
132
128
  specification_version: 3
133
129
  summary: A collection of development support tools.
134
130
  test_files: []
135
-