standard-file 0.2.0 → 0.2.1
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/README.md +0 -28
- data/lib/standard_file/sync_manager.rb +19 -12
- data/lib/standard_file/user_manager.rb +20 -7
- data/lib/standard_file/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b119105d8253ec0363b7eacef2f93de2f15ad39c
|
4
|
+
data.tar.gz: fce8a2904b7b5cb291a0d0588e21de6074adfcce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3029ce76229b771a8820819ea790ea32d66c01c821d68c72a30280b0a43e66936d7ad78c9b43a0512ac13b16e7b12bd8ff5fe2a27e868d08c5d139ffe744d1bd
|
7
|
+
data.tar.gz: a85108a38988fc9a126bc7751a86434c592a8305180fe45e6e5ee4b7fc6cf320eb86200f707aea1c3522c85c696d4f258b9070f2cd8270452d1b46ae9c2a3888
|
data/README.md
CHANGED
@@ -1,28 +0,0 @@
|
|
1
|
-
# StandardFile
|
2
|
-
Short description and motivation.
|
3
|
-
|
4
|
-
## Usage
|
5
|
-
How to use my plugin.
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
Add this line to your application's Gemfile:
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
gem 'standard_file'
|
12
|
-
```
|
13
|
-
|
14
|
-
And then execute:
|
15
|
-
```bash
|
16
|
-
$ bundle
|
17
|
-
```
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
```bash
|
21
|
-
$ gem install standard_file
|
22
|
-
```
|
23
|
-
|
24
|
-
## Contributing
|
25
|
-
Contribution directions go here.
|
26
|
-
|
27
|
-
## License
|
28
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -17,6 +17,7 @@ module StandardFile
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def sync(item_hashes, options)
|
20
|
+
|
20
21
|
in_sync_token = options[:sync_token]
|
21
22
|
in_cursor_token = options[:cursor_token]
|
22
23
|
limit = options[:limit]
|
@@ -28,7 +29,23 @@ module StandardFile
|
|
28
29
|
last_updated = saved_items.sort_by{|m| m.updated_at}.last.updated_at
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
+
last_updated = check_for_conflicts(saved_items, retrieved_items, last_updated)
|
33
|
+
|
34
|
+
# add 1 microsecond to avoid returning same object in subsequent sync
|
35
|
+
last_updated = (last_updated.to_time + 1/100000.0).to_datetime.utc
|
36
|
+
|
37
|
+
sync_token = sync_token_from_datetime(last_updated)
|
38
|
+
return {
|
39
|
+
:retrieved_items => retrieved_items,
|
40
|
+
:saved_items => saved_items,
|
41
|
+
:unsaved => unsaved,
|
42
|
+
:sync_token => sync_token,
|
43
|
+
:cursor_token => cursor_token
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def check_for_conflicts(saved_items, retrieved_items, last_updated)
|
48
|
+
# conflicts occur when you are trying to save an item for which there is a pending change already
|
32
49
|
min_conflict_interval = 20
|
33
50
|
|
34
51
|
saved_ids = saved_items.map{|x| x.uuid }
|
@@ -53,17 +70,7 @@ module StandardFile
|
|
53
70
|
retrieved_items.delete(conflicted)
|
54
71
|
end
|
55
72
|
|
56
|
-
|
57
|
-
last_updated = (last_updated.to_time + 1/100000.0).to_datetime.utc
|
58
|
-
|
59
|
-
sync_token = sync_token_from_datetime(last_updated)
|
60
|
-
return {
|
61
|
-
:retrieved_items => retrieved_items,
|
62
|
-
:saved_items => saved_items,
|
63
|
-
:unsaved => unsaved,
|
64
|
-
:sync_token => sync_token,
|
65
|
-
:cursor_token => cursor_token
|
66
|
-
}
|
73
|
+
return last_updated
|
67
74
|
end
|
68
75
|
|
69
76
|
def destroy_items(uuids)
|
@@ -32,14 +32,27 @@ module StandardFile
|
|
32
32
|
return { user: user, token: jwt(user) }
|
33
33
|
end
|
34
34
|
|
35
|
+
def update(user, params)
|
36
|
+
user.update!(registration_params(params))
|
37
|
+
return { user: user, token: jwt(user) }
|
38
|
+
end
|
39
|
+
|
35
40
|
def auth_params(email)
|
36
41
|
user = @user_class.find_by_email(email)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
|
43
|
+
if !user
|
44
|
+
return {}
|
45
|
+
end
|
46
|
+
|
47
|
+
auth_params = {:pw_salt => user.pw_salt, :pw_cost => user.pw_cost, :pw_auth => user.pw_auth}
|
48
|
+
|
49
|
+
if user.pw_func
|
50
|
+
auth_params[:pw_func] = user.pw_func
|
51
|
+
auth_params[:pw_alg] = user.pw_alg
|
52
|
+
auth_params[:pw_key_size] = user.pw_key_size
|
53
|
+
end
|
54
|
+
|
55
|
+
return auth_params
|
43
56
|
end
|
44
57
|
|
45
58
|
private
|
@@ -63,7 +76,7 @@ module StandardFile
|
|
63
76
|
end
|
64
77
|
|
65
78
|
def registration_params(params)
|
66
|
-
params.permit(:pw_func, :pw_alg, :pw_cost, :pw_key_size, :pw_nonce)
|
79
|
+
params.permit(:pw_func, :pw_alg, :pw_cost, :pw_key_size, :pw_nonce, :pw_salt, :pw_auth)
|
67
80
|
end
|
68
81
|
|
69
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standard-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Standard File
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.6.12
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Standard File User & Sync Engine
|