getv 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: daa14a57206ce36f42d7373647539e9a3718422bade081044c4f6b38129fb23a
4
- data.tar.gz: a1bbbb5d1c6c5609611d12590760dad98cdb1f2e89a3d6ba92e05ba92d03d0eb
3
+ metadata.gz: 4f71f37db6e179d3af3b99369ea5ed0f18f9b11fdfb61cb49b3fddb41c154413
4
+ data.tar.gz: c8519d3d87fbb86265e1b77370213f5e41bdd19f205b731691a354b156c5d275
5
5
  SHA512:
6
- metadata.gz: a0329d396ff28c22ddaf272872298b80660d41ad44fe5504740721ae8f4797fcb009e30cda8c334e7f611589b34e82e5f050846865d9ba6a9b0c9c65e2d126ab
7
- data.tar.gz: 5463da5acef0fe03dd77dd54135ac393f34876c3108d957bd9016fafd2d903754ae725f34c1b41a50300c8c4ab3bd5752066560a59fa997bf6885ee3d25daaa4
6
+ metadata.gz: 8ce6bc17082dd898e433702e395ab2b12432fb5e72d4d287fa5c55210b234cf6f7a324a07fceee1b1b452c24f1309f8ff801a10502012de238f143be0a507422
7
+ data.tar.gz: c5d3ff7f4ae2fe63221c6a31f841da8f85f509579abb1a937c07ba2eb35c3b6432026353d456b45bd3857e051f7e3f3dd2e0b33dbc68ad61c3667b84fe9bedfb
data/lib/getv/package.rb CHANGED
@@ -11,12 +11,16 @@ module Getv
11
11
  elsif /python.*-.*/.match?(name)
12
12
  opts = {'type' => 'pypi'}.merge(opts)
13
13
  end
14
+ if opts[:type] == 'github_commit'
15
+ opts = {
16
+ :select_search => '^((\d{8})(\d{6}),(([a-z\d]{7})(.*)))$',
17
+ :semantic_only => false
18
+ }.merge(opts)
19
+ end
14
20
  opts = {
15
21
  :type => 'github_release',
16
- :select => {
17
- :search => '^\s*v?((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)\s*$',
18
- :replace => '\1'
19
- },
22
+ :select_search => '^\s*v?((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)\s*$',
23
+ :select_replace => '\1',
20
24
  :reject => nil,
21
25
  :semantic_only => true,
22
26
  :semantic_select => ['*'],
@@ -62,6 +66,8 @@ module Getv
62
66
  versions = get_versions_using_gem
63
67
  when 'get'
64
68
  versions = get_versions_using_get
69
+ when 'github_commit'
70
+ versions = get_versions_using_github('commit')
65
71
  when 'github_release'
66
72
  versions = get_versions_using_github('release')
67
73
  when 'github_tag'
@@ -73,9 +79,12 @@ module Getv
73
79
  when 'pypi'
74
80
  versions = get_versions_using_pypi
75
81
  end
76
- select_pattern = Regexp.new(opts[:select][:search])
82
+ if opts[:type] == 'github_commit'
83
+ versions.sort!
84
+ end
85
+ select_pattern = Regexp.new(opts[:select_search])
77
86
  versions.select! {|v| v =~ select_pattern}
78
- versions.map! {|v| v.sub(select_pattern, opts[:select][:replace])}
87
+ versions.map! {|v| v.sub(select_pattern, opts[:select_replace])}
79
88
  unless opts[:reject].nil?
80
89
  versions.reject! {|v| v =~ Regexp.new(opts[:reject])}
81
90
  end
@@ -88,7 +97,9 @@ module Getv
88
97
  end
89
98
  versions.sort_by! {|v| Semantic::Version.new(v)}
90
99
  else
91
- versions.sort!
100
+ unless opts[:type] == 'github_commit'
101
+ versions.sort!
102
+ end
92
103
  end
93
104
  opts[:versions] = versions
94
105
  unless opts[:versions].empty?
@@ -128,6 +139,10 @@ module Getv
128
139
  end
129
140
  if method == 'release'
130
141
  return github.releases("#{opts[:owner]}/#{opts[:repo]}").map{|r| r.tag_name}
142
+ elsif method == 'commit'
143
+ return github.commits("#{opts[:owner]}/#{opts[:repo]}").map { |c|
144
+ "#{DateTime.parse(c[:commit][:author][:date].to_s).strftime('%Y%m%d%H%M%S')},#{c[:sha]}"
145
+ }
131
146
  else
132
147
  return github.tags("#{opts[:owner]}/#{opts[:repo]}").map{|t| t[:name]}
133
148
  end
data/lib/getv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Getv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.0.3
148
+ rubygems_version: 3.2.22
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Pull package version numbers from the web in various ways.