twenty-server 0.5.0 → 0.5.1

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: b83eb9e96d4001197f2e9b1433fafcb65b596be12ee1ee524e65a052f1414ee6
4
+ data.tar.gz: 888fa18f5343736fc57aaf55b9be0cc35939420296a7bc42b24bc5d7a06bf2a9
5
5
  SHA512:
6
- metadata.gz: 5ca0d2eca6285ff6c9d7972be1d4a2c0a0c57dbf5edca4d8d07055a49617b12b5d9c2ee6a55142ce2e00cdb3696ec7db8a64fe94d4e3f69b6ef137bd04912996
7
- data.tar.gz: 7b9e1f4c67fccb62dfe4de1c87e86d642e5c8744ccaacc7adfe79d3d18ce160388ed677c0e1131a3f65da9bd24e6fea5f6f12da5d296e238dc54b4404c641b39
6
+ metadata.gz: ba09669cff1d0342c78a4b1f972a6d61028b31103fddfa1330f3d859dd533e51a46198c5636f4a28ceb4202889d891d251fa432c6c626b1a21a569c6a723ce57
7
+ data.tar.gz: 0a05f5c006ce39024ab619133bb26de572c3aa97faf7430979336c0c8a051557d2d88120fbc3c79a95840ff4a6b9447bb56118d739d62b671af45b2cdb7724df
@@ -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.1
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-26 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"