reivt 1.5.0 → 1.6.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 +4 -4
- data/.gitignore +15 -14
- data/.rubocop.yml +1168 -1168
- data/Gemfile +11 -11
- data/README.md +3 -2
- data/Rakefile +22 -22
- data/bin/console +9 -9
- data/exe/revit +5 -5
- data/guides/BaemptyError.md +31 -31
- data/guides/CreatingRevs.md +50 -50
- data/guides/GraphQLDataIssue.md +5 -5
- data/guides/GraphQLValidationError.md +5 -5
- data/guides/LoggingIn.md +17 -17
- data/lib/reivt/api/mutations/document_create.mutation.rb +50 -50
- data/lib/reivt/api/mutations/document_delete.mutation.rb +36 -36
- data/lib/reivt/api/mutations/rev_create.mutation.rb +38 -38
- data/lib/reivt/api/mutations/rev_delete.mutation.rb +36 -36
- data/lib/reivt/api/mutations/user_create.mutation.rb +32 -32
- data/lib/reivt/api/mutations/user_signin.mutation.rb +39 -39
- data/lib/reivt/api.rb +64 -64
- data/lib/reivt/auth.rb +96 -82
- data/lib/reivt/cli.rb +167 -165
- data/lib/reivt/document.rb +67 -67
- data/lib/reivt/exception.rb +48 -35
- data/lib/reivt/schema/schema.json +20981 -20981
- data/lib/reivt/util.rb +112 -112
- data/lib/reivt/version.rb +3 -3
- data/lib/reivt.rb +42 -42
- data/revit.gemspec +44 -44
- metadata +2 -2
data/lib/reivt/util.rb
CHANGED
@@ -1,112 +1,112 @@
|
|
1
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
2
|
-
require 'rugged'
|
3
|
-
require 'tempfile'
|
4
|
-
|
5
|
-
# An extension of our main module
|
6
|
-
#
|
7
|
-
# @author [brwnrclse]
|
8
|
-
#
|
9
|
-
module Reivt
|
10
|
-
# A collection of utility functions for use with reivt
|
11
|
-
#
|
12
|
-
# @author [brwnrclse]
|
13
|
-
#
|
14
|
-
module Util
|
15
|
-
# Wrapper for creating a Document object from a path
|
16
|
-
#
|
17
|
-
# @param path [String] Location on the filesystem to access for files
|
18
|
-
#
|
19
|
-
# @param has_diff [Boolean] A flag to tell if the document has a dif
|
20
|
-
#
|
21
|
-
# @param spinner [TTY:Spinner] A spinner for feedback
|
22
|
-
#
|
23
|
-
# @return [Revit::Document] A newly created Document object
|
24
|
-
#
|
25
|
-
def self.doc_from_path(path, has_diff = false)
|
26
|
-
blob = File.read(path)
|
27
|
-
doc_name = File.basename(path)
|
28
|
-
content_type = Util.ext_to_lang(File.extname(path))
|
29
|
-
Document.new(blob, content_type, doc_name, has_diff)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Creates a list of documents from files in the passed directory
|
33
|
-
#
|
34
|
-
# @param path [String] Location on the filesystem to access for files
|
35
|
-
#
|
36
|
-
# @return [Array<Reivt::Document>] List of documents from directory
|
37
|
-
#
|
38
|
-
def self.docs_from_dir(path)
|
39
|
-
docs = []
|
40
|
-
|
41
|
-
# Recursively get all file paths in a directory
|
42
|
-
entries = Dir.glob("#{path}/**/*").reject { |entry| Dir.exist?(entry) }
|
43
|
-
|
44
|
-
entries.each do |entry|
|
45
|
-
docs.push(Util.doc_from_path(entry)) if entry != '.' && entry != '..'
|
46
|
-
end
|
47
|
-
|
48
|
-
docs
|
49
|
-
end
|
50
|
-
|
51
|
-
# Creates a list of documents from repo changelist
|
52
|
-
#
|
53
|
-
# @param path [String] Location on the filesystem to access for files
|
54
|
-
#
|
55
|
-
# @return [Array<Reivt::Document>] List of documents from repo commit
|
56
|
-
#
|
57
|
-
def self.docs_from_repo(path)
|
58
|
-
docs = []
|
59
|
-
repo = Rugged::Repository.discover(path)
|
60
|
-
|
61
|
-
if repo.bare? || repo.empty?
|
62
|
-
raise Reivt::BaemptyException, "Bad repo: #{path}"
|
63
|
-
end
|
64
|
-
|
65
|
-
commit = repo.head.target
|
66
|
-
diff = commit.parents.first.diff(commit)
|
67
|
-
|
68
|
-
diff.find_similar!
|
69
|
-
diff.each_delta do |d|
|
70
|
-
file_path = d.new_file[:path]
|
71
|
-
docs.push(Util.doc_from_path("#{path}/#{file_path}", true))
|
72
|
-
|
73
|
-
ofile = repo.lookup(d.old_file[:oid])
|
74
|
-
nfile = repo.lookup(d.new_file[:oid])
|
75
|
-
diff_file = Tempfile.new([File.basename(file_path).to_s, '.diff'])
|
76
|
-
|
77
|
-
diff_file.write(ofile.diff(nfile).to_s)
|
78
|
-
docs.push(Util.doc_from_path(diff_file.path))
|
79
|
-
diff_file.close
|
80
|
-
diff_file.unlink
|
81
|
-
end
|
82
|
-
|
83
|
-
docs
|
84
|
-
end
|
85
|
-
|
86
|
-
# Translates a file extenstion to its corresponding programming language.
|
87
|
-
#
|
88
|
-
# @param extension [String] The file extension to be analyzed
|
89
|
-
#
|
90
|
-
# @return [String] The name of the language corresponding to the extension
|
91
|
-
#
|
92
|
-
def self.ext_to_lang(extension)
|
93
|
-
case extension.downcase
|
94
|
-
when '.rb', '.gemspec' then 'ruby'
|
95
|
-
when '.py', '.pyw', '.pyd', '.py3' then 'python'
|
96
|
-
when '.c', '.cpp', '.h', '.hpp' then 'c/c++'
|
97
|
-
when '.js', '.jsx' then 'javascript'
|
98
|
-
when '.java', '.class' then 'java'
|
99
|
-
when '.json' then 'json'
|
100
|
-
when '.yml', '.yaml' then 'yaml'
|
101
|
-
when '.xml' then 'xml'
|
102
|
-
when '.txt', ' ' then 'plain text'
|
103
|
-
when '.sh', '.zsh', '.bash' then 'shell script'
|
104
|
-
when '.md', '.markdown' then 'markdown'
|
105
|
-
when '.fountain' then 'fountain'
|
106
|
-
when '.diff' then 'diff'
|
107
|
-
else
|
108
|
-
'unknown'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
1
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
2
|
+
require 'rugged'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
# An extension of our main module
|
6
|
+
#
|
7
|
+
# @author [brwnrclse]
|
8
|
+
#
|
9
|
+
module Reivt
|
10
|
+
# A collection of utility functions for use with reivt
|
11
|
+
#
|
12
|
+
# @author [brwnrclse]
|
13
|
+
#
|
14
|
+
module Util
|
15
|
+
# Wrapper for creating a Document object from a path
|
16
|
+
#
|
17
|
+
# @param path [String] Location on the filesystem to access for files
|
18
|
+
#
|
19
|
+
# @param has_diff [Boolean] A flag to tell if the document has a dif
|
20
|
+
#
|
21
|
+
# @param spinner [TTY:Spinner] A spinner for feedback
|
22
|
+
#
|
23
|
+
# @return [Revit::Document] A newly created Document object
|
24
|
+
#
|
25
|
+
def self.doc_from_path(path, has_diff = false)
|
26
|
+
blob = File.read(path).gsub("\r\n", "\n") #gsub replace CRLF line endings and converts to LF
|
27
|
+
doc_name = File.basename(path)
|
28
|
+
content_type = Util.ext_to_lang(File.extname(path))
|
29
|
+
Document.new(blob, content_type, doc_name, has_diff)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a list of documents from files in the passed directory
|
33
|
+
#
|
34
|
+
# @param path [String] Location on the filesystem to access for files
|
35
|
+
#
|
36
|
+
# @return [Array<Reivt::Document>] List of documents from directory
|
37
|
+
#
|
38
|
+
def self.docs_from_dir(path)
|
39
|
+
docs = []
|
40
|
+
|
41
|
+
# Recursively get all file paths in a directory
|
42
|
+
entries = Dir.glob("#{path}/**/*").reject { |entry| Dir.exist?(entry) }
|
43
|
+
|
44
|
+
entries.each do |entry|
|
45
|
+
docs.push(Util.doc_from_path(entry)) if entry != '.' && entry != '..'
|
46
|
+
end
|
47
|
+
|
48
|
+
docs
|
49
|
+
end
|
50
|
+
|
51
|
+
# Creates a list of documents from repo changelist
|
52
|
+
#
|
53
|
+
# @param path [String] Location on the filesystem to access for files
|
54
|
+
#
|
55
|
+
# @return [Array<Reivt::Document>] List of documents from repo commit
|
56
|
+
#
|
57
|
+
def self.docs_from_repo(path)
|
58
|
+
docs = []
|
59
|
+
repo = Rugged::Repository.discover(path)
|
60
|
+
|
61
|
+
if repo.bare? || repo.empty?
|
62
|
+
raise Reivt::BaemptyException, "Bad repo: #{path}"
|
63
|
+
end
|
64
|
+
|
65
|
+
commit = repo.head.target
|
66
|
+
diff = commit.parents.first.diff(commit)
|
67
|
+
|
68
|
+
diff.find_similar!
|
69
|
+
diff.each_delta do |d|
|
70
|
+
file_path = d.new_file[:path]
|
71
|
+
docs.push(Util.doc_from_path("#{path}/#{file_path}", true))
|
72
|
+
|
73
|
+
ofile = repo.lookup(d.old_file[:oid])
|
74
|
+
nfile = repo.lookup(d.new_file[:oid])
|
75
|
+
diff_file = Tempfile.new([File.basename(file_path).to_s, '.diff'])
|
76
|
+
|
77
|
+
diff_file.write(ofile.diff(nfile).to_s)
|
78
|
+
docs.push(Util.doc_from_path(diff_file.path))
|
79
|
+
diff_file.close
|
80
|
+
diff_file.unlink
|
81
|
+
end
|
82
|
+
|
83
|
+
docs
|
84
|
+
end
|
85
|
+
|
86
|
+
# Translates a file extenstion to its corresponding programming language.
|
87
|
+
#
|
88
|
+
# @param extension [String] The file extension to be analyzed
|
89
|
+
#
|
90
|
+
# @return [String] The name of the language corresponding to the extension
|
91
|
+
#
|
92
|
+
def self.ext_to_lang(extension)
|
93
|
+
case extension.downcase
|
94
|
+
when '.rb', '.gemspec' then 'ruby'
|
95
|
+
when '.py', '.pyw', '.pyd', '.py3' then 'python'
|
96
|
+
when '.c', '.cpp', '.h', '.hpp' then 'c/c++'
|
97
|
+
when '.js', '.jsx' then 'javascript'
|
98
|
+
when '.java', '.class' then 'java'
|
99
|
+
when '.json' then 'json'
|
100
|
+
when '.yml', '.yaml' then 'yaml'
|
101
|
+
when '.xml' then 'xml'
|
102
|
+
when '.txt', ' ' then 'plain text'
|
103
|
+
when '.sh', '.zsh', '.bash' then 'shell script'
|
104
|
+
when '.md', '.markdown' then 'markdown'
|
105
|
+
when '.fountain' then 'fountain'
|
106
|
+
when '.diff' then 'diff'
|
107
|
+
else
|
108
|
+
'unknown'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/reivt/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Reivt
|
2
|
-
VERSION = '1.
|
3
|
-
end
|
1
|
+
module Reivt
|
2
|
+
VERSION = '1.6.0'.freeze
|
3
|
+
end
|
data/lib/reivt.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'logger'
|
3
|
-
require 'paint'
|
4
|
-
require 'pstore'
|
5
|
-
|
6
|
-
# The cli tool for rev. Revit process paths passed to it in order to create new
|
7
|
-
# documents to review online. Each path passed is determined to be a file,
|
8
|
-
# directory or git repo. In the case of the first two "Document" objects
|
9
|
-
# are created as a simple wrapper around important info we need to pass to
|
10
|
-
# the Rev API. In the case of the repo, we only use files from the latest
|
11
|
-
# commit (or a passed commit hash) along with diffs for each. The iops are
|
12
|
-
# grouped together and the api calls are made last (aside from creating
|
13
|
-
# the rev). This allows us to have UI feedback (spinnys) that'll keep the
|
14
|
-
# user informed about what's going on
|
15
|
-
#
|
16
|
-
# @author [brwnrclse]
|
17
|
-
#
|
18
|
-
module Reivt
|
19
|
-
FileUtils.mkdir_p("#{Dir.home}/.reivt")
|
20
|
-
|
21
|
-
REIVT_STORE = PStore.new("#{Dir.home}/.reivt/reivt.pstore")
|
22
|
-
LOGGER = Logger.new(STDOUT)
|
23
|
-
DEVLOGGER = Logger.new("#{Dir.home}/.reivt/reivt-dev.log")
|
24
|
-
|
25
|
-
DEVLOGGER.datetime_format = '%Y-%m-%d %H:%M:%S '
|
26
|
-
LOGGER.formatter = proc do |severity, _, _, msg|
|
27
|
-
case severity
|
28
|
-
when 'ERROR' then "\n#{Paint[severity, :red]}: #{msg}\n"
|
29
|
-
when 'FATAL' then "\n#{Paint[severity, :red]}L #{msg}\n"
|
30
|
-
else
|
31
|
-
"\n#{msg}\n"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
require 'reivt/api'
|
37
|
-
require 'reivt/auth'
|
38
|
-
require 'reivt/cli'
|
39
|
-
require 'reivt/document'
|
40
|
-
require 'reivt/exception'
|
41
|
-
require 'reivt/util'
|
42
|
-
require 'reivt/version'
|
1
|
+
require 'fileutils'
|
2
|
+
require 'logger'
|
3
|
+
require 'paint'
|
4
|
+
require 'pstore'
|
5
|
+
|
6
|
+
# The cli tool for rev. Revit process paths passed to it in order to create new
|
7
|
+
# documents to review online. Each path passed is determined to be a file,
|
8
|
+
# directory or git repo. In the case of the first two "Document" objects
|
9
|
+
# are created as a simple wrapper around important info we need to pass to
|
10
|
+
# the Rev API. In the case of the repo, we only use files from the latest
|
11
|
+
# commit (or a passed commit hash) along with diffs for each. The iops are
|
12
|
+
# grouped together and the api calls are made last (aside from creating
|
13
|
+
# the rev). This allows us to have UI feedback (spinnys) that'll keep the
|
14
|
+
# user informed about what's going on
|
15
|
+
#
|
16
|
+
# @author [brwnrclse]
|
17
|
+
#
|
18
|
+
module Reivt
|
19
|
+
FileUtils.mkdir_p("#{Dir.home}/.reivt")
|
20
|
+
|
21
|
+
REIVT_STORE = PStore.new("#{Dir.home}/.reivt/reivt.pstore")
|
22
|
+
LOGGER = Logger.new(STDOUT)
|
23
|
+
DEVLOGGER = Logger.new("#{Dir.home}/.reivt/reivt-dev.log")
|
24
|
+
|
25
|
+
DEVLOGGER.datetime_format = '%Y-%m-%d %H:%M:%S '
|
26
|
+
LOGGER.formatter = proc do |severity, _, _, msg|
|
27
|
+
case severity
|
28
|
+
when 'ERROR' then "\n#{Paint[severity, :red]}: #{msg}\n"
|
29
|
+
when 'FATAL' then "\n#{Paint[severity, :red]}L #{msg}\n"
|
30
|
+
else
|
31
|
+
"\n#{msg}\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'reivt/api'
|
37
|
+
require 'reivt/auth'
|
38
|
+
require 'reivt/cli'
|
39
|
+
require 'reivt/document'
|
40
|
+
require 'reivt/exception'
|
41
|
+
require 'reivt/util'
|
42
|
+
require 'reivt/version'
|
data/revit.gemspec
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
# rubocop disable Metrics/BlockLength
|
2
|
-
# coding: utf-8
|
3
|
-
|
4
|
-
lib = File.expand_path('../lib', __FILE__)
|
5
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
-
require 'reivt/version'
|
7
|
-
|
8
|
-
Gem::Specification.new do |spec|
|
9
|
-
spec.name = 'reivt'
|
10
|
-
spec.version = Reivt::VERSION
|
11
|
-
spec.authors = ['vaemoi', 'Barry Harris, Tarik Massac']
|
12
|
-
spec.email = ['dev@vaemoi.co', 'brwnrclse@vaemoi.co', 'tai@vaemoi.co']
|
13
|
-
spec.summary = 'NOTICE!!! - we will be moving to revit in a few days ' \
|
14
|
-
"https://rubygems.org/gems/revit !!! \n\n" \
|
15
|
-
' Creating and uploading code reviews to use with rev' \
|
16
|
-
' - https://rev.vaemoi.co'
|
17
|
-
spec.homepage = 'https://rev.vaemoi.co'
|
18
|
-
spec.license = 'MIT'
|
19
|
-
|
20
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
-
f.match(%r{^(test|spec|features)/})
|
22
|
-
end
|
23
|
-
|
24
|
-
spec.bindir = 'exe'
|
25
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
|
-
spec.require_paths = ['lib']
|
28
|
-
spec.required_ruby_version = '>= 2.3.0'
|
29
|
-
|
30
|
-
spec.add_dependency 'graphql-client', '~> 0.8.0'
|
31
|
-
spec.add_dependency 'thor', '~> 0.19.4'
|
32
|
-
spec.add_dependency 'tty-spinner', '~> 0.4.1'
|
33
|
-
|
34
|
-
spec.add_runtime_dependency 'bcrypt', '~> 3.1', '>= 3.1.11'
|
35
|
-
spec.add_runtime_dependency 'paint', '~> 2.0', '>= 2.0.0'
|
36
|
-
spec.add_runtime_dependency 'sysrandom', '~> 1.0', '>= 1.0.5'
|
37
|
-
|
38
|
-
spec.add_development_dependency 'bundler', '~> 1.13'
|
39
|
-
spec.add_development_dependency 'pry', '~> 0.10.4'
|
40
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
-
spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
|
42
|
-
spec.add_development_dependency 'rubocop', '~> 0.48.1'
|
43
|
-
spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2'
|
44
|
-
end
|
1
|
+
# rubocop disable Metrics/BlockLength
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'reivt/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'reivt'
|
10
|
+
spec.version = Reivt::VERSION
|
11
|
+
spec.authors = ['vaemoi', 'Barry Harris, Tarik Massac']
|
12
|
+
spec.email = ['dev@vaemoi.co', 'brwnrclse@vaemoi.co', 'tai@vaemoi.co']
|
13
|
+
spec.summary = 'NOTICE!!! - we will be moving to revit in a few days ' \
|
14
|
+
"https://rubygems.org/gems/revit !!! \n\n" \
|
15
|
+
' Creating and uploading code reviews to use with rev' \
|
16
|
+
' - https://rev.vaemoi.co'
|
17
|
+
spec.homepage = 'https://rev.vaemoi.co'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.bindir = 'exe'
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
spec.required_ruby_version = '>= 2.3.0'
|
29
|
+
|
30
|
+
spec.add_dependency 'graphql-client', '~> 0.8.0'
|
31
|
+
spec.add_dependency 'thor', '~> 0.19.4'
|
32
|
+
spec.add_dependency 'tty-spinner', '~> 0.4.1'
|
33
|
+
|
34
|
+
spec.add_runtime_dependency 'bcrypt', '~> 3.1', '>= 3.1.11'
|
35
|
+
spec.add_runtime_dependency 'paint', '~> 2.0', '>= 2.0.0'
|
36
|
+
spec.add_runtime_dependency 'sysrandom', '~> 1.0', '>= 1.0.5'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
39
|
+
spec.add_development_dependency 'pry', '~> 0.10.4'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
|
42
|
+
spec.add_development_dependency 'rubocop', '~> 0.48.1'
|
43
|
+
spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2'
|
44
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reivt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaemoi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04-
|
12
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql-client
|