coconductor 0.2.0 → 0.3.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: 2ee61b32a0da6ae5579a75cd3b779173aff62ade67bda32a9c4ea8ec0e00bdb8
4
- data.tar.gz: 1cf3bc17142ea6391af0e7187ccbdc74c0fe861c5c1c4aeea41419589ed36940
3
+ metadata.gz: 7bffa46bb8fa4dc61efcf0dbb3c1fbe52a15bd4d3beb7fd308022991dca191b1
4
+ data.tar.gz: 80cb1d7157a189e0ace506bd69da8d4bf1491b61b77549b3a3fab93024ff8858
5
5
  SHA512:
6
- metadata.gz: 50806e9b4da9c93fb9fba54c244d6885a6a83ce095f8e452b66d36c40e977fc2a8bfefbea1d0bc369fee52c7695ff3f734d4eb371310dd4e9ab757ad4c828eab
7
- data.tar.gz: cdb29b720102a2654045e188d3d2c30bdd6f0d3f408d26b9a63adeaf6c5ac19f77edf5e432c192c6e1081a7fc61de3c6e11365e251abe81ca9a7faf8127406ec
6
+ metadata.gz: ae28338a6e309678acdb61215a1061735b854d5f74b69f2937708c139523f3cd7d5c2cc47b87c2e499e97b9f12400cfeb512c4316dbcb01a71bff277659baa24
7
+ data.tar.gz: 7083ef079b5c2ef32c65f1f2993431b5b87962b1115b1ebdf12772b0cc421094dd7652b69d955c41834bdab212d457f77713cbc02771e5d20b292fbc5f81b967
data/README.md CHANGED
@@ -45,10 +45,14 @@ project.code_of_conduct_file.confidence
45
45
  ### Command line
46
46
 
47
47
  ```
48
- coconductor detect [PATH] # Detect the code of conduct of the given project
49
- coconductor diff [PATH] # Compare the given code of conduct text to a known code of conduct
50
- coconductor help [COMMAND] # Describe available commands or one specific command
51
- coconductor version # Return the Coconductor version
48
+ Coconductor commands:
49
+ coconductor detect [PATH] # Detect the code of conduct of the given project
50
+ coconductor diff [PATH] # Compare the given code of conduct text to a known code of conduct
51
+ coconductor help [COMMAND] # Describe available commands or one specific command
52
+ coconductor version # Return the Coconductor version
53
+
54
+ Options:
55
+ [--remote], [--no-remote] # Assume PATH is a GitHub owner/repo path
52
56
  ```
53
57
 
54
58
  #### Example output
data/bin/coconductor CHANGED
@@ -2,15 +2,22 @@
2
2
 
3
3
  require_relative '../lib/coconductor'
4
4
  require 'thor'
5
+ require 'octokit'
5
6
 
6
7
  class CoconductorCLI < Thor
7
8
  package_name 'Coconductor'
8
9
  default_task :detect
10
+ class_option :remote, type: :boolean,
11
+ desc: 'Assume PATH is a GitHub owner/repo path'
9
12
 
10
13
  private
11
14
 
12
15
  def path
13
- args.first || Dir.pwd
16
+ @path ||= if remote?
17
+ "https://github.com/#{args.first}"
18
+ else
19
+ args.first || Dir.pwd
20
+ end
14
21
  end
15
22
 
16
23
  def project
@@ -24,6 +31,10 @@ class CoconductorCLI < Thor
24
31
  def code_of_conduct_file
25
32
  project.code_of_conduct_file
26
33
  end
34
+
35
+ def remote?
36
+ options[:remote] || path =~ %r{^https://}
37
+ end
27
38
  end
28
39
 
29
40
  commands_dir = File.expand_path '../lib/coconductor/commands/', __dir__
data/coconductor.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.add_dependency 'licensee', '~> 9.9', '>= 9.9.3'
26
+ spec.add_dependency 'licensee', '~> 9.9', '>= 9.9.4'
27
27
  spec.add_dependency 'thor', '~> 0.20'
28
28
  spec.add_dependency 'toml', '~> 0.2'
29
29
 
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'pry', '~> 0.10'
32
32
  spec.add_development_dependency 'rspec', '~> 3.0'
33
33
  spec.add_development_dependency 'rubocop', '~> 0.50'
34
+ spec.add_development_dependency 'webmock', '~> 3.1'
34
35
  end
data/lib/coconductor.rb CHANGED
@@ -21,7 +21,11 @@ module Coconductor
21
21
  end
22
22
 
23
23
  def project(path, **args)
24
- Coconductor::Projects::GitProject.new(path, args)
24
+ if path =~ %r{\Ahttps://github.com}
25
+ Coconductor::Projects::GitHubProject.new(path, args)
26
+ else
27
+ Coconductor::Projects::GitProject.new(path, args)
28
+ end
25
29
  rescue Coconductor::Projects::GitProject::InvalidRepository
26
30
  Coconductor::Projects::FSProject.new(path, args)
27
31
  end
@@ -43,6 +43,8 @@ class CoconductorCLI < Thor
43
43
  return options[:code_of_conduct_to_diff]
44
44
  end
45
45
 
46
+ return project.code_of_conduct_file if remote?
47
+
46
48
  @code_of_conduct_to_diff ||= begin
47
49
  if STDIN.tty?
48
50
  error 'You must pipe the file contents to the command via STDIN'
@@ -5,6 +5,12 @@ module Coconductor
5
5
 
6
6
  undef_method :licenses_by_similarity
7
7
  undef_method :potential_licenses
8
+
9
+ private
10
+
11
+ def minimum_confidence
12
+ Coconductor.confidence_threshold
13
+ end
8
14
  end
9
15
  end
10
16
  end
@@ -15,7 +15,7 @@ module Coconductor
15
15
  end
16
16
 
17
17
  def possible_matchers
18
- [Matchers::Exact, Matchers::FieldAware, Matchers::Dice]
18
+ [Matchers::Exact, Matchers::Dice, Matchers::FieldAware]
19
19
  end
20
20
  end
21
21
  end
@@ -3,6 +3,15 @@ autoload :Octokit, 'octokit'
3
3
  module Coconductor
4
4
  module Projects
5
5
  class GitHubProject < Licensee::Projects::GitHubProject
6
+ include Coconductor::Projects::Project
7
+
8
+ private
9
+
10
+ def files
11
+ @files ||= begin
12
+ Coconductor::Projects::Project::DIRS.map { |p| dir_files(p) }.flatten
13
+ end
14
+ end
6
15
  end
7
16
  end
8
17
  end
@@ -1,14 +1,16 @@
1
1
  module Coconductor
2
2
  module Projects
3
3
  module Project
4
- DIRS = ['./docs/', './.github/'].freeze
4
+ DIRS = ['./', './docs/', './.github/'].freeze
5
5
 
6
6
  def code_of_conduct
7
7
  code_of_conduct_file.code_of_conduct if code_of_conduct_file
8
8
  end
9
9
 
10
10
  def code_of_conduct_file
11
+ return @code_of_conduct_file if defined? @code_of_conduct_file
11
12
  return if files.nil? || files.empty?
13
+
12
14
  file = find_files do |filename|
13
15
  ProjectFiles::CodeOfConductFile.name_score(filename)
14
16
  end.first
@@ -16,7 +18,9 @@ module Coconductor
16
18
  return unless file
17
19
 
18
20
  content = load_file(file)
19
- ProjectFiles::CodeOfConductFile.new(content, file)
21
+ @code_of_conduct_file = begin
22
+ ProjectFiles::CodeOfConductFile.new(content, file)
23
+ end
20
24
  end
21
25
 
22
26
  private
@@ -1,3 +1,3 @@
1
1
  module Coconductor
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coconductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-23 00:00:00.000000000 Z
11
+ date: 2018-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: licensee
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '9.9'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 9.9.3
22
+ version: 9.9.4
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '9.9'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 9.9.3
32
+ version: 9.9.4
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: thor
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +114,20 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0.50'
117
+ - !ruby/object:Gem::Dependency
118
+ name: webmock
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.1'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.1'
117
131
  description:
118
132
  email:
119
133
  - ben.balter@github.com