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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 586b411b7901b68e979b8640282eea96470b4433481d1785bff14cdf3bddcc78
4
- data.tar.gz: c8b7b7e848bc6525f62d2512757066cca27bdc7dbb0dd055961738b18c84a256
3
+ metadata.gz: e757edafe6098ad6fdb828673a80a368fef19102c0d423b37505a89fbf7ef5f2
4
+ data.tar.gz: 43f1d07bc5b01ed9ac0d80b99a35fac3b5e38770fa2f63bd6131c8c26af3fe91
5
5
  SHA512:
6
- metadata.gz: 5ca0d2eca6285ff6c9d7972be1d4a2c0a0c57dbf5edca4d8d07055a49617b12b5d9c2ee6a55142ce2e00cdb3696ec7db8a64fe94d4e3f69b6ef137bd04912996
7
- data.tar.gz: 7b9e1f4c67fccb62dfe4de1c87e86d642e5c8744ccaacc7adfe79d3d18ce160388ed677c0e1131a3f65da9bd24e6fea5f6f12da5d296e238dc54b4404c641b39
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.0
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-25 00:00:00.000000000 Z
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"