coconductor 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9b4cc3e36b81bf54501ef0faecde56bc6d9d56301bf329cb3d606145f5312b2
4
- data.tar.gz: ff6ded1918af2d981cc367cae83aa41c9dbe403c087ded3d33572ece20e76d05
3
+ metadata.gz: c5c5ff9d7faba7e4fdad45cacddaffcfee361aaa1382f2d607b846959d1547a0
4
+ data.tar.gz: a453031ce32a2926e4695b03611b4a538bc23009f06f6ca7183367abb0c3a468
5
5
  SHA512:
6
- metadata.gz: 85aab5538e5f66c2b25e6d9aa08112851334502e1888a6bbf8d7e1d9e6327345bd1b1f5646d68ecce8b066f842e456e4d037ff4954a13cf1e14c55abe1e7f691
7
- data.tar.gz: 2275c2792b3e9c012ac34ebb34daa4068aba46921fa86e2ba70fbb970b93dec488063a3b771cd2ce997a844950c353df12b2995c6370eb09b29373288f9a3466
6
+ metadata.gz: c59d42852ddfb4c84fba34b895e0bcb691f14833d15447c5b189d6a9485876ce338f7359e1bce8b9047ccd33f3a1b3464413fc3f25dd77a2334ef90aaea8af83
7
+ data.tar.gz: ccc6b1b5b353e6c9601d4dcc85ead0826c83494dbc8c683e37562bf0c4603b8d1a261bc5ec0f2465b03a9b64555e748fc7b602411d920f6052e8b07f00774091
@@ -15,7 +15,7 @@ module Coconductor
15
15
  # Returns the code of conduct specified by the key with version,
16
16
  # or the latest in the family if only the family is specified
17
17
  def find(key_or_family)
18
- return new('other') if key_or_family == 'other'
18
+ return new(key_or_family) if new(key_or_family).pseudo?
19
19
  match = all.find { |coc| coc.key == key_or_family }
20
20
  match || latest_in_family(key_or_family)
21
21
  end
@@ -32,7 +32,7 @@ module Coconductor
32
32
  key = path.relative_path_from(vendor_dir)
33
33
  matches = KEY_REGEX.match(key.to_path)
34
34
  matches.to_a.compact[1..-1].insert(1, 'version').join('/') if matches
35
- end
35
+ end.compact
36
36
  end
37
37
 
38
38
  def latest_in_family(family, language: DEFAULT_LANGUAGE)
@@ -82,7 +82,7 @@ module Coconductor
82
82
  def language
83
83
  @language ||= begin
84
84
  parts = key.split('/')
85
- if other?
85
+ if pseudo?
86
86
  nil
87
87
  elsif parts.last =~ /^[a-z-]{2,5}$/
88
88
  parts.last
@@ -124,7 +124,7 @@ module Coconductor
124
124
  end
125
125
 
126
126
  def family
127
- @family ||= key.split('/').first
127
+ @family ||= key.split('/').first unless none?
128
128
  end
129
129
 
130
130
  def contributor_covenant?
@@ -139,10 +139,21 @@ module Coconductor
139
139
  family == 'no-code-of-conduct'
140
140
  end
141
141
 
142
+ # The "other" code of conduct represents an unidentifiable code of conduct
142
143
  def other?
143
144
  key == 'other'
144
145
  end
145
146
 
147
+ # The "none" code of conduct represents the lack of a code of conduct
148
+ def none?
149
+ key == 'none'
150
+ end
151
+
152
+ # Code of conduct is an pseudo code of conduct (e.g., none, other)
153
+ def pseudo?
154
+ other? || none?
155
+ end
156
+
146
157
  def fields
147
158
  @fields ||= Field.from_code_of_conduct(self)
148
159
  end
@@ -178,7 +189,7 @@ module Coconductor
178
189
 
179
190
  # Raw content of code of conduct file, including TOML front matter
180
191
  def raw_content
181
- return if other?
192
+ return if pseudo?
182
193
  unless File.exist?(filepath)
183
194
  msg = "'#{key}' is not a valid code of conduct key"
184
195
  raise Coconductor::InvalidCodeOfConduct, msg
@@ -201,7 +212,7 @@ module Coconductor
201
212
  end
202
213
 
203
214
  def default_language?
204
- other? || language == DEFAULT_LANGUAGE
215
+ pseudo? || language == DEFAULT_LANGUAGE
205
216
  end
206
217
  end
207
218
  end
@@ -1,3 +1,3 @@
1
1
  module Coconductor
2
- VERSION = '0.6.2'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coconductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter