visual_studio 0.0.0.1 → 0.0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6891bd4f1a9085fae52467f5bed6cb34811db9c3
4
- data.tar.gz: eaac0c5a88ec84b0d4c2557e0f4e2f08839bc5bd
3
+ metadata.gz: ecf6432e82f273c61131810726bac356c0fdab8a
4
+ data.tar.gz: cf7b56e584955844acd2d0cac638d2d910114d04
5
5
  SHA512:
6
- metadata.gz: e1d832e5983dd2553dffb347019f0a3a2e2d79b228b2e9b9420de36533c0d396f46ceac2eaff1cfe991b6f0fceae8e50a04493d1ce13802b84e14269a3a5284b
7
- data.tar.gz: 2fd6b8ef6f648f20b6df6dc7b4d263aad2b36b74fcd75158e51135a2f5fb6a15dfad0d3c029d3cdb260aa7fa4a05711d418fb1e359380ffcb3d7f3d96e136525
6
+ metadata.gz: 22280b6319f9fcba3b50bd5ad74c16f3dbdc7f5f0c4e6cae0fb2b78eb8a49355dd2ec2ed301694ca03da63d618e88666f78079f85ebe9a7c5eb65c3e5069e501
7
+ data.tar.gz: 03a0052124bef8d0f74b07acf4cbb19a853dd2cdc9e887c85ef3d7660a64cab38e73db55d7b88d8e5af23ed67c560cb4a67f89a4d756f5c944e6bea68f8723d7
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
 
4
4
  # RubyGems
5
5
  *.gem
6
+ pkg/
data/lib/visual_studio.rb CHANGED
@@ -1,82 +1,43 @@
1
1
  require 'hashie'
2
2
 
3
- class VisualStudio
4
- NAMES = ['vs2015', 'vs2013', 'vs2012', 'vs2010', 'vs2008', 'vs2005', 'vs2003', 'vs2002', 'vs6']
5
- PRETTY_NAMES = ['Visual Studio 2015', 'Visual Studio 2013', 'Visual Studio 2012', 'Visual Studio 2010',
6
- 'Visual Studio 2008', 'Visual Studio 2005', 'Visual Studio .NET 2003', 'Visual Studio 6.0']
7
- VERSIONS = ['14.0', '12.0', '11.0', '10.0', '9.0', '8.0', '7.1', '7.0', '6.0']
8
- NAME_TO_VERSION = Hash[NAMES.zip(VERSIONS)]
9
- NAME_TO_PRETTY_NAME = Hash[NAMES.zip(PRETTY_NAMES)]
10
- VERSION_TO_NAME = Hash[VERSIONS.zip(NAMES)]
3
+ module VisualStudio
4
+ autoload :VERSION, 'visual_studio/version'
11
5
 
12
- attr_reader :name
13
- attr_reader :version
14
- attr_reader :install
15
- attr_reader :toolsets
16
- attr_reader :sdks
6
+ autoload :Name, 'visual_studio/name'
7
+ autoload :Install, 'visual_studio/install'
17
8
 
18
- def initialize(opts={})
19
- require 'visual_studio/name'
20
- @name = VisualStudio::Name.new(opts[:name], pretty: NAME_TO_PRETTY_NAME[opts[:name]])
21
- @version = opts[:version]
22
- @install = opts[:install]
23
- @toolsets = opts[:toolsets]
24
- @sdks = opts[:sdks]
25
- end
9
+ NAMES = [VisualStudio::Name.new('vs2015', pretty: 'Visual Studio 2015'),
10
+ VisualStudio::Name.new('vs2013', pretty: 'Visual Studio 2013'),
11
+ VisualStudio::Name.new('vs2012', pretty: 'Visual Studio 2012'),
12
+ VisualStudio::Name.new('vs2010', pretty: 'Visual Studio 2010'),
13
+ VisualStudio::Name.new('vs2008', pretty: 'Visual Studio 2008'),
14
+ VisualStudio::Name.new('vs2005', pretty: 'Visual Studio 2005'),
15
+ VisualStudio::Name.new('vs2003', pretty: 'Visual Studio .NET 2003'),
16
+ VisualStudio::Name.new('vs2003', pretty: 'Visual Studio .NET 2002'),
17
+ VisualStudio::Name.new('vs6', pretty: 'Visual Studio 6.0')]
18
+
19
+ VERSIONS = %w{14.0 12.0 11.0 10.0 9.0 8.0 7.1 7.0 6.0}
20
+
21
+ NAME_TO_VERSION = Hash[NAMES.zip(VERSIONS)]
22
+ VERSION_TO_NAME = Hash[VERSIONS.zip(NAMES)]
26
23
 
