tudla_contracts 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +175 -0
- data/Rakefile +12 -0
- data/lib/tudla_contracts/integrations/host_interface.rb +39 -0
- data/lib/tudla_contracts/integrations/registry.rb +90 -0
- data/lib/tudla_contracts/integrations/view_definitions/base.rb +30 -0
- data/lib/tudla_contracts/integrations/view_definitions/dashboard_section_definition.rb +11 -0
- data/lib/tudla_contracts/integrations/view_definitions/show_tab_definition.rb +11 -0
- data/lib/tudla_contracts/integrations/view_defintions.rb +3 -0
- data/lib/tudla_contracts/time_sheet/base.rb +25 -0
- data/lib/tudla_contracts/version.rb +5 -0
- data/lib/tudla_contracts.rb +12 -0
- data/sig/tudla_contracts.rbs +4 -0
- metadata +66 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ae48bdd0b24050feb695a73d69fc487f57e5e1fe3eb77d47b2e46e4a0949474a
|
|
4
|
+
data.tar.gz: 12d6dd76439145a4194169fa638a8bdcd7884fd6b777447449832e4826b3bc99
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3a5366b20effc045d051affe7c92a4fbea212adf884cb1ab5d8b138d8f3224106a0f8e184058788a3de7263bb8cc37c4963b2624b121ca410f7014a4f95e3f23
|
|
7
|
+
data.tar.gz: f41cf8279508eb41c73e66740dc09e10a6261ae3113f943c4d827a2733eefdd62c2030348bd43de675a40c7efb9f49a2ea7a7db9b5c99faa2af9815a02203abc
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.3.4
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 The Tudla Authors
|
|
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,175 @@
|
|
|
1
|
+
# TudlaContracts
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/tudla_contracts)
|
|
4
|
+
[](LICENSE.txt)
|
|
5
|
+
[](https://www.ruby-lang.org)
|
|
6
|
+
|
|
7
|
+
A shared contracts gem for Tudla integrations. This gem provides base classes, interfaces, and a registry system for building pluggable integrations with the Tudla platform.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Integration Registry** - Thread-safe registration and lookup of integration providers
|
|
12
|
+
- **Host Interface** - Abstract interface for host applications to provide user, task, and project data
|
|
13
|
+
- **TimeSheet Base** - Base class for building time sheet integrations with a standardized API
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Add this line to your application's Gemfile:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem "tudla_contracts"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
And then execute:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bundle install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or install it yourself as:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
gem install tudla_contracts
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
|
|
37
|
+
- Ruby >= 3.0.0
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Integration Registry
|
|
42
|
+
|
|
43
|
+
Register your integration provider using fully qualified class name strings:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
TudlaContracts::Integrations::Registry.register(
|
|
47
|
+
:my_provider,
|
|
48
|
+
type: :time_sheet,
|
|
49
|
+
provider_class: "MyGem::Providers::TimeSheetProvider",
|
|
50
|
+
config_class: "MyGem::Config::TimeSheetConfig"
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Look up registered integrations:
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
# Find a specific provider (returns class name string)
|
|
58
|
+
provider_class_name = TudlaContracts::Integrations::Registry.find(:my_provider)
|
|
59
|
+
# => "MyGem::Providers::TimeSheetProvider"
|
|
60
|
+
|
|
61
|
+
# Instantiate the provider
|
|
62
|
+
provider = provider_class_name.constantize.new(config)
|
|
63
|
+
|
|
64
|
+
# Get all providers of a type
|
|
65
|
+
time_sheet_providers = TudlaContracts::Integrations::Registry.all_of_type(:time_sheet)
|
|
66
|
+
|
|
67
|
+
# List available provider names
|
|
68
|
+
TudlaContracts::Integrations::Registry.available_providers
|
|
69
|
+
# => ["my_provider"]
|
|
70
|
+
|
|
71
|
+
# Get config class for a provider (returns class name string)
|
|
72
|
+
config_class_name = TudlaContracts::Integrations::Registry.config_class_for(:my_provider)
|
|
73
|
+
# => "MyGem::Config::TimeSheetConfig"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Host Interface
|
|
77
|
+
|
|
78
|
+
Implement the host interface to provide data from your application:
|
|
79
|
+
|
|
80
|
+
```ruby
|
|
81
|
+
class MyHostInterface < TudlaContracts::Integrations::HostInterface
|
|
82
|
+
def available_users_for_user(user)
|
|
83
|
+
# Return array of TudlaContracts::Integrations::User structs
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def available_tasks_for_user(user)
|
|
87
|
+
# Return array of TudlaContracts::Integrations::Task structs
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def available_projects_for_user(user)
|
|
91
|
+
# Return array of TudlaContracts::Integrations::Project structs
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def find_task(task_id)
|
|
95
|
+
# Return a TudlaContracts::Integrations::Task struct
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Available data structures:
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
TudlaContracts::Integrations::User.new(id:, name:, email:)
|
|
104
|
+
TudlaContracts::Integrations::Task.new(id:, name:, project_name:)
|
|
105
|
+
TudlaContracts::Integrations::Project.new(id:, name:)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### TimeSheet Integration
|
|
109
|
+
|
|
110
|
+
Create a time sheet provider by extending the base class:
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
class MyTimeSheetProvider < TudlaContracts::TimeSheet::Base
|
|
114
|
+
def daily_activities(user, date, task_ids = nil)
|
|
115
|
+
# Fetch and return activities for the given date
|
|
116
|
+
# Returns array of TudlaContracts::TimeSheet::ActivitySummary
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Activity summary structure:
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
TudlaContracts::TimeSheet::ActivitySummary.new(
|
|
125
|
+
task_id:,
|
|
126
|
+
total_seconds:,
|
|
127
|
+
notes:,
|
|
128
|
+
remote_id:,
|
|
129
|
+
metadata:
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Development
|
|
134
|
+
|
|
135
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Install dependencies
|
|
139
|
+
bin/setup
|
|
140
|
+
|
|
141
|
+
# Run tests
|
|
142
|
+
bundle exec rake spec
|
|
143
|
+
|
|
144
|
+
# Run linter
|
|
145
|
+
bundle exec rubocop
|
|
146
|
+
|
|
147
|
+
# Start interactive console
|
|
148
|
+
bin/console
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
152
|
+
|
|
153
|
+
## Releasing
|
|
154
|
+
|
|
155
|
+
1. Update the version number in `lib/tudla_contracts/version.rb`
|
|
156
|
+
2. Update `CHANGELOG.md` with the new version's changes
|
|
157
|
+
3. Run `bundle exec rake release` to create a git tag, push commits and tags, and publish to RubyGems
|
|
158
|
+
|
|
159
|
+
## Contributing
|
|
160
|
+
|
|
161
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tibomogul/tudla_contracts. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).
|
|
162
|
+
|
|
163
|
+
1. Fork it
|
|
164
|
+
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
|
165
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
166
|
+
4. Push to the branch (`git push origin feature/my-new-feature`)
|
|
167
|
+
5. Create a new Pull Request
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
|
172
|
+
|
|
173
|
+
## Code of Conduct
|
|
174
|
+
|
|
175
|
+
Everyone interacting in the TudlaContracts project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TudlaContracts
|
|
4
|
+
module Integrations
|
|
5
|
+
User = Struct.new(:id, :name, :email)
|
|
6
|
+
Task = Struct.new(:id, :name, :project_name)
|
|
7
|
+
Project = Struct.new(:id, :name)
|
|
8
|
+
# Host application interface for TudlaContracts
|
|
9
|
+
class HostInterface
|
|
10
|
+
# Returns an array of users available to the user
|
|
11
|
+
# @param user [User] The host application User object
|
|
12
|
+
# @return [Array<User>]
|
|
13
|
+
def available_users_for_user(user)
|
|
14
|
+
raise NotImplementedError, "#{self.class.name} must implement #avaliable_users_for_user"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Returns an array of tasks available to the user
|
|
18
|
+
# @param user [User] The host application User object
|
|
19
|
+
# @return [Array<Task>]
|
|
20
|
+
def available_tasks_for_user(user)
|
|
21
|
+
raise NotImplementedError, "#{self.class.name} must implement #avaliable_tasks_for_user"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns an array of projects available to the user
|
|
25
|
+
# @param user [User] The host application User object
|
|
26
|
+
# @return [Array<Project>]
|
|
27
|
+
def available_projects_for_user(user)
|
|
28
|
+
raise NotImplementedError, "#{self.class.name} must implement #avaliable_projects_for_user"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns a Tudla task by id
|
|
32
|
+
# @param task_id [Integer] The Tudla task id
|
|
33
|
+
# @return [Task]
|
|
34
|
+
def find_task(task_id)
|
|
35
|
+
raise NotImplementedError, "#{self.class.name} must implement #find_task"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TudlaContracts
|
|
4
|
+
module Integrations
|
|
5
|
+
# Shared class for registering and looking up integrations
|
|
6
|
+
class Registry
|
|
7
|
+
# Thread-safe storage for registered integrations
|
|
8
|
+
@integrations = {}
|
|
9
|
+
# Thread-safe storage for registered view definitions
|
|
10
|
+
@view_slots = {}
|
|
11
|
+
|
|
12
|
+
VALID_TYPES = %w[time_sheet].freeze
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# Method called by gems to register themselves
|
|
16
|
+
# @param name [String, Symbol] Unique identifier for the integration
|
|
17
|
+
# @param type [String, Symbol] Integration type (e.g., :time_sheet)
|
|
18
|
+
# @param provider_class [String] Fully qualified class name of the provider
|
|
19
|
+
# @param config_class [String] Fully qualified class name of the config
|
|
20
|
+
def register(name, type:, provider_class:, config_class:)
|
|
21
|
+
@integrations[name.to_s] = {
|
|
22
|
+
type: type.to_s,
|
|
23
|
+
provider_class: provider_class.to_s,
|
|
24
|
+
config_class: config_class.to_s
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Reset the registry
|
|
29
|
+
def reset!
|
|
30
|
+
@integrations = {}
|
|
31
|
+
@view_slots = {}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Method called by gems to register view definitions for slots
|
|
35
|
+
# @param slot [String, Symbol] Slot name
|
|
36
|
+
# @param view_definition [Object] An instance of a class that inherits from ViewDefinitions::Base
|
|
37
|
+
def register_view_for_slot(slot, view_definition)
|
|
38
|
+
unless view_definition.class.ancestors.any? { |a| a.name&.end_with?("ViewDefinitions::Base") }
|
|
39
|
+
raise ArgumentError, "view_definition must be an instance of a class that inherits from ViewDefinitions::Base"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@view_slots[slot.to_s] ||= []
|
|
43
|
+
@view_slots[slot.to_s] << view_definition
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Used by the Host App to look up view components for a specific slot
|
|
47
|
+
# @param slot [String, Symbol] Slot name
|
|
48
|
+
# @return [Array<String>] Array of fully qualified view component class names
|
|
49
|
+
def views_for_slot(slot)
|
|
50
|
+
@view_slots[slot.to_s] || []
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Used by the Host App to look up all registered slots
|
|
54
|
+
def registered_slots
|
|
55
|
+
@view_slots.keys
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Used by the Host App to look up a specific provider
|
|
59
|
+
# @param name [String, Symbol] Integration name
|
|
60
|
+
# @return [String] Fully qualified provider class name
|
|
61
|
+
def find(name)
|
|
62
|
+
entry = @integrations[name.to_s]
|
|
63
|
+
raise ArgumentError, "Unknown integration: #{name}" unless entry
|
|
64
|
+
|
|
65
|
+
entry[:provider_class]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Used by the Host App to look up all integrations of a specific type
|
|
69
|
+
def all_of_type(type)
|
|
70
|
+
@integrations.select { |_, v| v[:type] == type.to_s }.values
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Used by the Host App to find the config class for polymorphic associations
|
|
74
|
+
# @param name [String, Symbol] Integration name
|
|
75
|
+
# @return [String, nil] Fully qualified config class name or nil if not found
|
|
76
|
+
def config_class_for(name)
|
|
77
|
+
entry = @integrations[name.to_s]
|
|
78
|
+
return nil unless entry
|
|
79
|
+
|
|
80
|
+
entry[:config_class]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Used to populate UI dropdowns
|
|
84
|
+
def available_providers
|
|
85
|
+
@integrations.keys
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TudlaContracts
|
|
4
|
+
module Integrations
|
|
5
|
+
module ViewDefinitions
|
|
6
|
+
# Base class for all view definitions
|
|
7
|
+
# Subclasses must implement the #visible? method
|
|
8
|
+
class Base
|
|
9
|
+
attr_reader :id, :label, :component_class, :priority, :condition
|
|
10
|
+
|
|
11
|
+
def initialize(id:, label:, component_class:, priority: 10, if: nil)
|
|
12
|
+
@id = id
|
|
13
|
+
@label = label
|
|
14
|
+
@component_class = component_class
|
|
15
|
+
@priority = priority
|
|
16
|
+
# Capture the conditional logic (lambda/proc)
|
|
17
|
+
@condition = binding.local_variable_get(:if)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Helper to check visibility within a specific context
|
|
21
|
+
def visible?(context, *args)
|
|
22
|
+
return true if @condition.nil?
|
|
23
|
+
|
|
24
|
+
# Execute the condition in the context of the view (context)
|
|
25
|
+
context.instance_exec(*args, &@condition)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TudlaContracts
|
|
4
|
+
module TimeSheet
|
|
5
|
+
ActivitySummary = Struct.new(:task_id, :total_seconds, :notes, :remote_id, :metadata)
|
|
6
|
+
|
|
7
|
+
# Base class for time sheet integrations
|
|
8
|
+
class Base
|
|
9
|
+
attr_reader :config
|
|
10
|
+
|
|
11
|
+
def initialize(config)
|
|
12
|
+
@config = config
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# The core method for retrieving data.
|
|
16
|
+
# @param user [User] The host application User object
|
|
17
|
+
# @param date The date for which to retrieve activities
|
|
18
|
+
# @param task_ids [Array<Integer>] Optional filter for specific tasks
|
|
19
|
+
# @return
|
|
20
|
+
def daily_activities(user, date, task_ids)
|
|
21
|
+
raise NotImplementedError, "#{self.class.name} must implement #daily_activities"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "tudla_contracts/version"
|
|
4
|
+
require_relative "tudla_contracts/integrations/registry"
|
|
5
|
+
require_relative "tudla_contracts/integrations/host_interface"
|
|
6
|
+
require_relative "tudla_contracts/integrations/view_defintions"
|
|
7
|
+
require_relative "tudla_contracts/time_sheet/base"
|
|
8
|
+
|
|
9
|
+
module TudlaContracts
|
|
10
|
+
class Error < StandardError; end
|
|
11
|
+
# Your code goes here...
|
|
12
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tudla_contracts
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tibo Mogul
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-02-07 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Tudla Contracts - a shared gem for Tudla integrations
|
|
14
|
+
email:
|
|
15
|
+
- tibo.mogul@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".rspec"
|
|
21
|
+
- ".rubocop.yml"
|
|
22
|
+
- ".ruby-version"
|
|
23
|
+
- CHANGELOG.md
|
|
24
|
+
- CODE_OF_CONDUCT.md
|
|
25
|
+
- LICENSE.txt
|
|
26
|
+
- README.md
|
|
27
|
+
- Rakefile
|
|
28
|
+
- lib/tudla_contracts.rb
|
|
29
|
+
- lib/tudla_contracts/integrations/host_interface.rb
|
|
30
|
+
- lib/tudla_contracts/integrations/registry.rb
|
|
31
|
+
- lib/tudla_contracts/integrations/view_definitions/base.rb
|
|
32
|
+
- lib/tudla_contracts/integrations/view_definitions/dashboard_section_definition.rb
|
|
33
|
+
- lib/tudla_contracts/integrations/view_definitions/show_tab_definition.rb
|
|
34
|
+
- lib/tudla_contracts/integrations/view_defintions.rb
|
|
35
|
+
- lib/tudla_contracts/time_sheet/base.rb
|
|
36
|
+
- lib/tudla_contracts/version.rb
|
|
37
|
+
- sig/tudla_contracts.rbs
|
|
38
|
+
homepage: https://tibomogul.github.io/
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
41
|
+
metadata:
|
|
42
|
+
allowed_push_host: https://rubygems.org
|
|
43
|
+
rubygems_mfa_required: 'true'
|
|
44
|
+
homepage_uri: https://tibomogul.github.io/
|
|
45
|
+
source_code_uri: https://github.com/tibomogul/tudla_contracts
|
|
46
|
+
changelog_uri: https://github.com/tibomogul/tudla_contracts/blob/main/CHANGELOG.md
|
|
47
|
+
post_install_message:
|
|
48
|
+
rdoc_options: []
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 3.0.0
|
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
requirements: []
|
|
62
|
+
rubygems_version: 3.5.11
|
|
63
|
+
signing_key:
|
|
64
|
+
specification_version: 4
|
|
65
|
+
summary: Tudla Contracts
|
|
66
|
+
test_files: []
|