cross_platform_csproj 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENSE.txt +20 -20
  2. data/README.rdoc +15 -15
  3. data/lib/cross_platform_csproj.rb +167 -163
  4. metadata +39 -26
data/LICENSE.txt CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2013 Mark Wong
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2013 Mark Wong
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,15 +1,15 @@
1
- = cross_platform_csproj
2
-
3
- Tools for creating cross platform CSharp projects. Best for creating a common library that compiles to Windows, MonoDevelop and MonoTouch.
4
-
5
- Offers functions which synchronize the file and folder structure to a CSharp project. Users maintain a cross platform CSharp library using the file system. Running these functions will update CSProject files to any changes as done on the file system. This was particularly built for creating cross platform libraries that would work with Windows, MonoAndroid and MonoTouch.
6
-
7
- == Usage
8
-
9
- * files = FileList.new('Source/**/*.cs')
10
- * CrossPlatformCSProj::updateProject('Source/MyProject.csproj', files)
11
-
12
- == Copyright
13
-
14
- Copyright (c) 2013 Tyler Hamilton and Mark Wong. See LICENSE.txt for
15
- further details.
1
+ = cross_platform_csproj
2
+
3
+ Tools for creating cross platform CSharp projects. Best for creating a common library that compiles to Windows, MonoDevelop and MonoTouch.
4
+
5
+ Offers functions which synchronize the file and folder structure to a CSharp project. Users maintain a cross platform CSharp library using the file system. Running these functions will update CSProject files to any changes as done on the file system. This was particularly built for creating cross platform libraries that would work with Windows, MonoAndroid and MonoTouch.
6
+
7
+ == Usage
8
+
9
+ * files = FileList.new('Source/**/*.cs')
10
+ * CrossPlatformCSProj::updateProject('Source/MyProject.csproj', files)
11
+
12
+ == Copyright
13
+
14
+ Copyright (c) 2013 Tyler Hamilton and Mark Wong. See LICENSE.txt for
15
+ further details.
@@ -1,163 +1,167 @@
1
- require 'nokogiri'
2
-
3
- class CrossPlatformCSProj
4
-
5
- def self.updateProject(projectFile, fileList)
6
- if !File.exists?(projectFile)
7
- puts "CSProject file does not point to any file: #{projectFile}"
8
- end
9
-
10
- for file in fileList do
11
- if !File.exists?(file)
12
- puts "A file in the in the file list is not a valid file: #{fileList}"
13
- end
14
- end
15
-
16
- rootPath = File.dirname(projectFile).gsub('/', '\\')
17
- document = openDocument(projectFile)
18
- parent = getParentNode(document)
19
-
20
- if parent != nil
21
- parent.children.remove
22
-
23
- for file in fileList do
24
- compileNode = Nokogiri::XML::Node.new 'Compile', document
25
-
26
- parent.add_child(compileNode)
27
-
28
- relativeFile = getRelativePath(file, rootPath)
29
-
30
- compileNode.set_attribute('Include', relativeFile)
31
- end
32
- end
33
-
34
- saveDocument(document, projectFile)
35
- end
36
-
37
- private
38
-
39
- def self.openDocument(projectFile)
40
- fileHandle = File.open(projectFile)
41
- document = Nokogiri::XML(fileHandle) do |config|
42
- config.default_xml.noblanks
43
- end
44
- fileHandle.close
45
-
46
- return document
47
- end
48
-
49
- def self.saveDocument(document, projectFile)
50
- documentContents = document.to_xml(:indent => 4)
51
-
52
- fileHandle = File.open(projectFile)
53
- documentContentsOld = fileHandle.read
54
- fileHandle.close
55
-
56
- # Only write to the file if there has been changes. This will allow updateProject to be called many times without Visual Studio from needing to reload the project
57
- if documentContentsOld != documentContents
58
- fileHandle = File.open(projectFile, 'w')
59
- fileHandle.puts(documentContents)
60
- fileHandle.close
61
- end
62
- end
63
-
64
- def self.getParentNode(document)
65
- nodes = document.css('Project > ItemGroup')
66
- parentNode = nil
67
-
68
- for node in nodes do
69
- if (node.css('Compile').length > 0)
70
- if (parentNode != nil)
71
- puts "ERROR: more than one ItemGroup element has Compile elements"
72
- return nil
73
- end
74
-
75
- parentNode = node
76
- end
77
- if node.children.length == 0 && node.attributes.length == 0
78
- node.remove()
79
- end
80
- end
81
-
82
- if parentNode == nil
83
- projectNodes = document.css('Project')
84
-
85
- if projectNodes.length == 0
86
- puts 'ERROR: invalid CSharp project file'
87
- return nil
88
- end
89
-
90
- parentNode = Nokogiri::XML::Node.new('ItemGroup', document)
91
-
92
- projectNodes[0].add_child(parentNode)
93
- end
94
-
95
- return parentNode
96
- end
97
-
98
- def self.getRelativePath(path, pathRelative)
99
- pathRelative = pathRelative.gsub('/', '\\')
100
- path = path.gsub('/', '\\')
101
-
102
- if path.start_with?(pathRelative)
103
- path = path[pathRelative.length..path.length - 1]
104
- end
105
-
106
- if (path.length > 0 and path.start_with?('\\'))
107
- return path[1..path.length - 1]
108
- end
109
-
110
- return path
111
- end
112
-
113
- def self.getCoreFiles(path = '.')
114
- fileList = FileList.new()
115
-
116
- fileList.include("#{path}/**/*.cs")
117
-
118
- return fileList
119
- end
120
-
121
- def self.getAndroidFiles(path = '.')
122
- fileList = getCoreFiles(path);
123
-
124
- fileList.exclude("#{path}/**/IOS/**/*.cs")
125
- fileList.exclude("#{path}/**/Windows/**/*.cs")
126
-
127
- fileList.exclude("#{path}/**/*.IOS.cs")
128
- fileList.exclude("#{path}/**/*.Windows.cs")
129
-
130
- return fileList;
131
- end
132
-
133
- def self.getIOSFiles(path = '.')
134
- fileList = getCoreFiles(path);
135
-
136
- fileList.exclude("#{path}/**/Android/**/*.cs")
137
- fileList.exclude("#{path}/**/Windows/**/*.cs")
138
-
139
- fileList.exclude("#{path}/**/*.Android.cs")
140
- fileList.exclude("#{path}/**/*.Windows.cs")
141
-
142
- fileList.exclude("#{path}/**/Resource.Designer.cs")
143
- fileList.exclude("#{path}/**/Resource.designer.cs")
144
-
145
- return fileList;
146
- end
147
-
148
- def self.getWindowsFiles(path = '.')
149
- fileList = getCoreFiles(path);
150
-
151
- fileList.exclude("#{path}/**/Android/**/*.cs")
152
- fileList.exclude("#{path}/**/IOS/**/*.cs")
153
-
154
- fileList.exclude("#{path}/**/*.Android.cs")
155
- fileList.exclude("#{path}/**/*.IOS.cs")
156
-
157
- fileList.exclude("#{path}/**/Resource.Designer.cs")
158
- fileList.exclude("#{path}/**/Resource.designer.cs")
159
-
160
- return fileList;
161
- end
162
-
163
- end
1
+ require 'nokogiri'
2
+
3
+ class CrossPlatformCSProj
4
+
5
+ def self.updateProject(projectFile, fileList)
6
+ if !File.exists?(projectFile)
7
+ puts "CSProject file does not point to any file: #{projectFile}"
8
+ end
9
+
10
+ for file in fileList do
11
+ if !File.exists?(file)
12
+ puts "A file in the in the file list is not a valid file: #{fileList}"
13
+ end
14
+ end
15
+
16
+ rootPath = File.dirname(projectFile).gsub('/', '\\')
17
+ document = openDocument(projectFile)
18
+ parent = getParentNode(document)
19
+
20
+ if parent != nil
21
+ parent.children.remove
22
+
23
+ for file in fileList do
24
+ compileNode = Nokogiri::XML::Node.new 'Compile', document
25
+
26
+ parent.add_child(compileNode)
27
+
28
+ relativeFile = getRelativePath(file, rootPath)
29
+
30
+ compileNode.set_attribute('Include', relativeFile)
31
+ end
32
+ end
33
+
34
+ saveDocument(document, projectFile)
35
+ end
36
+
37
+ private
38
+
39
+ def self.openDocument(projectFile)
40
+ fileHandle = File.open(projectFile)
41
+ document = Nokogiri::XML(fileHandle) do |config|
42
+ config.default_xml.noblanks
43
+ end
44
+ fileHandle.close
45
+
46
+ return document
47
+ end
48
+
49
+ def self.saveDocument(document, projectFile)
50
+ documentContents = document.to_xml(:indent => 4)
51
+
52
+ fileHandle = File.open(projectFile)
53
+ documentContentsOld = fileHandle.read
54
+ fileHandle.close
55
+
56
+ # Only write to the file if there has been changes. This will allow updateProject to be called many times without Visual Studio from needing to reload the project
57
+ if documentContentsOld != documentContents
58
+ fileHandle = File.open(projectFile, 'w')
59
+ fileHandle.puts(documentContents)
60
+ fileHandle.close
61
+ end
62
+ end
63
+
64
+ def self.getParentNode(document)
65
+ nodes = document.css('Project > ItemGroup')
66
+ parentNode = nil
67
+
68
+ for node in nodes do
69
+ if (node.css('Compile').length > 0)
70
+ if (parentNode != nil)
71
+ puts "ERROR: more than one ItemGroup element has Compile elements"
72
+ return nil
73
+ end
74
+
75
+ parentNode = node
76
+ end
77
+ if node.children.length == 0 && node.attributes.length == 0
78
+ node.remove()
79
+ end
80
+ end
81
+
82
+ if parentNode == nil
83
+ projectNodes = document.css('Project')
84
+
85
+ if projectNodes.length == 0
86
+ puts 'ERROR: invalid CSharp project file'
87
+ return nil
88
+ end
89
+
90
+ parentNode = Nokogiri::XML::Node.new('ItemGroup', document)
91
+
92
+ projectNodes[0].add_child(parentNode)
93
+ end
94
+
95
+ return parentNode
96
+ end
97
+
98
+ def self.getRelativePath(path, pathRelative)
99
+ pathRelative = pathRelative.gsub('/', '\\')
100
+ path = path.gsub('/', '\\')
101
+
102
+ if path.start_with?(pathRelative)
103
+ path = path[pathRelative.length..path.length - 1]
104
+ end
105
+
106
+ if (path.length > 0 and path.start_with?('\\'))
107
+ return path[1..path.length - 1]
108
+ end
109
+
110
+ return path
111
+ end
112
+
113
+ def self.getCoreFiles(path = '.')
114
+ fileList = FileList.new()
115
+
116
+ fileList.include("#{path}/**/*.cs")
117
+
118
+ return fileList
119
+ end
120
+
121
+ def self.getAndroidFiles(path = '.')
122
+ fileList = getCoreFiles(path);
123
+
124
+ fileList.exclude("#{path}/**/iOS/**/*.cs")
125
+ fileList.exclude("#{path}/**/IOS/**/*.cs")
126
+ fileList.exclude("#{path}/**/Windows/**/*.cs")
127
+
128
+ fileList.exclude("#{path}/**/*.iOS.cs")
129
+ fileList.exclude("#{path}/**/*.IOS.cs")
130
+ fileList.exclude("#{path}/**/*.Windows.cs")
131
+
132
+ return fileList;
133
+ end
134
+
135
+ def self.getIOSFiles(path = '.')
136
+ fileList = getCoreFiles(path);
137
+
138
+ fileList.exclude("#{path}/**/Android/**/*.cs")
139
+ fileList.exclude("#{path}/**/Windows/**/*.cs")
140
+
141
+ fileList.exclude("#{path}/**/*.Android.cs")
142
+ fileList.exclude("#{path}/**/*.Windows.cs")
143
+
144
+ fileList.exclude("#{path}/**/Resource.Designer.cs")
145
+ fileList.exclude("#{path}/**/Resource.designer.cs")
146
+
147
+ return fileList;
148
+ end
149
+
150
+ def self.getWindowsFiles(path = '.')
151
+ fileList = getCoreFiles(path);
152
+
153
+ fileList.exclude("#{path}/**/Android/**/*.cs")
154
+ fileList.exclude("#{path}/**/iOS/**/*.cs")
155
+ fileList.exclude("#{path}/**/IOS/**/*.cs")
156
+
157
+ fileList.exclude("#{path}/**/*.Android.cs")
158
+ fileList.exclude("#{path}/**/*.iOS.cs")
159
+ fileList.exclude("#{path}/**/*.IOS.cs")
160
+
161
+ fileList.exclude("#{path}/**/Resource.Designer.cs")
162
+ fileList.exclude("#{path}/**/Resource.designer.cs")
163
+
164
+ return fileList;
165
+ end
166
+
167
+ end
metadata CHANGED
@@ -1,51 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cross_platform_csproj
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 8
9
+ version: 0.0.8
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Tyler Hamilton, Mark Wong
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
16
+
17
+ date: 2013-03-01 00:00:00 -08:00
18
+ default_executable:
13
19
  dependencies: []