27
24
  def self.available?
28
- VERSIONS.any? { |version| installed?(version) }
25
+ VERSIONS.any? { |version| self.installed?(version) }
29
26
  end
30
27
 
31
28
  def self.installed?(name_or_version)
32
- !!(find(name_or_version))
29
+ VisualStudio::Install.exists?(name_or_version)
33
30
  end
34
31
 
35
32
  def self.find(name_or_version)
36
- return find_by_name(name_or_version) if NAMES.include?(name_or_version)
37
- return find_by_version(name_or_version) if VERSIONS.include?(name_or_version)
33
+ VisualStudio::Install.find(name_or_version)
38
34
  end
39
35
 
40
36
  def self.find_by_name(name)
41
- find_by_version(NAME_TO_VERSION[name]) if NAMES.include?(name)
37
+ VisualStudio::Install.find_by_name(name)
42
38
  end
43
39
 
44
40
  def self.find_by_version(version)
45
- install = _find_install_via_registry(version)
46
- return if install.nil?
47
-
48
- # HACK(mtwilliams): Assume C/C++ is installed.
49
- c_and_cpp = File.join(install, 'VC')
50
- # TODO(mtwilliams): Search for other toolsets, notably C#.
51
- csharp = nil # File.join(install, 'VC#')
52
-
53
- # TODO(mtwilliams): Look for SDKs, including packaged ones.
54
- sdk = nil # ...
55
-
56
- # TODO(mtwilliams): Cache.
57
- VisualStudio.new(name: VERSION_TO_NAME[version],
58
- version: version,
59
- install: install,
60
- toolsets: Hashie::Mash.new({
61
- c: c_and_cpp,
62
- cpp: c_and_cpp,
63
- csharp: csharp }),
64
- sdks: Hashie::Mash.new({
65
- windows: nil }))
41
+ VisualStudio::Install.find_by_version(version)
66
42
  end
67
-
68
- private
69
- def self._find_install_via_registry(version)
70
- # TODO(mtwilliams): Try other products, like C#.
71
- keys = ["SOFTWARE\\Microsoft\\VisualStudio\\#{version}\\Setup\\VC",
72
- "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\#{version}\\Setup\\VC"]
73
- keys.each do |key|
74
- begin
75
- require 'win32/registry'
76
- return File.expand_path(File.join(::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['ProductDir'], '..')).to_s
77
- rescue
78
- return nil
79
- end
80
- end
81
- end
82
43
  end
