nuget_helper 0.3.0 → 1.0.0

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: 17bc3cb79c09f5b46812e5efc013cc5329ce8e38
4
- data.tar.gz: 20e8f0babfc0ef329e92d51ad10898380bc5d944
3
+ metadata.gz: 950599a0150850fa1c92062930a9a70fac8cc558
4
+ data.tar.gz: 51663a88008e657cae46a8b3916ce0560d2c7391
5
5
  SHA512:
6
- metadata.gz: 5a2c94f023f523deb513854de9e8d17b313c3aff2869efb0023fcd7a07fa39462f75c3aedb55046cc51cf08d2f78936138d40059a16dc6f2a505b3273ecd27ee
7
- data.tar.gz: 59cbea9d048d9ab92dac5db04a87e86a1b28cb4cb56243e859639d297c4b4fa7ca852a60c84ccd01f8db6ed51088533f4572cdde44b74b4078398c0c5512afcc
6
+ metadata.gz: ea9164f05c1bd0c7c6233d836d1325060d24d89a66d23ae730dc912cc08d8171102558b23604923dace2c422e1aca3cf7ab70d0f185659b0c1f65c0cacb0112a
7
+ data.tar.gz: 4e040a2156cfb945672038075d8ffebd1c236d45c8acbfa1ec0f13577a3369f7ceb9cf5e3f98911b8d5f186078442ffb7972b6798f8bc01d7c8614ef1e39f1d6
data/lib/nuget_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require_relative "./nuget_helper/version"
2
+ require_relative "./nuget_helper/nuspec"
2
3
  require "open3"
4
+ require "semver"
3
5
 
4
6
  module NugetHelper
5
7
  def self.exec(parameters)
@@ -57,7 +59,7 @@ module NugetHelper
57
59
  end
58
60
 
59
61
  def self.version_of(file)
60
- file.gsub(/[a-zA-Z]\.?/,'').split(/\./).map do |i| i.to_i end.to_a
62
+ SemVer.parse(file.gsub(/\.nupkg$/, ''))
61
63
  end
62
64
 
63
65
  def self.last_version(files)
@@ -0,0 +1,18 @@
1
+ require "nokogiri"
2
+ require "semver"
3
+ module NugetHelper
4
+ class NuSpec
5
+ attr_reader :nuspec_path_base, :nuspec_filename, :nuspec_xml_node
6
+
7
+ def initialize nuspec_path
8
+ raise ArgumentError, 'nuspec path does not exist' unless File.exists? nuspec_path.to_s
9
+ nuspec_path = nuspec_path.to_s unless nuspec_path.is_a? String
10
+ @nuspec_xml_node = Nokogiri.XML(open(nuspec_path))
11
+ @nuspec_path_base, @nuspec_filename = File.split nuspec_path
12
+ end
13
+ def version
14
+ el = @nuspec_xml_node.xpath("/package/metadata/version")
15
+ SemVer.parse(el.text)
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module NugetHelper
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/nuget_helper.gemspec CHANGED
@@ -21,4 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
  spec.add_development_dependency 'rspec', '>= 3.2'
23
23
  spec.add_dependency "nuget", '~> 2.8.50126.400'
24
+ spec.add_dependency 'semver2', '~> 3.4'
25
+ spec.add_dependency 'nokogiri', '~> 1.5' # used to manipulate and read *nuspec files
26
+
24
27
  end
@@ -1,30 +1,37 @@
1
1
  require_relative 'spec_helper'
2
-
2
+ require "semver"
3
3
  describe "NugetHelper" do
4
- describe "with restored packages" do
5
- let(:xunit_versions) do
6
- ["xunit.runners.1.9.3","xunit.runners.1.9.2","xunit.runners.1.9.1"]
7
- end
8
- let(:nunit_versions) do
9
- ["nunit.runners.2.6.1","nunit.runners.2.6.4","nunit.runners.2.3.6","nunit.runners.1.9.1"]
10
- end
4
+ describe "with restored packages" do
5
+ let(:xunit_versions) do
6
+ ["xunit.runners.1.9.3","xunit.runners.1.9.2","xunit.runners.1.9.1"]
7
+ end
8
+ let(:nunit_versions) do
9
+ ["nunit.runners.2.6.1","nunit.runners.2.6.4","nunit.runners.2.3.6","nunit.runners.1.9.1"]
10
+ end
11
11
 
12
12
 
