taskchampion-rb 0.9.1 → 0.9.2
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/ext/taskchampion/src/error.rs +0 -8
- data/ext/taskchampion/src/replica.rs +1 -1
- data/ext/taskchampion/src/task.rs +12 -12
- data/ext/taskchampion/src/thread_check.rs +2 -2
- data/ext/taskchampion/src/util.rs +0 -23
- data/lib/taskchampion/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d963e64502ad438957e3345671387a3915de84947a63bbcced83270f5c50848
|
|
4
|
+
data.tar.gz: 19309ecfe6ccf1a5a077a513a7b6ff769109ba7949c0282617b8b74e3b54f116
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '052509a0688871de92bc3d4219d7c257b712b7f4b7f5693f4e051d2ff38f891d5b6095d66aaf0cec8d06466ec272ec1fe5bd7e166dd790fb2a0c649592a29d4b'
|
|
7
|
+
data.tar.gz: f21cca16bd5da5921474361eb81d18937a1e328313a4c3dac2ea521ccc4d7b93cf356816d11e67abfa7292bbcfb76e40548766b94718030e42a315a80c3e5531
|
|
@@ -11,14 +11,6 @@ pub fn init_errors(module: &RModule) -> Result<(), Error> {
|
|
|
11
11
|
Ok(())
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
pub fn base_error() -> magnus::ExceptionClass {
|
|
15
|
-
let ruby = magnus::Ruby::get().expect("Ruby not available");
|
|
16
|
-
let module = ruby.class_object().const_get::<_, RModule>("Taskchampion")
|
|
17
|
-
.expect("Taskchampion module not found");
|
|
18
|
-
module.const_get::<_, magnus::ExceptionClass>("Error")
|
|
19
|
-
.expect("Error class not initialized")
|
|
20
|
-
}
|
|
21
|
-
|
|
22
14
|
pub fn thread_error() -> magnus::ExceptionClass {
|
|
23
15
|
let ruby = magnus::Ruby::get().expect("Ruby not available");
|
|
24
16
|
let module = ruby.class_object().const_get::<_, RModule>("Taskchampion")
|
|
@@ -58,7 +58,7 @@ impl Replica {
|
|
|
58
58
|
let tc_task = tc_replica.create_task(tc_uuid, &mut tc_ops).map_err(into_error)?;
|
|
59
59
|
|
|
60
60
|
// Add the resulting operations to the provided Operations object
|
|
61
|
-
operations.extend_from_tc(tc_ops)
|
|
61
|
+
operations.extend_from_tc(tc_ops)?;
|
|
62
62
|
|
|
63
63
|
// Convert to Ruby Task object
|
|
64
64
|
let task = Task::from_tc_task(tc_task);
|
|
@@ -137,24 +137,22 @@ impl Task {
|
|
|
137
137
|
|
|
138
138
|
fn get_uda(&self, namespace: String, key: String) -> Result<Value, Error> {
|
|
139
139
|
let task = self.0.get()?;
|
|
140
|
-
|
|
140
|
+
let combined_key = if namespace.is_empty() { key } else { format!("{}.{}", namespace, key) };
|
|
141
|
+
match task.get_user_defined_attribute(&combined_key) {
|
|
141
142
|
Some(value) => Ok(value.into_value()),
|
|
142
|
-
None => Ok(().into_value()),
|
|
143
|
+
None => Ok(().into_value()),
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
fn udas(&self) -> Result<RArray, Error> {
|
|
147
148
|
let task = self.0.get()?;
|
|
148
|
-
let udas: Vec<(
|
|
149
|
-
.map(|(
|
|
149
|
+
let udas: Vec<(String, String)> = task.get_user_defined_attributes()
|
|
150
|
+
.map(|(key, value)| (key.to_string(), value.to_string()))
|
|
150
151
|
.collect();
|
|
151
152
|
|
|
152
|
-
vec_to_ruby(udas, |(
|
|
153
|
+
vec_to_ruby(udas, |(key, value)| {
|
|
153
154
|
let array = RArray::new();
|
|
154
|
-
|
|
155
|
-
key_array.push(key_tuple.0)?;
|
|
156
|
-
key_array.push(key_tuple.1)?;
|
|
157
|
-
array.push(key_array)?;
|
|
155
|
+
array.push(key)?;
|
|
158
156
|
array.push(value)?;
|
|
159
157
|
Ok(array.into_value())
|
|
160
158
|
})
|
|
@@ -360,7 +358,7 @@ impl Task {
|
|
|
360
358
|
Some(timestamp_str) => {
|
|
361
359
|
// Parse the string as Unix timestamp (seconds since epoch)
|
|
362
360
|
if let Ok(timestamp_secs) = timestamp_str.parse::<i64>() {
|
|
363
|
-
use chrono::
|
|
361
|
+
use chrono::DateTime;
|
|
364
362
|
if let Some(dt) = DateTime::from_timestamp(timestamp_secs, 0) {
|
|
365
363
|
return datetime_to_ruby(dt);
|
|
366
364
|
}
|
|
@@ -387,8 +385,9 @@ impl Task {
|
|
|
387
385
|
}
|
|
388
386
|
|
|
389
387
|
let mut task = self.0.get_mut()?;
|
|
388
|
+
let combined_key = format!("{}.{}", namespace, key);
|
|
390
389
|
operations.with_inner_mut(|ops| {
|
|
391
|
-
task.
|
|
390
|
+
task.set_user_defined_attribute(&combined_key, &value, ops)
|
|
392
391
|
})?;
|
|
393
392
|
Ok(())
|
|
394
393
|
}
|
|
@@ -408,8 +407,9 @@ impl Task {
|
|
|
408
407
|
}
|
|
409
408
|
|
|
410
409
|
let mut task = self.0.get_mut()?;
|
|
410
|
+
let combined_key = format!("{}.{}", namespace, key);
|
|
411
411
|
operations.with_inner_mut(|ops| {
|
|
412
|
-
task.
|
|
412
|
+
task.remove_user_defined_attribute(&combined_key, ops)
|
|
413
413
|
})?;
|
|
414
414
|
Ok(())
|
|
415
415
|
}
|
|
@@ -32,12 +32,12 @@ impl<T> ThreadBound<T> {
|
|
|
32
32
|
Ok(())
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
pub fn get(&self) -> Result<std::cell::Ref<T>, Error> {
|
|
35
|
+
pub fn get(&self) -> Result<std::cell::Ref<'_, T>, Error> {
|
|
36
36
|
self.check_thread()?;
|
|
37
37
|
Ok(self.inner.borrow())
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
pub fn get_mut(&self) -> Result<std::cell::RefMut<T>, Error> {
|
|
40
|
+
pub fn get_mut(&self) -> Result<std::cell::RefMut<'_, T>, Error> {
|
|
41
41
|
self.check_thread()?;
|
|
42
42
|
Ok(self.inner.borrow_mut())
|
|
43
43
|
}
|
|
@@ -31,8 +31,6 @@ pub fn datetime_to_ruby(dt: DateTime<Utc>) -> Result<Value, Error> {
|
|
|
31
31
|
|
|
32
32
|
/// Convert Ruby DateTime/Time/String to Rust DateTime<Utc> with enhanced validation
|
|
33
33
|
pub fn ruby_to_datetime(value: Value) -> Result<DateTime<Utc>, Error> {
|
|
34
|
-
let ruby = magnus::Ruby::get().map_err(|e| Error::new(magnus::exception::runtime_error(), e.to_string()))?;
|
|
35
|
-
|
|
36
34
|
// If it's a string, parse it
|
|
37
35
|
if let Ok(s) = RString::try_convert(value) {
|
|
38
36
|
let s = unsafe { s.as_str()? };
|
|
@@ -99,15 +97,6 @@ where
|
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
/// Convert HashMap to Ruby Hash
|
|
103
|
-
pub fn hashmap_to_ruby(map: HashMap<String, String>) -> Result<RHash, Error> {
|
|
104
|
-
let hash = RHash::new();
|
|
105
|
-
for (k, v) in map {
|
|
106
|
-
hash.aset(k, v)?;
|
|
107
|
-
}
|
|
108
|
-
Ok(hash)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
100
|
/// Convert Ruby Hash to HashMap
|
|
112
101
|
pub fn ruby_to_hashmap(hash: RHash) -> Result<HashMap<String, String>, Error> {
|
|
113
102
|
let mut map = HashMap::new();
|
|
@@ -130,15 +119,3 @@ where
|
|
|
130
119
|
Ok(array)
|
|
131
120
|
}
|
|
132
121
|
|
|
133
|
-
/// Convert Ruby Array to Vec
|
|
134
|
-
pub fn ruby_to_vec<T, F>(array: RArray, converter: F) -> Result<Vec<T>, Error>
|
|
135
|
-
where
|
|
136
|
-
F: Fn(Value) -> Result<T, Error>,
|
|
137
|
-
{
|
|
138
|
-
let mut vec = Vec::with_capacity(array.len());
|
|
139
|
-
for i in 0..array.len() {
|
|
140
|
-
let value: Value = array.entry(i as isize)?;
|
|
141
|
-
vec.push(converter(value)?);
|
|
142
|
-
}
|
|
143
|
-
Ok(vec)
|
|
144
|
-
}
|
data/lib/taskchampion/version.rb
CHANGED