@@ -0,0 +1,69 @@
1
+ module VisualStudio
2
+ class Install
3
+ attr_reader :name
4
+ attr_reader :version
5
+ attr_reader :install
6
+ attr_reader :toolsets
7
+ attr_reader :sdks
8
+
9
+ def initialize(opts={})
10
+ @name = opts[:name]
11
+ @version = opts[:version]
12
+ @install = opts[:install]
13
+ @toolsets = opts[:toolsets]
14
+ @sdks = opts[:sdks]
15
+ end
16
+
17
+ def self.exists?(name_or_version)
18
+ !!(find(name_or_version))
19
+ end
20
+
21
+ def self.find(name_or_version)
22
+ return find_by_name(name_or_version) if NAMES.include?(name_or_version)
23
+ return find_by_version(name_or_version) if VERSIONS.include?(name_or_version)
24
+ end
25
+
26
+ def self.find_by_name(name)
27
+ find_by_version(NAME_TO_VERSION[name]) if NAMES.include?(name)
28
+ end
29
+
30
+ def self.find_by_version(version)
31
+ install = _find_install_via_registry(version)
32
+ return if install.nil?
33
+
34
+ # HACK(mtwilliams): Assume C/C++ is installed.
35
+ c_and_cpp = File.join(install, 'VC')
36
+ # TODO(mtwilliams): Search for other toolsets, notably C#.
37
+ csharp = nil # File.join(install, 'VC#')
38
+
39
+ # TODO(mtwilliams): Look for SDKs, including packaged ones.
40
+ sdk = nil # ...
41
+
42
+ # TODO(mtwilliams): Cache.
43
+ VisualStudio::Install.new(name: VERSION_TO_NAME[version],
44
+ version: version,
45
+ install: install,
46
+ toolsets: Hashie::Mash.new({
47
+ c: c_and_cpp,
48
+ cpp: c_and_cpp,
49
+ csharp: csharp }),
50
+ sdks: Hashie::Mash.new({
51
+ windows: nil }))
52
+ end
53
+
54
+ private
55
+ def self._find_install_via_registry(version)
56
+ # TODO(mtwilliams): Try other products, like C#.
57
+ keys = ["SOFTWARE\\Microsoft\\VisualStudio\\#{version}\\Setup\\VC",
58
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\#{version}\\Setup\\VC"]
59
+ keys.each do |key|
60
+ begin
61
+ require 'win32/registry'
62
+ return File.expand_path(File.join(::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['ProductDir'], '..')).to_s
63
+ rescue
64
+ return nil
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,9 +1,9 @@
1
- class VisualStudio
1
+ module VisualStudio
2
2
  class Name < String
3
3
  attr_reader :pretty
4
4
  def initialize(name, opts={})
5
5
  super(name)
6
- @pretty = opts[:pretty] || nil
6
+ @pretty = opts[:pretty] if opts[:pretty]
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,11 @@
1
+ class VisualStudio
2
+ module VERSION #:nodoc:
3
+ MAJOR, MINOR, PATCH, PRE = [0, 0, 0, 2]
4
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
5
+ end
6
+
7
+ # Returns the semantic version of `visual_studio`.
8
+ def self.version
9
+ VisualStudio::VERSION::STRING
10
+ end
11
+ end
@@ -1,9 +1,9 @@
1
1
  $:.push File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
2
- require 'visual_studio/gem/version'
2
+ require 'visual_studio/version'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'visual_studio'
6
- s.version = VisualStudio::Gem.version
6
+ s.version = VisualStudio.version
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.author = 'Michael Williams'
9
9
  s.email = 'm.t.williams@live.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visual_studio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.1
4
+ version: 0.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Williams
@@ -79,8 +79,9 @@ files:
79
79
  - README.md
80
80
  - Rakefile
81
81
  - lib/visual_studio.rb
82
- - lib/visual_studio/gem/version.rb
82
+ - lib/visual_studio/install.rb
83
83
  - lib/visual_studio/name.rb
84
+ - lib/visual_studio/version.rb
84
85
  - visual_studio.gemspec
85
86
  - visual_studio.sublime-project
86
87
  homepage: https://github.com/mtwilliams/visual_studio
@@ -1,13 +0,0 @@
1
- class VisualStudio
2
- module Gem
3
- module VERSION #:nodoc:
4
- MAJOR, MINOR, PATCH, PRE = [0, 0, 0, 1]
5
- STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
6
- end
7
-
8
- # Returns the semantic version of Visual Studio.
9
- def self.version
10
- VisualStudio::Gem::VERSION::STRING
11
- end
12
- end
13
- end