vstudioide 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
+ = VStudioIDE
@@ -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 = 'vstudioide'
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://vstudioide.rubyforge.org/"
25
+ s.rubyforge_project = "vstudioide"
26
+
27
+ s.summary = "A Ruby library for parsing Visual Studio file formats."
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/vstudioide.rb')
38
+ rdoc.rdoc_files.include('lib/vstudioide/**/*.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 'vstudioide/version'
2
+ require 'vstudioide/solution'
@@ -0,0 +1,7 @@
1
+ class String
2
+
3
+ def begin?(other_str)
4
+ self.index(other_str) == 0
5
+ end
6
+
7
+ end
@@ -0,0 +1,33 @@
1
+ require 'vstudioide/core_ext/string'
2
+ require 'vstudioide/sln_node'
3
+
4
+
5
+ module VStudioIDE
6
+
7
+ class SLNDocument
8
+
9
+ attr_reader :global
10
+ attr_reader :projects
11
+
12
+ def initialize(io)
13
+ @global = nil
14
+ @projects = []
15
+ parse io
16
+ end
17
+
18
+ private
19
+ def parse(io)
20
+ while io.gets
21
+ $_.strip!
22
+
23
+ if $_ == "Global"
24
+ @global = SLNGlobalNode.new(io)
25
+ elsif $_.begin? "Project"
26
+ @projects << SLNProjectNode.new($_, io)
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,107 @@
1
+ require 'vstudioide/core_ext/string'
2
+ require 'vstudioide/sln_node_mixins'
3
+
4
+
5
+ module VStudioIDE
6
+
7
+ class SLNNode
8
+ end
9
+
10
+ class SLNGlobalNode < SLNNode
11
+ def initialize(io)
12
+ @sections = []
13
+ parse io
14
+ end
15
+
16
+ def [](arg)
17
+ return @sections[arg] if arg.is_a? Fixnum
18
+ @sections.each { |s| return s if s.type == arg }
19
+ nil
20
+ end
21
+
22
+ private
23
+ def parse(io)
24
+ while io.gets
25
+ $_.strip!
26
+ break if $_ == "EndGlobal"
27
+
28
+ if $_.begin? "GlobalSection"
29
+ @sections << SLNGlobalSectionNode.new($_, io)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ class SLNGlobalSectionNode < SLNNode
36
+ include SLNNodeMixin::TypedNode
37
+
38
+ def initialize(line, io)
39
+ @children = []
40
+ parse line, io
41
+ end
42
+
43
+ def each
44
+ @children.each { |c| yield c }
45
+ end
46
+
47
+ private
48
+ def parse(line, io)
49
+ line.slice!(0, "GlobalSection".length)
50
+ super
51
+
52
+ while io.gets
53
+ $_.strip!
54
+ break if $_ == "EndGlobalSection"
55
+
56
+ @children << $_
57
+ end
58
+ end
59
+ end
60
+
61
+ class SLNProjectNode < SLNNode
62
+ include SLNNodeMixin::TypedNode
63
+
64
+ def initialize(line, io)
65
+ @sections = []
66
+ parse line, io
67
+ end
68
+
69
+ private
70
+ def parse(line, io)
71
+ line.slice!(0, "Project".length)
72
+ super
73
+
74
+ while io.gets
75
+ $_.strip!
76
+ break if $_ == "EndProject"
77
+
78
+ if $_.begin? "ProjectSection"
79
+ @sections << SLNProjectSectionNode.new($_, io)
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ class SLNProjectSectionNode < SLNNode
86
+ include SLNNodeMixin::TypedNode
87
+
88
+ def initialize(line, io)
89
+ @children = []
90
+ parse line, io
91
+ end
92
+
93
+ private
94
+ def parse(line, io)
95
+ line.slice!(0, "ProjectSection".length)
96
+ super
97
+
98
+ while io.gets
99
+ $_.strip!
100
+ break if $_ == "EndProjectSection"
101
+
102
+ @children << $_
103
+ end
104
+ end
105
+ end
106
+
107
+ end
@@ -0,0 +1,37 @@
1
+ require 'vstudioide/core_ext/string'
2
+
3
+
4
+ module VStudioIDE
5
+ module SLNNodeMixin
6
+
7
+ module TypedNode
8
+
9
+ attr_reader :type
10
+ attr_reader :params
11
+
12
+ private
13
+ def parse(line, io)
14
+ if line.begin? '('
15
+ line.slice!(0, 1)
16
+
17
+ idx = line.index(')')
18
+ raise IOError, "End-of-type delimiter not found." if idx.nil?
19
+
20
+ @type = line.slice!(0, idx)
21
+
22
+ line.slice!(0, 1)
23
+ line.strip!
24
+ end
25
+
26
+ if line.begin? '='
27
+ line.slice!(0, 1)
28
+ line.strip!
29
+
30
+ @params = line.dup
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,116 @@
1
+ require 'vstudioide/sln_document'
2
+
3
+
4
+ module VStudioIDE
5
+
6
+ class Solution
7
+
8
+ def initialize(file)
9
+ @file = file
10
+ parse
11
+ end
12
+
13
+ def configurations
14
+ @sln.configurations
15
+ end
16
+
17
+ private
18
+ def parse
19
+ File.open(@file) do |io|
20
+ @sln = SLN.load(io)
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+
27
+ class SLN
28
+ @@formats = []
29
+
30
+ def self.inherited(format)
31
+ @@formats << format
32
+ end
33
+
34
+ def self.load(io)
35
+ # Loop until we read a line that begins with a word charachter. This
36
+ # scans past garbage that certain versions of Visual Studio put at the
37
+ # beginning of the file.
38
+ while io.gets
39
+ break if $_.match('\A\w')
40
+ end
41
+
42
+ sln = nil
43
+ version = $_.strip
44
+
45
+ @@formats.each do |format|
46
+ sln = format.new if format.loads? version
47
+ end
48
+ raise IOError, "Unrecognized Visual Studio solution format." if sln.nil?
49
+
50
+ sln.parse(io)
51
+ sln
52
+ end
53
+
54
+
55
+ def self.loads?(format)
56
+ false
57
+ end
58
+
59
+ def configurations
60
+ []
61
+ end
62
+ end
63
+
64
+ class SLNv8 < SLN
65
+ FORMAT = "Microsoft Visual Studio Solution File, Format Version 8.00".freeze
66
+
67
+ def self.loads?(format)
68
+ true if FORMAT == format
69
+ end
70
+
71
+ def parse(io)
72
+ @doc = SLNDocument.new(io)
73
+ end
74
+
75
+ def configurations
76
+ sc = @doc.global['SolutionConfiguration']
77
+ return [] if sc.nil?
78
+
79
+ configs = []
80
+
81
+ sc.each do |config|
82
+ idx = config.index('=')
83
+ configs << config.slice(0, idx).strip
84
+ end
85
+
86
+ return configs
87
+ end
88
+ end
89
+
90
+ class SLNv9 < SLN
91
+ FORMAT = "Microsoft Visual Studio Solution File, Format Version 9.00".freeze
92
+
93
+ def self.loads?(format)
94
+ true if FORMAT == format
95
+ end
96
+
97
+ def parse(io)
98
+ @doc = SLNDocument.new(io)
99
+ end
100
+
101
+ def configurations
102
+ sc = @doc.global['SolutionConfigurationPlatforms']
103
+ return [] if sc.nil?
104
+
105
+ configs = []
106
+
107
+ sc.each do |config|
108
+ idx = config.index('|')
109
+ configs << config.slice(0, idx).strip
110
+ end
111
+
112
+ return configs
113
+ end
114
+ end
115
+
116
+ end
@@ -0,0 +1,5 @@
1
+ module VStudioIDE
2
+
3
+ VERSION = '0.1.0'.freeze
4
+
5
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: vstudioide
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2008-01-19 00:00:00 -08:00
8
+ summary: A Ruby library for parsing Visual Studio file formats.
9
+ require_paths:
10
+ - lib
11
+ email: jaredhanson@gmail.com
12
+ homepage: http://vstudioide.rubyforge.org/
13
+ rubyforge_project: vstudioide
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Jared Hanson
31
+ files:
32
+ - LICENSE
33
+ - Rakefile
34
+ - README
35
+ - lib/vstudioide
36
+ - lib/vstudioide/core_ext
37
+ - lib/vstudioide/core_ext/string.rb
38
+ - lib/vstudioide/sln_document.rb
39
+ - lib/vstudioide/sln_node.rb
40
+ - lib/vstudioide/sln_node_mixins.rb
41
+ - lib/vstudioide/solution.rb
42
+ - lib/vstudioide/version.rb
43
+ - lib/vstudioide.rb
44
+ test_files: []
45
+
46
+ rdoc_options: []
47
+
48
+ extra_rdoc_files: []
49
+
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ requirements: []
55
+
56
+ dependencies: []
57
+