reivt 1.1.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.
data/lib/revit/util.rb ADDED
@@ -0,0 +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 Revit
10
+ # A collection of utility functions for use with revit
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<Revit::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<Revit::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 Revit::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
@@ -0,0 +1,3 @@
1
+ module Revit
2
+ VERSION = '1.1.0'.freeze
3
+ end
data/lib/revit.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'fileutils'
2
+ require 'logger'
3
+ require 'pstore'
4
+
5
+ # The cli tool for rev. Revit process paths passed to it in order to create new
6
+ # documents to review online. Each path passed is determined to be a file,
7
+ # directory or git repo. In the case of the first two "Document" objects
8
+ # are created as a simple wrapper around important info we need to pass to
9
+ # the Rev API. In the case of the repo, we only use files from the latest
10
+ # commit (or a passed commit hash) along with diffs for each. The iops are
11
+ # grouped together and the api calls are made last (aside from creating
12
+ # the rev). This allows us to have UI feedback (spinnys) that'll keep the
13
+ # user informed about what's going on
14
+ #
15
+ # @author [brwnrclse]
16
+ #
17
+ module Revit
18
+ FileUtils.mkdir_p("#{Dir.home}/.revit")
19
+
20
+ REVIT_STORE = PStore.new("#{Dir.home}/.revit/revit.pstore")
21
+ DEVLOGGER = Logger.new("#{Dir.home}/.revit/revit-dev.log")
22
+
23
+ DEVLOGGER.datetime_format = '%Y-%m-%d %H:%M:%S '
24
+ end
25
+
26
+ require 'revit/api'
27
+ require 'revit/auth'
28
+ require 'revit/cli'
29
+ require 'revit/document'
30
+ require 'revit/exception'
31
+ require 'revit/util'
32
+ require 'revit/version'
data/revit.gemspec ADDED
@@ -0,0 +1,40 @@
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 'revit/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'reivt'
10
+ spec.version = Revit::VERSION
11
+ spec.authors = ['vaemoi', 'Barry Harris, Tarik Massac']
12
+ spec.email = ['dev@vaemoi.co', 'brwnrclse@vaemoi.co', 'tai@vaemoi.co']
13
+ spec.summary = 'Creating and uploading code reviews to use with rev'
14
+ spec.homepage = 'https://rev.vaemoi.co'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_dependency 'graphql-client', '~> 0.8.0'
27
+ spec.add_dependency 'thor', '~> 0.19.4'
28
+ spec.add_dependency 'tty-spinner', '~> 0.4.1'
29
+
30
+ spec.add_runtime_dependency 'bcrypt', '~> 3.1', '>= 3.1.11'
31
+ spec.add_runtime_dependency 'paint', '~> 2.0', '>= 2.0.0'
32
+ spec.add_runtime_dependency 'sysrandom', '~> 1.0', '>= 1.0.5'
33
+
34
+ spec.add_development_dependency 'bundler', '~> 1.13'
35
+ spec.add_development_dependency 'pry', '~> 0.10.4'
36
+ spec.add_development_dependency 'rake', '~> 10.0'
37
+ spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
38
+ spec.add_development_dependency 'rubocop', '~> 0.48.1'
39
+ spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2'
40
+ end
@@ -0,0 +1,31 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": ".",
5
+ "folder_exclude_patterns": ["coverage", "rdoc", ".bundle", "vendor/ruby", "vendor/bundle", "lib/bundler/man", "tmp", "pkg", "InstalledFiles"],
6
+ "file_exclude_patterns": ["*.gem", "*.rbc", ".config", "Gemfile.lock", ".ruby-gemset", ".rvmrc"],
7
+ "name":"revit - rev cli"
8
+ }
9
+ ],
10
+ "SublimeLinter": {
11
+ "linters": {
12
+ "rubocop": {
13
+ "@disable": false,
14
+ "args": ["-c", "${project}/.rubocop.yml"],
15
+ "excludes": ["coverage", "rdoc", ".bundle", "vendor"]
16
+ }
17
+ },
18
+ "paths": {
19
+ "linux": [
20
+ "/usr/local/sbin",
21
+ "/usr/local/bin",
22
+ "/usr/bin",
23
+ "/usr/lib/jvm/default/bin",
24
+ "/usr/bin/site_perl",
25
+ "/usr/bin/vendor_perl",
26
+ "/usr/bin/core_perl",
27
+ "${project}/vendor/ruby/2.3.0/bin/"
28
+ ]
29
+ }
30
+ }
31
+ }
metadata ADDED
@@ -0,0 +1,281 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reivt
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - vaemoi
8
+ - Barry Harris, Tarik Massac
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2017-04-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: graphql-client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.8.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.8.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: thor
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.19.4
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.19.4
42
+ - !ruby/object:Gem::Dependency
43
+ name: tty-spinner
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 0.4.1
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 0.4.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: bcrypt
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.1'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 3.1.11
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '3.1'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.11
76
+ - !ruby/object:Gem::Dependency
77
+ name: paint
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.0.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '2.0'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.0.0
96
+ - !ruby/object:Gem::Dependency
97
+ name: sysrandom
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.0'
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 1.0.5
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.0'
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 1.0.5
116
+ - !ruby/object:Gem::Dependency
117
+ name: bundler
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '1.13'
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '1.13'
130
+ - !ruby/object:Gem::Dependency
131
+ name: pry
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 0.10.4
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: 0.10.4
144
+ - !ruby/object:Gem::Dependency
145
+ name: rake
146
+ requirement: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: '10.0'
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '10.0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rspec
160
+ requirement: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '3.5'
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: 3.5.0
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '3.5'
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 3.5.0
178
+ - !ruby/object:Gem::Dependency
179
+ name: rubocop
180
+ requirement: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "~>"
183
+ - !ruby/object:Gem::Version
184
+ version: 0.48.1
185
+ type: :development
186
+ prerelease: false
187
+ version_requirements: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - "~>"
190
+ - !ruby/object:Gem::Version
191
+ version: 0.48.1
192
+ - !ruby/object:Gem::Dependency
193
+ name: webmock
194
+ requirement: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - "~>"
197
+ - !ruby/object:Gem::Version
198
+ version: '2.3'
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: 2.3.2
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '2.3'
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: 2.3.2
212
+ description:
213
+ email:
214
+ - dev@vaemoi.co
215
+ - brwnrclse@vaemoi.co
216
+ - tai@vaemoi.co
217
+ executables:
218
+ - revit
219
+ extensions: []
220
+ extra_rdoc_files: []
221
+ files:
222
+ - ".codeclimate.yml"
223
+ - ".gitignore"
224
+ - ".rubocop.yml"
225
+ - ".ruby-version"
226
+ - ".test-unit.yml"
227
+ - Gemfile
228
+ - LICENSE.txt
229
+ - README.md
230
+ - Rakefile
231
+ - bin/console
232
+ - bin/setup
233
+ - bitbucket-pipelines.yml
234
+ - exe/revit
235
+ - guides/BaemptyError.md
236
+ - guides/CreatingRevs.md
237
+ - guides/GraphQLDataIssue.md
238
+ - guides/GraphQLValidationError.md
239
+ - guides/LoggingIn.md
240
+ - lib/revit.rb
241
+ - lib/revit/api.rb
242
+ - lib/revit/api/mutations/document_create.mutation.rb
243
+ - lib/revit/api/mutations/document_delete.mutation.rb
244
+ - lib/revit/api/mutations/rev_create.mutation.rb
245
+ - lib/revit/api/mutations/rev_delete.mutation.rb
246
+ - lib/revit/api/mutations/user_create.mutation.rb
247
+ - lib/revit/api/mutations/user_signin.mutation.rb
248
+ - lib/revit/auth.rb
249
+ - lib/revit/cli.rb
250
+ - lib/revit/document.rb
251
+ - lib/revit/exception.rb
252
+ - lib/revit/schema/schema.json
253
+ - lib/revit/util.rb
254
+ - lib/revit/version.rb
255
+ - revit.gemspec
256
+ - revit.sublime-project
257
+ homepage: https://rev.vaemoi.co
258
+ licenses:
259
+ - MIT
260
+ metadata: {}
261
+ post_install_message:
262
+ rdoc_options: []
263
+ require_paths:
264
+ - lib
265
+ required_ruby_version: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ required_rubygems_version: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - ">="
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
275
+ requirements: []
276
+ rubyforge_project:
277
+ rubygems_version: 2.6.10
278
+ signing_key:
279
+ specification_version: 4
280
+ summary: Creating and uploading code reviews to use with rev
281
+ test_files: []