twenty-server 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/twenty/server/model/project.rb +17 -2
- data/lib/twenty/server/rack/graphql.rb +3 -3
- data/lib/twenty/server.rb +37 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e757edafe6098ad6fdb828673a80a368fef19102c0d423b37505a89fbf7ef5f2
|
4
|
+
data.tar.gz: 43f1d07bc5b01ed9ac0d80b99a35fac3b5e38770fa2f63bd6131c8c26af3fe91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e03f24bd875d97992927619a88ed38a1bf79d25c011ada150ba26e55d55f9ad68694290262d83a3591f83f913f31d137d946de457a0d9d1f71f6d84d4ca7eea1
|
7
|
+
data.tar.gz: 0acd505202c76554c708050ebc6d6d71be556d09154cc563a7acc1805a82c4e1349d9b9780da1dc195e624c7d3a12f4be3d2fb4750135f63ef16ad5ce309fec5
|
@@ -8,16 +8,31 @@ class Twenty::Project < Sequel::Model
|
|
8
8
|
validates_presence_of :path
|
9
9
|
one_to_many :tasks, class_name: "Twenty::Task"
|
10
10
|
|
11
|
+
##
|
12
|
+
# @api private
|
13
|
+
def validate
|
14
|
+
super
|
15
|
+
errors.add(:path, "does not exist on disk") if !path_exist?
|
16
|
+
errors.add(:path, "is not absolute") if !File.absolute_path?(path)
|
17
|
+
end
|
18
|
+
|
11
19
|
##
|
12
20
|
# @return [String]
|
13
|
-
# The path to a project
|
21
|
+
# The path to a project
|
14
22
|
def path
|
15
23
|
super&.sub(Dir.home, "~")
|
16
24
|
end
|
17
25
|
|
26
|
+
##
|
27
|
+
# @return [Boolean]
|
28
|
+
# Returns true when {#path} exists on disk
|
29
|
+
def path_exist?
|
30
|
+
File.exist? File.expand_path(path)
|
31
|
+
end
|
32
|
+
|
18
33
|
##
|
19
34
|
# @return [Integer]
|
20
|
-
# Returns the number of open tasks a project has
|
35
|
+
# Returns the number of open tasks a project has
|
21
36
|
def open_task_count
|
22
37
|
@open_task_count ||= Twenty::Task
|
23
38
|
.where(project_id: id)
|
@@ -4,13 +4,13 @@ module Twenty::Rack
|
|
4
4
|
module GraphQL
|
5
5
|
##
|
6
6
|
# Extends {Server::Dir Server::Dir} (a static file
|
7
|
-
# Rack application) with a /graphql endpoint
|
7
|
+
# Rack application) with a /graphql endpoint
|
8
8
|
#
|
9
9
|
# @param [Hash] env
|
10
|
-
# Environment hash
|
10
|
+
# Environment hash
|
11
11
|
#
|
12
12
|
# @return [Array<Integer, Hash, #each>]
|
13
|
-
# Returns a response
|
13
|
+
# Returns a response
|
14
14
|
def call(env)
|
15
15
|
req = Rack::Request.new(env)
|
16
16
|
if req.post? &&
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twenty
|
4
|
+
require "fileutils"
|
5
|
+
require "sequel"
|
6
|
+
require_relative "server/path"
|
7
|
+
|
8
|
+
##
|
9
|
+
# @return [String]
|
10
|
+
# Returns the location of the default SQLite database.
|
11
|
+
def self.default_database
|
12
|
+
@default_database ||= File.join(Path.datadir, "database.sqlite")
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Establishes a database connection.
|
17
|
+
#
|
18
|
+
# @param [String] path
|
19
|
+
# The path to a SQLite3 database file.
|
20
|
+
#
|
21
|
+
# @return [void]
|
22
|
+
def self.establish_connection(path:)
|
23
|
+
@connection = Sequel.connect(
|
24
|
+
adapter: "sqlite",
|
25
|
+
database: path
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.connection
|
30
|
+
establish_connection unless @connection
|
31
|
+
@connection
|
32
|
+
end
|
33
|
+
|
34
|
+
FileUtils.touch(default_database)
|
35
|
+
require_relative "server/graphql"
|
36
|
+
require_relative "server/rack"
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -101,6 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- "./lib/twenty/server.rb"
|
104
105
|
- "./lib/twenty/server/graphql.rb"
|
105
106
|
- "./lib/twenty/server/graphql/input.rb"
|
106
107
|
- "./lib/twenty/server/graphql/input/task_input.rb"
|