13
- it "can find latest xunit" do
14
- xunit = xunit_versions.sort_by do |xunit| NugetHelper.version_of xunit end.last
15
- expect(xunit).to eq 'xunit.runners.1.9.3'
16
- end
17
- it "can find latest nunit" do
18
- xunit = nunit_versions.sort_by do |nunit| NugetHelper.version_of nunit end.last
19
- expect(xunit).to eq 'nunit.runners.2.6.4'
20
- end
13
+ it "can find latest xunit" do
14
+ xunit = xunit_versions.sort_by do |xunit| NugetHelper.version_of xunit end.last
15
+ expect(xunit).to eq 'xunit.runners.1.9.3'
16
+ end
17
+ it "can find latest nunit" do
18
+ xunit = nunit_versions.sort_by do |nunit| NugetHelper.version_of nunit end.last
19
+ expect(xunit).to eq 'nunit.runners.2.6.4'
20
+ end
21
21
 
22
- it "can parse out version" do
23
- expect( NugetHelper.version_of 'somelib.something.35.63.7').to eq [35,63,7]
24
- end
22
+ it "can parse out version" do
23
+ expect( NugetHelper.version_of 'somelib.something.35.63.7').to eq SemVer.new(35,63,7)
24
+ end
25
+ it "can parse out version of beta package" do
26
+ expect( NugetHelper.version_of 'somelib.something.35.63.7-beta.nupkg').to eq SemVer.new(35,63,7,'beta')
27
+ end
28
+
29
+ it "can determine latest version of" do
30
+ expect( NugetHelper.last_version ['With.0.4.7.nupkg','With.1.0.2.nupkg','With.1.0.1.nupkg']).to eq 'With.1.0.2.nupkg'
31
+ end
25
32
 
26
- it "can determine latest version of" do
27
- expect( NugetHelper.last_version ['With.0.4.7.nupkg','With.1.0.2.nupkg','With.1.0.1.nupkg']).to eq 'With.1.0.2.nupkg'
28
- end
33
+ it "can handle semver versions as well" do
34
+ expect( NugetHelper.last_version ['With.0.4.7.nupkg','With.1.0.2.nupkg','With.1.0.3-beta.nupkg','With.1.0.1.nupkg']).to eq 'With.1.0.3-beta.nupkg'
29
35
  end
36
+ end
30
37
  end
@@ -2,69 +2,69 @@ require_relative 'spec_helper'
2
2
  $vs_2013_solution = File.join(File.dirname(__FILE__), "Vs2013Solution", "Vs2013Solution.sln")
3
3
 
4
4
  describe "NugetHelper" do
5
- describe "execute system nuget" do
6
- it "can restore packages" do
7
- NugetHelper.exec("restore #{$vs_2013_solution}")
8
- end
5
+ describe "execute system nuget" do
6
+ it "can restore packages" do
7
+ NugetHelper.exec("restore #{$vs_2013_solution}")
8
+ end
9
9
 
10
- describe "with restored packages" do
11
- before(:all) do
12
- NugetHelper.exec("restore #{$vs_2013_solution}")
13
- end
10
+ describe "with restored packages" do
11
+ before(:all) do
12
+ NugetHelper.exec("restore #{$vs_2013_solution}")
13
+ end
14
14
 
15
- it "can run nunit runner" do
16
- cmd = NugetHelper.nunit_path
17
- help = Gem.win_platform? ? "/help" : "-help"
18
- NugetHelper.run_tool cmd, help
19
- expect($?.success?).to be true
20
- end
15
+ it "can run nunit runner" do
16
+ cmd = NugetHelper.nunit_path
17
+ help = Gem.win_platform? ? "/help" : "-help"
18
+ NugetHelper.run_tool cmd, help
19
+ expect($?.success?).to be true
20
+ end
21
21
 
22
- it "can run nunit runner and get result" do
23
- cmd = NugetHelper.nunit_path
24
- help = Gem.win_platform? ? "/help" : "-help"
25
- res= NugetHelper.run_tool_with_result cmd, help
26
- expect(res).not_to be_empty
27
- end
22
+ it "can run nunit runner and get result" do
23
+ cmd = NugetHelper.nunit_path
24
+ help = Gem.win_platform? ? "/help" : "-help"
25
+ res= NugetHelper.run_tool_with_result cmd, help
26
+ expect(res).not_to be_empty
27
+ end
28
28
 
29
- it "can run nunit runner and fail" do
30
- cmd = NugetHelper.nunit_path
31
- expect { NugetHelper.run_tool_with_result "xxxyyy" }.to raise_error
32
- end
29
+ it "can run nunit runner and fail" do
30
+ cmd = NugetHelper.nunit_path
31
+ expect { NugetHelper.run_tool_with_result "xxxyyy" }.to raise_error
32
+ end
33
33
 
34
- it "can run xunit2 runner" do
35
- cmd = NugetHelper.xunit2_path
36
- c = NugetHelper.run_tool cmd
37
- expect(c).to be false
38
- expect($?.exitstatus).to be 1
39
- end
34
+ it "can run xunit2 runner" do
35
+ cmd = NugetHelper.xunit2_path
36
+ c = NugetHelper.run_tool cmd
37
+ expect(c).to be false
38
+ expect($?.exitstatus).to be 1
39
+ end
40
40
 
