win32rc 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2007 Jared Hanson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1 @@
1
+ = Win32RC
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/testtask'
7
+
8
+ PKG_NAME = 'win32rc'
9
+ PKG_VERSION = '0.1.0'
10
+
11
+ PKG_FILES = FileList[
12
+ '[A-Z]*',
13
+ 'lib/**/*'
14
+ ]
15
+
16
+
17
+ spec = Gem::Specification.new do |s|
18
+ s.name = PKG_NAME
19
+ s.version = PKG_VERSION
20
+ s.files = PKG_FILES
21
+
22
+ s.author = "Jared Hanson"
23
+ s.email = "jaredhanson@gmail.com"
24
+ s.homepage = "http://win32rc.rubyforge.org/"
25
+ s.rubyforge_project = "win32rc"
26
+
27
+ s.summary = "A Ruby library for modifying Windows Resource files."
28
+ end
29
+
30
+ Rake::GemPackageTask.new(spec) do |pkg|
31
+ pkg.gem_spec = spec
32
+ end
33
+
34
+ Rake::RDocTask.new do |rdoc|
35
+ rdoc.rdoc_dir = 'doc'
36
+ rdoc.rdoc_files.include('README')
37
+ rdoc.rdoc_files.include('lib/win32rc.rb')
38
+ rdoc.rdoc_files.include('lib/win32rc/**/*.rb')
39
+ end
40
+
41
+ Rake::TestTask.new do |test|
42
+ test.libs << "test"
43
+ test.test_files = FileList['test/test_suite.rb']
44
+ end
@@ -0,0 +1,2 @@
1
+ require 'win32rc/version'
2
+ require 'win32rc/resource'
@@ -0,0 +1,22 @@
1
+ class String
2
+
3
+ def begin?(other_str)
4
+ self.index(other_str) == 0
5
+ end
6
+
7
+ def end?(other_str)
8
+ i = self.rindex(other_str)
9
+ return false if i.nil?
10
+ return (self.length == i + other_str.length)
11
+ end
12
+
13
+ def win32_versionize(sep = ',')
14
+ components = self.split('.', 4)
15
+ while components.size < 4
16
+ components.push('0')
17
+ end
18
+
19
+ return components.join(sep)
20
+ end
21
+
22
+ end
@@ -0,0 +1,38 @@
1
+ require 'ftools'
2
+ require 'win32rc/core_ext/string'
3
+ require 'win32rc/version_info'
4
+
5
+ module Win32RC
6
+
7
+ # http://msdn2.microsoft.com/en-us/library/aa380599(VS.85).aspx
8
+ class Resource
9
+ attr_writer :version
10
+
11
+ def initialize(file)
12
+ @file = file
13
+ end
14
+
15
+ def save
16
+ return if @version.nil?
17
+
18
+ fin = File.open(@file)
19
+ fout = File.open("#{@file}.new", "w")
20
+
21
+ while fin.gets
22
+ fout << $_
23
+
24
+ if $_.strip.end? "VERSIONINFO"
25
+ VersionInfoUpdater.new(fin, fout, @version)
26
+ end
27
+ end
28
+
29
+ fin.close
30
+ fout.close
31
+
32
+ File.delete @file
33
+ File.move "#{@file}.new", @file
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,5 @@
1
+ module Win32RC
2
+
3
+ VERSION = '0.1.0'.freeze
4
+
5
+ end
@@ -0,0 +1,40 @@
1
+ require 'win32rc/core_ext/string'
2
+
3
+ module Win32RC
4
+
5
+ class VersionInfoUpdater
6
+
7
+ def initialize(fin, fout, v)
8
+ update fin, fout, v
9
+ end
10
+
11
+ private
12
+ def update(fin, fout, v)
13
+ block_cnt = 0
14
+
15
+ while fin.gets
16
+ if $_.strip.begin? "BEGIN"
17
+ block_cnt = block_cnt + 1
18
+ elsif $_.strip.begin? "END"
19
+ block_cnt = block_cnt - 1
20
+ end
21
+
22
+ if $_.strip.begin? "FILEVERSION"
23
+ fout << $_.gsub(/FILEVERSION .*/, "FILEVERSION #{v.win32_versionize}")
24
+ elsif $_.strip.begin? "PRODUCTVERSION"
25
+ fout << $_.gsub(/PRODUCTVERSION .*/, "PRODUCTVERSION #{v.win32_versionize}")
26
+ elsif $_.strip.begin? "VALUE \"FileVersion\""
27
+ fout << $_.gsub(/\"FileVersion\", .*/, "\"FileVersion\", \"#{v.win32_versionize(', ')}\"")
28
+ elsif $_.strip.begin? "VALUE \"ProductVersion\""
29
+ fout << $_.gsub(/\"ProductVersion\", .*/, "\"ProductVersion\", \"#{v.win32_versionize(', ')}\"")
30
+ else
31
+ fout << $_
32
+ end
33
+
34
+ break if $_.strip.begin? "END" and block_cnt == 0
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: win32rc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jared Hanson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: jaredhanson@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - LICENSE
26
+ - Rakefile
27
+ - README
28
+ - lib/win32rc
29
+ - lib/win32rc/core_ext
30
+ - lib/win32rc/core_ext/string.rb
31
+ - lib/win32rc/resource.rb
32
+ - lib/win32rc/version.rb
33
+ - lib/win32rc/version_info.rb
34
+ - lib/win32rc.rb
35
+ has_rdoc: false
36
+ homepage: http://win32rc.rubyforge.org/
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project: win32rc
57
+ rubygems_version: 1.0.1
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: A Ruby library for modifying Windows Resource files.
61
+ test_files: []
62
+