14
- description: Offers functions which synchronize the file and folder structure to a
15
- CSharp project. Users maintain a cross platform CSharp library using the file system. Running
16
- these functions will update CSProject files to any changes as done on the file system. This
17
- is particularly useful for creating cross platform libraries that would work with
18
- Windows, MonoAndroid and MonoTouch.
20
+
21
+ description: Offers functions which synchronize the file and folder structure to a CSharp project. Users maintain a cross platform CSharp library using the file system. Running these functions will update CSProject files to any changes as done on the file system. This is particularly useful for creating cross platform libraries that would work with Windows, MonoAndroid and MonoTouch.
19
22
  email: xqdeveloper@gmail.com
20
23
  executables: []
24
+
21
25
  extensions: []
26
+
22
27
  extra_rdoc_files: []
23
- files:
28
+
29
+ files:
24
30
  - lib/cross_platform_csproj.rb
25
31
  - README.rdoc
26
32
  - LICENSE.txt
33
+ has_rdoc: true
27
34
  homepage: http://github.com/markslwong/CrossPlatformCSProj
28
35
  licenses: []
36
+
29
37
  post_install_message:
30
38
  rdoc_options: []
31
- require_paths:
39
+
40
+ require_paths:
32
41
  - lib
33
- required_ruby_version: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
39
- required_rubygems_version: !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
45
56
  requirements: []
57
+
46
58
  rubyforge_project:
47
- rubygems_version: 1.8.25
59
+ rubygems_version: 1.3.6
48
60
  signing_key:
49
61
  specification_version: 3
50
62
  summary: Tools for creating cross platform CSharp projects.
51
63
  test_files: []
64
+