41
- it "can run xunit clr4 runner" do
42
- cmd = NugetHelper.xunit_clr4_path
43
- c = NugetHelper.run_tool cmd
44
- expect(c).to be false
45
- #expect($?.exitstatus).to be 1
46
- end
41
+ it "can run xunit clr4 runner" do
42
+ cmd = NugetHelper.xunit_clr4_path
43
+ c = NugetHelper.run_tool cmd
44
+ expect(c).to be false
45
+ #expect($?.exitstatus).to be 1
46
+ end
47
47
 
48
- it "can run mspec runner" do
49
- cmd = NugetHelper.mspec_path
50
- c = NugetHelper.run_tool cmd
51
- expect(c).to be false
52
- expect($?.exitstatus).to be 1
53
- end
48
+ it "can run mspec runner" do
49
+ cmd = NugetHelper.mspec_path
50
+ c = NugetHelper.run_tool cmd
51
+ expect(c).to be false
52
+ expect($?.exitstatus).to be 1
53
+ end
54
54
 
55
- it "can run mspec clr4 runner" do
56
- cmd = NugetHelper.mspec_clr4_path
57
- c = NugetHelper.run_tool cmd
58
- expect(c).to be false
59
- expect($?.exitstatus).to be 1
60
- end
55
+ it "can run mspec clr4 runner" do
56
+ cmd = NugetHelper.mspec_clr4_path
57
+ c = NugetHelper.run_tool cmd
58
+ expect(c).to be false
59
+ expect($?.exitstatus).to be 1
60
+ end
61
61
 
62
- it "can run nspec runner" do
63
- cmd = NugetHelper.nspec_path
64
- c = NugetHelper.run_tool cmd
65
- expect(c).to be true
66
- expect($?.exitstatus).to be 0
67
- end
68
- end
62
+ it "can run nspec runner" do
63
+ cmd = NugetHelper.nspec_path
64
+ c = NugetHelper.run_tool cmd
65
+ expect(c).to be true
66
+ expect($?.exitstatus).to be 0
67
+ end
69
68
  end
69
+ end
70
70
  end
@@ -0,0 +1,14 @@
1
+ require_relative 'spec_helper'
2
+ require "semver"
3
+
4
+ describe "NuSpec" do
5
+ subject do
6
+ root_folder = File.expand_path(File.join(File.dirname(__FILE__),'nuspecs'))
7
+ NugetHelper::NuSpec.new( File.join(root_folder, "example.nuspec"))
8
+ end
9
+
10
+ it 'should have a version' do
11
+ expect(subject.version).to eq SemVer.new(1,2,3)
12
+ end
13
+ end
14
+
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0"?>
2
+ <package >
3
+ <metadata>
4
+ <id>Example</id>
5
+ <version>1.2.3</version>
6
+ <authors>Mr.Example</authors>
7
+ <owners>Ms.Example</owners>
8
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
9
+ <description>Example package</description>
10
+ <releaseNotes>Used for specs</releaseNotes>
11
+ <copyright>none</copyright>
12
+ <tags>example spec</tags>
13
+ </metadata>
14
+ </package>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuget_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oskar Gewalli
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.8.50126.400
69
+ - !ruby/object:Gem::Dependency
70
+ name: semver2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.5'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.5'
69
97
  description:
70
98
  email:
71
99
  - gewalli@gmail.com
@@ -84,6 +112,7 @@ files:
84
112
  - Rakefile
85
113
  - appveyor.yml
86
114
  - lib/nuget_helper.rb
115
+ - lib/nuget_helper/nuspec.rb
87
116
  - lib/nuget_helper/version.rb
88
117
  - nuget_helper.gemspec
89
118
  - spec/Vs2013Solution/.gitignore
@@ -94,6 +123,8 @@ files:
94
123
  - spec/Vs2013Solution/Vs2013Solution.sln
95
124
  - spec/get_version_of_spec.rb
96
125
  - spec/nuget_exec_spec.rb
126
+ - spec/nuspec_spec.rb
127
+ - spec/nuspecs/example.nuspec
97
128
  - spec/spec_helper.rb
98
129
  homepage: https://github.com/wallymathieu/nuget_helper
99
130
  licenses:
@@ -128,4 +159,6 @@ test_files:
128
159
  - spec/Vs2013Solution/Vs2013Solution.sln
129
160
  - spec/get_version_of_spec.rb
130
161
  - spec/nuget_exec_spec.rb
162
+ - spec/nuspec_spec.rb
163
+ - spec/nuspecs/example.nuspec
131
164
  - spec/spec_helper.rb