revit 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +17 -0
- data/.gemrc +1 -0
- data/.gitignore +15 -0
- data/.rubocop.yml +1151 -0
- data/.ruby-version +1 -0
- data/.test-unit.yml +12 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/README.md +15 -0
- data/Rakefile +27 -0
- data/bin/console +9 -0
- data/bin/setup +8 -0
- data/bitbucket-pipelines.yml +9 -0
- data/exe/revit +5 -0
- data/guides/BaemptyError.md +31 -0
- data/guides/CreatingRevs.md +50 -0
- data/guides/GraphQLDataIssue.md +5 -0
- data/guides/GraphQLValidationError.md +5 -0
- data/guides/LoggingIn.md +17 -0
- data/lib/revit.rb +71 -0
- data/lib/revit/api.rb +188 -0
- data/lib/revit/auth.rb +97 -0
- data/lib/revit/cli.rb +134 -0
- data/lib/revit/exception.rb +36 -0
- data/lib/revit/schema/schema.json +20982 -0
- data/lib/revit/util.rb +164 -0
- data/lib/revit/version.rb +3 -0
- data/revit.gemspec +40 -0
- data/revit.sublime-project +20 -0
- metadata +248 -0
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.4
|
data/.test-unit.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 vaemoi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
[![Code Climate](https://codeclimate.com/repos/57d861ee01430a66ea000bed/badges/4d214cda256127c2391e/gpa.svg)](https://codeclimate.com/repos/57d861ee01430a66ea000bed/feed) [![Test Coverage](https://codeclimate.com/repos/57d861ee01430a66ea000bed/badges/4d214cda256127c2391e/coverage.svg)](https://codeclimate.com/repos/57d861ee01430a66ea000bed/coverage) [![Issue Count](https://codeclimate.com/repos/57d861ee01430a66ea000bed/badges/4d214cda256127c2391e/issue_count.svg)](https://codeclimate.com/repos/57d861ee01430a66ea000bed/feed)
|
2
|
+
|
3
|
+
# Rev
|
4
|
+
---
|
5
|
+
Upload your documents/directories/git commits to rev for a code review session!
|
6
|
+
|
7
|
+
Conduct your code reviews with [rev](https://rev.vaemoi.co)!
|
8
|
+
|
9
|
+
[Bitbucket](https://bitbucket.org/vaemoi/revit)
|
10
|
+
[Docker Whale used for testing](https://hub.docker.com/r/vaemoi/revit-whale/)
|
11
|
+
[Issues](https://bitbucket.org/vaemoi/revit/issues)
|
12
|
+
|
13
|
+
## License
|
14
|
+
|
15
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
6
|
+
t.rspec_opts = '--format doc'
|
7
|
+
end
|
8
|
+
|
9
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
10
|
+
t.patterns = ['lib/**/*.rb']
|
11
|
+
t.options = ['--config', "#{Dir.pwd}/.rubocop.yml"]
|
12
|
+
end
|
13
|
+
|
14
|
+
task :console do
|
15
|
+
require 'pry'
|
16
|
+
require 'revit'
|
17
|
+
|
18
|
+
def reload!
|
19
|
+
files = $LOADED_FEATURES.select { |feat| feat =~ %r{//revit} }
|
20
|
+
files.each { |file| load file }
|
21
|
+
end
|
22
|
+
|
23
|
+
ARGV.clear
|
24
|
+
Pry.start
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :spec
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/exe/revit
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# baemptyError
|
2
|
+
|
3
|
+
This simply means you have passed rev either to an empty repo or a [bare repo](http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/).
|
4
|
+
|
5
|
+
If you still want to use the repo:
|
6
|
+
|
7
|
+
|
8
|
+
- create a commit
|
9
|
+
``` bash
|
10
|
+
|
11
|
+
git add -A && git commit -m # Add every file in the repo
|
12
|
+
|
13
|
+
git add ./path/to/file.ext && git commit -m # Add a specific file or folder
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
- Destroy the repo
|
18
|
+
``` bash
|
19
|
+
|
20
|
+
rm -rf .git
|
21
|
+
|
22
|
+
```
|
23
|
+
|
24
|
+
|
25
|
+
Then try revit again:
|
26
|
+
|
27
|
+
``` bash
|
28
|
+
|
29
|
+
revit create ./path/to/repo
|
30
|
+
|
31
|
+
```
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# How to
|
2
|
+
|
3
|
+
## Getting Started
|
4
|
+
---
|
5
|
+
To get started with revit make sure you have the latest ruby installed or atleast version 2.3.3.
|
6
|
+
|
7
|
+
``` bash
|
8
|
+
|
9
|
+
ruby -v
|
10
|
+
|
11
|
+
```
|
12
|
+
|
13
|
+
Now let's install revit!
|
14
|
+
|
15
|
+
``` bash
|
16
|
+
|
17
|
+
gem install revit
|
18
|
+
|
19
|
+
revit -v
|
20
|
+
revit --version
|
21
|
+
|
22
|
+
```
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
## Creating a revs
|
27
|
+
---
|
28
|
+
revit only allows creating new rev at the moment, modifying them will come soong!
|
29
|
+
|
30
|
+
Get started by running revit ```create```
|
31
|
+
|
32
|
+
``` bash
|
33
|
+
|
34
|
+
revit create ./path/to/docs # Path to a single file, directory or git repo
|
35
|
+
|
36
|
+
revit create -l ./path/file1 ./path/file2 # -l allows you to pass multiple files / docs / repos
|
37
|
+
|
38
|
+
revit create ./path/file1 -d "An example rev" # Add a description to your rev
|
39
|
+
|
40
|
+
revit create ./path/file1 -t "First Rev" # Add a title to your rev
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
These commands will also be shown by running:
|
45
|
+
|
46
|
+
``` bash
|
47
|
+
|
48
|
+
revit --help
|
49
|
+
|
50
|
+
```
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# GraphQLDataIssue
|
2
|
+
|
3
|
+
Hey, don't fret this just means that some error happened on our api! It's not your fault we swear!
|
4
|
+
|
5
|
+
Try running the same command again, and if you end up here again post an issue to our tracker on Bitbucket [here](https://bitbucket.org/vaemoi/revit/issues)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# GraphQLValidationError
|
2
|
+
|
3
|
+
Hey, don't fret this just means that some variable passed to our api wasn't in the correct format! It's not your fault we swear!
|
4
|
+
|
5
|
+
Try running the same command again, and if it fails post an issue to our tracker on Bitbucket [here](https://bitbucket.org/vaemoi/revit/issues)
|
data/guides/LoggingIn.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Logging In
|
2
|
+
Start an authentication workflow to receive an access token (allows you to access our api)
|
3
|
+
|
4
|
+
Running login will produce a url you need to follow in order to get your auth code from Auth0. Paste this code back into the terminal and you'll be authenticated. (If you want more security info checkout our wiki!)
|
5
|
+
|
6
|
+
``` bash
|
7
|
+
|
8
|
+
revit login
|
9
|
+
|
10
|
+
"Login here for your token": https://vaemoi.auth0/login/stuff/to/login
|
11
|
+
|
12
|
+
"Enter your auth code here" => owfnoisjIAIO90w9JDOFIEF
|
13
|
+
|
14
|
+
Authentication successful :)
|
15
|
+
```
|
16
|
+
|
17
|
+
Now you're ready to make some revs!
|
data/lib/revit.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'json'
|
3
|
+
require 'logger'
|
4
|
+
require 'net/http'
|
5
|
+
require 'pstore'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
# CLI upload tool for rev. revit:
|
9
|
+
# 0) Authenticates you using Auth0
|
10
|
+
# 1) Takes a combination of inputs
|
11
|
+
# * File path
|
12
|
+
# * Directory path
|
13
|
+
# * git/svn repo path
|
14
|
+
# - git/svn repo commit hashes
|
15
|
+
# - git/svn repo branch names
|
16
|
+
# ~ git svn repo branch commit hashes
|
17
|
+
# 2) Creates a handy dandy rev
|
18
|
+
# 3) Notifies your melee
|
19
|
+
# 3) Gives you a web link to the rev
|
20
|
+
#
|
21
|
+
# @author [brwnrclse]
|
22
|
+
#
|
23
|
+
module Revit
|
24
|
+
# Setup home folder for config and log(s)
|
25
|
+
FileUtils.mkdir_p("#{Dir.home}/.revit")
|
26
|
+
STORE = PStore.new("#{Dir.home}/.revit/revit.pstore")
|
27
|
+
LOGGER = Logger.new("#{Dir.home}/.revit/revit.log")
|
28
|
+
|
29
|
+
# Set default values for store values if there aren't any
|
30
|
+
STORE.transaction do |store|
|
31
|
+
store[:auth0_id] = nil unless store[:auth0_id]
|
32
|
+
store[:access_token] = nil unless store[:access_token]
|
33
|
+
store[:auth_url] = 'https://vaemoi.auth0.com'.freeze unless store[:auth_url]
|
34
|
+
store[:user_id] = nil unless store[:user_id]
|
35
|
+
|
36
|
+
unless store[:auth_callback_url]
|
37
|
+
store[:auth_callback_url] = 'https://rev.vaemoi.co/login_success'.freeze
|
38
|
+
end
|
39
|
+
|
40
|
+
unless store[:auth_client_id]
|
41
|
+
store[:auth_client_id] = 'Q1fRDQ9u3oN33ok0ciIi9Vww5kV8U8MA'.freeze
|
42
|
+
end
|
43
|
+
|
44
|
+
unless store[:schema_path]
|
45
|
+
store[:schema_path] = "#{Dir.pwd}/lib/revit/schema/schema.json".freeze
|
46
|
+
end
|
47
|
+
|
48
|
+
unless store[:endpoint_url]
|
49
|
+
store[:endpoint_url] = 'https://api.graph.cool/simple/v1/revwver'.freeze
|
50
|
+
end
|
51
|
+
|
52
|
+
# Caching the graphql schema
|
53
|
+
unless File.exist?(store[:schema_path]) && !File.zero?(store[:schema_path])
|
54
|
+
uri = URI.parse(store[:endpoint_url])
|
55
|
+
req = Net::HTTP::Post.new(uri)
|
56
|
+
req.content_type = 'application/json'
|
57
|
+
req.body = { query: '{__schema {types {name}}}' }.to_json
|
58
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
59
|
+
File.write(store[:schema_path], JSON.parse(http.request(req).body))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
LOGGER.datetime_format = '%<year>Y-%<month>m-%<day>d %<hour>H:%<min>M:%<s>S '
|
64
|
+
end
|
65
|
+
|
66
|
+
require_relative 'revit/api'
|
67
|
+
require_relative 'revit/auth'
|
68
|
+
require_relative 'revit/cli'
|
69
|
+
require_relative 'revit/exception'
|
70
|
+
require_relative 'revit/util'
|
71
|
+
require_relative 'revit/version'
|
data/lib/revit/api.rb
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'graphlient'
|
2
|
+
|
3
|
+
module Revit
|
4
|
+
# Intrface for rev API, connects local changes with our remote.
|
5
|
+
#
|
6
|
+
# @author [brwnrclse]
|
7
|
+
#
|
8
|
+
module RevAPI
|
9
|
+
ENDPOINT_URL, ID_TOKEN, AUTH_TOKEN = Revit::STORE.transaction do |store|
|
10
|
+
[store[:endpoint_url], store[:user_id], store[:auth0_id]]
|
11
|
+
end
|
12
|
+
|
13
|
+
CLIENT = Graphlient::Client.new(
|
14
|
+
ENDPOINT_URL, headers: {
|
15
|
+
'Authorization' => "Bearer #{AUTH_TOKEN}"
|
16
|
+
}
|
17
|
+
)
|
18
|
+
|
19
|
+
##
|
20
|
+
## Helper methods
|
21
|
+
##
|
22
|
+
|
23
|
+
# Raise any errors in the response data or simply return the data
|
24
|
+
#
|
25
|
+
# @param api_response [Obj]
|
26
|
+
#
|
27
|
+
# @return [Array]
|
28
|
+
#
|
29
|
+
def self.handle_response(api_response)
|
30
|
+
unless api_response.data
|
31
|
+
error_info = []
|
32
|
+
|
33
|
+
api_response.errors.each do |error|
|
34
|
+
error_info.push("Error #{error&.code}: #{error&.message}")
|
35
|
+
end
|
36
|
+
|
37
|
+
raise Revit::GraphQLDataException, error_info.join(', ')
|
38
|
+
end
|
39
|
+
|
40
|
+
api_response.data
|
41
|
+
end
|
42
|
+
|
43
|
+
# Calls a query with the provided string and params
|
44
|
+
# and catches any validation or schema mismatch errors
|
45
|
+
#
|
46
|
+
def self.execute_query(querystr, params)
|
47
|
+
if (params&.rev_id).length < 25
|
48
|
+
raise Revit::GraphQLValidationException, 'Invalid rev id'
|
49
|
+
end
|
50
|
+
|
51
|
+
handle_response(CLIENT.query(querystr, params))
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
## API methods
|
56
|
+
##
|
57
|
+
|
58
|
+
# API call to createDocument
|
59
|
+
# @param has_diff [Boolean]
|
60
|
+
# @param doc_name [String]
|
61
|
+
# @param rev_id [String]
|
62
|
+
# @param syntax [String]
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
#
|
66
|
+
def self.create_doc(doc_name, has_diff, rev_id, syntax)
|
67
|
+
doc_name = 'Ole Noname Doc' if doc_name.nil? || doc_name.strip.empty?
|
68
|
+
mutation = CLIENT.parse do
|
69
|
+
mutation(syntax: :SYNTAX, name: :string, hasDiff: :boolean,
|
70
|
+
revId: :id) do
|
71
|
+
createDocument(syntax: :syntax, name: :name, hasDiff: :hasDiff,
|
72
|
+
revId: :revId) do
|
73
|
+
id
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
result = execute_query(mutation, syntax: syntax, rev: rev_id,
|
79
|
+
name: doc_name, hasDiff: has_diff)
|
80
|
+
|
81
|
+
result.createDocument.id
|
82
|
+
end
|
83
|
+
|
84
|
+
# API call to deleteDocument
|
85
|
+
# @param id [String]
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
#
|
89
|
+
def self.delete_doc(id)
|
90
|
+
mutation = CLIENT.parse do
|
91
|
+
mutation(id: :id) do
|
92
|
+
deleteDocument(id: :id) do
|
93
|
+
id
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
result = execute_query(mutation, id: id)
|
99
|
+
|
100
|
+
result.deleteDocument.id
|
101
|
+
end
|
102
|
+
|
103
|
+
# API call to createRev
|
104
|
+
# @param summary [String]
|
105
|
+
# @param title [String]
|
106
|
+
#
|
107
|
+
# @return [String]
|
108
|
+
#
|
109
|
+
def self.create_rev(summary, title)
|
110
|
+
summary = 'Some rev' if summary.nil? || summary.strip.empty?
|
111
|
+
title = 'rev, right?' if title.nil? || title.strip.empty?
|
112
|
+
mutation = CLIENT.parse do
|
113
|
+
mutation(summary: :string, title: :string, userId: :id) do
|
114
|
+
createRev(summary: :summary, title: :title, userId: :userId) do
|
115
|
+
id
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
result = execute_query(mutation, summary: summary, title: title,
|
121
|
+
userId: ID_TOKEN)
|
122
|
+
|
123
|
+
result.createRev.id
|
124
|
+
end
|
125
|
+
|
126
|
+
# API call to deleteRev
|
127
|
+
# @param id [String]
|
128
|
+
#
|
129
|
+
# @return [String]
|
130
|
+
#
|
131
|
+
def self.delete_rev(id)
|
132
|
+
mutation = CLIENT.parse do
|
133
|
+
mutation(id: :id) do
|
134
|
+
deleteRev(id: :id) do
|
135
|
+
id
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
result = execute_query(mutation, id: id)
|
141
|
+
|
142
|
+
result.deleteRev.id
|
143
|
+
end
|
144
|
+
|
145
|
+
# Authenticate the user against the api to receive a user id
|
146
|
+
# @param id [String]
|
147
|
+
#
|
148
|
+
# @return [String]
|
149
|
+
#
|
150
|
+
def self.create_user(auth0_id)
|
151
|
+
mutation = CLIENT.parse do
|
152
|
+
mutation(auth0SignUpData: AuthProviderSignupData!) do
|
153
|
+
createUser(authProvider: auth0SignUpData) do
|
154
|
+
id
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
result = execute_query(mutation, auth0_id: auth0_id)
|
160
|
+
|
161
|
+
result.createUser.id
|
162
|
+
end
|
163
|
+
|
164
|
+
# Authenticate the user against the api to receive a user id
|
165
|
+
# @param id [String]
|
166
|
+
#
|
167
|
+
# @return [String]
|
168
|
+
#
|
169
|
+
def self.signin_user(auth0_id)
|
170
|
+
mutation = CLIENT.parse do
|
171
|
+
mutation(auth0: :AUTH_PROVIDER_AUTH0) do
|
172
|
+
signinUser(auth0: :auth0) do
|
173
|
+
user do
|
174
|
+
id
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
result = execute_query(mutation, auth0_id: auth0_id)
|
181
|
+
|
182
|
+
# This means a user is trying to sign in but doesn't have an account, yet
|
183
|
+
result.nil? ? result : result.signinUser.user.id
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# TODO: Add in create_s3Resource func
|
188
|
+
end
|