twenty-server 0.5.3 → 0.5.5
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.
- checksums.yaml +4 -4
- data/lib/twenty/server/migration/3_add_color_to_projects.rb +1 -1
- data/lib/twenty/server/migration.rb +8 -7
- data/lib/twenty/server/mixin/colorable.rb +34 -0
- data/lib/twenty/server/mixin.rb +3 -0
- data/lib/twenty/server/model/project.rb +35 -33
- data/lib/twenty/server/model.rb +0 -1
- data/lib/twenty/server.rb +44 -12
- metadata +6 -5
- data/lib/twenty/server/model/mixin/colorable_mixin.rb +0 -32
- data/lib/twenty/server/path.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09a7504d2ef036f0463b573bd999ec4df8fa5e32a48bd40e7e91e947e5f1a25d'
|
4
|
+
data.tar.gz: 6a0e602227119bf35e1857525994e0b019061bc234a0913fc6c9a58dabfbf1da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e09450ff1212091122d480fcb77c3f6d2c319eed0b998986d541f1c5df730cd67b7a98b861336c6dc195e6e46c1d1f452ec09dc39813a177ab80834831b84b
|
7
|
+
data.tar.gz: a3adb49e1dd8132ceebfb0d78638d175a0d0a72fab31d12de7445633328e0a8921b68265d7a8c6bffbb3bc3e51d829db7b062a38ae1c4b17a68e585a3610f0b5
|
@@ -1,25 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Twenty::Migration
|
4
|
-
|
4
|
+
Sequel.extension(:migration)
|
5
|
+
|
5
6
|
##
|
6
7
|
# @return [String]
|
7
|
-
# Returns the path to
|
8
|
+
# Returns the path to the migrations directory
|
8
9
|
def self.migrations_path
|
9
10
|
File.join(__dir__, "migration")
|
10
11
|
end
|
11
12
|
|
12
13
|
##
|
13
|
-
#
|
14
|
+
# Run migrations
|
14
15
|
# @return [void]
|
15
|
-
def self.run!
|
16
|
-
Sequel::Migrator.run(Twenty.connection, migrations_path)
|
16
|
+
def self.run!(options = {})
|
17
|
+
Sequel::Migrator.run(Twenty.connection, migrations_path, options)
|
17
18
|
end
|
18
19
|
|
19
20
|
##
|
20
21
|
# @return [Boolean]
|
21
|
-
# Returns true when there are pending migrations
|
22
|
+
# Returns true when there are pending migrations
|
22
23
|
def self.pending_migrations?
|
23
|
-
Sequel::Migrator.is_current?(Twenty.connection, migrations_path)
|
24
|
+
! Sequel::Migrator.is_current?(Twenty.connection, migrations_path)
|
24
25
|
end
|
25
26
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twenty::Mixin
|
4
|
+
module Colorable
|
5
|
+
extend self
|
6
|
+
|
7
|
+
COLORS = [
|
8
|
+
"#222222", "#333333", "#444444", "#555555", "#666666",
|
9
|
+
"#777777", "#888888", "#999999", "#AA2222", "#22AA22",
|
10
|
+
"#2222AA", "#AA22AA", "#CC9900", "#0099CC", "#9900CC",
|
11
|
+
"#FF9900", "#00CC99", "#99CC00", "#CC0099", "#990000",
|
12
|
+
"#112233", "#445566", "#778899", "#AA4455", "#5544AA",
|
13
|
+
"#88AA44", "#AA88AA", "#CCBB00", "#1155CC", "#9900BB",
|
14
|
+
"#DD6600", "#00BBCC", "#CC0099", "#BB3300", "#006688",
|
15
|
+
"#993366", "#2200AA", "#557788", "#998877", "#BB4400"
|
16
|
+
]
|
17
|
+
|
18
|
+
def before_validation
|
19
|
+
super if defined?(super)
|
20
|
+
set_random_color
|
21
|
+
end
|
22
|
+
|
23
|
+
def random_color
|
24
|
+
COLORS.sample
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_random_color
|
30
|
+
return if id
|
31
|
+
self.color = random_color
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,42 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Twenty
|
4
|
+
class Project < Sequel::Model
|
5
|
+
include Model
|
6
|
+
include Mixin::Colorable
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
validates_presence_of :name
|
9
|
+
validates_presence_of :path
|
10
|
+
one_to_many :tasks, class_name: "Twenty::Task"
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
##
|
13
|
+
# @api private
|
14
|
+
def validate
|
15
|
+
super
|
16
|
+
errors.add(:path, "does not exist on disk") if !path_exist?
|
17
|
+
errors.add(:path, "is not absolute") if !File.absolute_path?(self[:path])
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
##
|
21
|
+
# @return [String]
|
22
|
+
# The path to a project
|
23
|
+
def path
|
24
|
+
super&.sub(Dir.home, "~")
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
##
|
28
|
+
# @return [Boolean]
|
29
|
+
# Returns true when {#path} exists on disk
|
30
|
+
def path_exist?
|
31
|
+
File.exist? File.expand_path(path)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
##
|
35
|
+
# @return [Integer]
|
36
|
+
# Returns the number of open tasks a project has
|
37
|
+
def open_task_count
|
38
|
+
@open_task_count ||= Twenty::Task
|
39
|
+
.where(project_id: id)
|
40
|
+
.where(Sequel.lit("status IN (0,1,2)"))
|
41
|
+
.count
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
data/lib/twenty/server/model.rb
CHANGED
data/lib/twenty/server.rb
CHANGED
@@ -1,22 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Twenty
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
extend Module.new {
|
5
|
+
require "tmpdir"
|
6
|
+
require "fileutils"
|
7
|
+
extend self
|
8
|
+
extend FileUtils
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
##
|
11
|
+
# @return [String]
|
12
|
+
# Returns the path for the default SQLite database
|
13
|
+
def default_database
|
14
|
+
@default_database ||= File.join(datadir, "database.sqlite")
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# @return [String]
|
19
|
+
# Returns the directory where twenty stores data
|
20
|
+
def datadir
|
21
|
+
File.join(Dir.home, ".local", "share", "twenty")
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# @return [String]
|
26
|
+
# Returns the directory where twenty stores temporary data
|
27
|
+
def tmpdir
|
28
|
+
File.join(Dir.tmpdir, "twenty")
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# @return [String]
|
33
|
+
# Returns the path to a PID file
|
34
|
+
def pid
|
35
|
+
File.join(tmpdir, "server.pid")
|
36
|
+
end
|
37
|
+
|
38
|
+
mkdir_p(datadir)
|
39
|
+
mkdir_p(tmpdir)
|
40
|
+
}
|
14
41
|
|
15
42
|
##
|
16
|
-
# Establishes a database connection
|
43
|
+
# Establishes a database connection
|
17
44
|
#
|
18
45
|
# @param [String] path
|
19
|
-
# The path to a
|
46
|
+
# The path to a SQLite database
|
20
47
|
#
|
21
48
|
# @return [void]
|
22
49
|
def self.establish_connection(path:)
|
@@ -26,12 +53,17 @@ module Twenty
|
|
26
53
|
)
|
27
54
|
end
|
28
55
|
|
56
|
+
##
|
57
|
+
# @return [Sequel::Database::SQLite]
|
58
|
+
# Returns the connection to a database
|
29
59
|
def self.connection
|
30
60
|
establish_connection unless @connection
|
31
61
|
@connection
|
32
62
|
end
|
33
63
|
|
34
|
-
|
64
|
+
require "sequel"
|
65
|
+
require_relative "server/mixin"
|
66
|
+
require_relative "server/migration"
|
35
67
|
require_relative "server/graphql"
|
36
68
|
require_relative "server/rack"
|
37
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
@@ -94,7 +94,8 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.35'
|
97
|
-
description:
|
97
|
+
description: Provides the server component of twenty. See https://rubygems.org/gems/twenty
|
98
|
+
for context.
|
98
99
|
email:
|
99
100
|
- 0x1eef@protonmail.com
|
100
101
|
executables: []
|
@@ -122,11 +123,11 @@ files:
|
|
122
123
|
- "./lib/twenty/server/migration/1_create_projects.rb"
|
123
124
|
- "./lib/twenty/server/migration/2_create_tasks.rb"
|
124
125
|
- "./lib/twenty/server/migration/3_add_color_to_projects.rb"
|
126
|
+
- "./lib/twenty/server/mixin.rb"
|
127
|
+
- "./lib/twenty/server/mixin/colorable.rb"
|
125
128
|
- "./lib/twenty/server/model.rb"
|
126
|
-
- "./lib/twenty/server/model/mixin/colorable_mixin.rb"
|
127
129
|
- "./lib/twenty/server/model/project.rb"
|
128
130
|
- "./lib/twenty/server/model/task.rb"
|
129
|
-
- "./lib/twenty/server/path.rb"
|
130
131
|
- "./lib/twenty/server/rack.rb"
|
131
132
|
- "./lib/twenty/server/rack/graphql.rb"
|
132
133
|
- "./share/twenty/server/schema.graphql"
|
@@ -152,5 +153,5 @@ requirements: []
|
|
152
153
|
rubygems_version: 3.5.9
|
153
154
|
signing_key:
|
154
155
|
specification_version: 4
|
155
|
-
summary:
|
156
|
+
summary: Provides the server component of twenty
|
156
157
|
test_files: []
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty::ColorableMixin
|
4
|
-
extend self
|
5
|
-
|
6
|
-
COLORS = [
|
7
|
-
"#222222", "#333333", "#444444", "#555555", "#666666",
|
8
|
-
"#777777", "#888888", "#999999", "#AA2222", "#22AA22",
|
9
|
-
"#2222AA", "#AA22AA", "#CC9900", "#0099CC", "#9900CC",
|
10
|
-
"#FF9900", "#00CC99", "#99CC00", "#CC0099", "#990000",
|
11
|
-
"#112233", "#445566", "#778899", "#AA4455", "#5544AA",
|
12
|
-
"#88AA44", "#AA88AA", "#CCBB00", "#1155CC", "#9900BB",
|
13
|
-
"#DD6600", "#00BBCC", "#CC0099", "#BB3300", "#006688",
|
14
|
-
"#993366", "#2200AA", "#557788", "#998877", "#BB4400"
|
15
|
-
]
|
16
|
-
|
17
|
-
def before_validation
|
18
|
-
super if defined?(super)
|
19
|
-
set_random_color
|
20
|
-
end
|
21
|
-
|
22
|
-
def random_color
|
23
|
-
COLORS.sample
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def set_random_color
|
29
|
-
return if id
|
30
|
-
self.color = random_color
|
31
|
-
end
|
32
|
-
end
|
data/lib/twenty/server/path.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty::Path
|
4
|
-
require "tmpdir"
|
5
|
-
extend self
|
6
|
-
|
7
|
-
##
|
8
|
-
# @return [String]
|
9
|
-
# Returns the directory where twenty stores persistent data.
|
10
|
-
def datadir
|
11
|
-
File.join(Dir.home, ".local", "share", "twenty")
|
12
|
-
end
|
13
|
-
|
14
|
-
##
|
15
|
-
# @return [String]
|
16
|
-
# Returns the directory where twenty stores temporary data.
|
17
|
-
def tmpdir
|
18
|
-
File.join(Dir.tmpdir, "twenty")
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# @return [String]
|
23
|
-
# Returns the file where twenty can write the PID of
|
24
|
-
# a web server running in the background.
|
25
|
-
def pidfile
|
26
|
-
File.join(tmpdir, "server.pid")
|
27
|
-
end
|
28
|
-
|
29
|
-
FileUtils.mkdir_p(datadir)
|
30
|
-
FileUtils.mkdir_p(tmpdir)
|
31
|
-
end
|