data_guru 0.4.0 → 1.0.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 +4 -4
- data/README.md +45 -37
- data/lib/data_guru/collection.rb +3 -2
- data/lib/data_guru/validation.rb +2 -1
- data/lib/data_guru/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3385e9759c76cf598810c880efcb0011dc62331e
|
4
|
+
data.tar.gz: 86cc6fe4ee3c388e111156b00e5d54f8e1674603
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1320b19b6d3f119730dcd173b31660754da2585490b758c7b9269c76a1c8d70300283f280b7e5b476188a361cc48efcf0d2331175467d745074fab99ac1cc363
|
7
|
+
data.tar.gz: 1d7a38793ecbe88a33eba71d70d954b7fed3b90bfe3d72ac5d9be0f51b796a26f1e83bfc3b57efe5f64a0abc43c41003dfa9530efbe13115210eed068f4cc134
|
data/README.md
CHANGED
@@ -35,21 +35,21 @@ DataGuru.configure do |config|
|
|
35
35
|
end
|
36
36
|
```
|
37
37
|
|
38
|
-
|
38
|
+
**Required** configuration values:
|
39
39
|
|
40
|
-
`api_url` -
|
40
|
+
`api_url` - url of server managing the Permissions repo
|
41
41
|
|
42
|
-
`access_token` -
|
42
|
+
`access_token` - token for authorizing access to the server
|
43
43
|
|
44
|
-
##
|
44
|
+
## Use
|
45
45
|
|
46
46
|
If you use default config files (see Permissions section below) you can simply do:
|
47
47
|
|
48
48
|
```ruby
|
49
|
-
data = DataGuru::Client.new
|
49
|
+
data = DataGuru::Client.new(api_url: <URL>, access_token: <TOKEN>)
|
50
50
|
|
51
51
|
# get collections
|
52
|
-
data.
|
52
|
+
data.members.all
|
53
53
|
data.projects.all
|
54
54
|
data.github_teams.all
|
55
55
|
data.google_groups.all
|
@@ -58,20 +58,20 @@ data.toggl_teams.all
|
|
58
58
|
|
59
59
|
# find in collections by attribute
|
60
60
|
data.projects.find{ |project| project.display_name == 'Some project' }
|
61
|
-
data.
|
61
|
+
data.members.find{ |member| member.github == 'example' }
|
62
62
|
|
63
|
-
# filter
|
64
|
-
data.
|
65
|
-
data.
|
63
|
+
# filter collections by attributes
|
64
|
+
data.members.select{ |member| member.external }
|
65
|
+
data.members.select{ |member| member.public_key.nil? }.count
|
66
66
|
|
67
|
-
# select key names of all github teams
|
68
|
-
|
69
|
-
data.github_teams.select{ |team| team.members.include?(
|
67
|
+
# select key names of all github teams a member belongs to
|
68
|
+
member = data.members.first
|
69
|
+
data.github_teams.select{ |team| team.members.include?(member.id) }.map(&:id)
|
70
70
|
```
|
71
71
|
|
72
|
-
The collections
|
72
|
+
The collections `include Enumerable` module so that you can filter models by attributes easily (`data.members.select{ |member| member.some_method }`).
|
73
73
|
|
74
|
-
You can refresh repo and storage at any time
|
74
|
+
You can refresh repo and storage at any time:
|
75
75
|
|
76
76
|
```ruby
|
77
77
|
data = DataGuru::Client.new
|
@@ -82,54 +82,62 @@ On a single model you can do:
|
|
82
82
|
|
83
83
|
```ruby
|
84
84
|
data = DataGuru::Client.new
|
85
|
-
|
85
|
+
member = data.members.all.first
|
86
86
|
|
87
|
-
# to get list of
|
88
|
-
|
87
|
+
# to get list of member attributes
|
88
|
+
member.attributes
|
89
89
|
|
90
90
|
# to get list of permitted and required attributes (see Permisions section below)
|
91
|
-
|
92
|
-
|
91
|
+
member.permitted_attributes
|
92
|
+
member.required_attributes
|
93
93
|
|
94
|
-
# check if
|
95
|
-
|
96
|
-
|
94
|
+
# check if member has all required attributes set
|
95
|
+
member.valid?
|
96
|
+
member.missing_attributes
|
97
97
|
```
|
98
98
|
|
99
|
-
Each model has a set of getter methods (permitted_attributes) so you can
|
100
|
-
Each model also has `id` method which returns the name of the file, for example for the
|
99
|
+
Each model has a set of getter methods (`permitted_attributes`), so for example you can do `member.github` to get just the github membername.
|
100
|
+
Each model also has `id` method which returns the name of the file the member is stored in, for example it will return `john.doe` for the member in the file `john.doe.yml`.
|
101
101
|
|
102
102
|
You can check whether configuration (in your rails app) and model configuration (in your permissions repo) is valid by running `DataGuru::Client.new.errors`.
|
103
103
|
|
104
104
|
### Permissions
|
105
105
|
|
106
|
-
A sample permissions repo contains a `config
|
106
|
+
A sample permissions repo contains a `config/` directory with files like `member.yml`, `project.yml`, `github_team.yml`. In these files you specify attributes of each model with information about whether they are required, what is the default value, and what is the datatype.
|
107
107
|
|
108
|
-
```
|
108
|
+
```yaml
|
109
109
|
---
|
110
|
-
name:
|
111
|
-
required: true
|
112
|
-
default_value:
|
113
|
-
value_type: string
|
114
110
|
emails:
|
111
|
+
default_value: []
|
115
112
|
required: true
|
116
|
-
default_value:
|
117
113
|
value_type: array
|
118
114
|
external:
|
119
|
-
required: false
|
120
115
|
default_value: false
|
116
|
+
required: true
|
121
117
|
value_type: boolean
|
118
|
+
github:
|
119
|
+
default_value:
|
120
|
+
required: true
|
121
|
+
value_type: string
|
122
|
+
name:
|
123
|
+
default_value:
|
124
|
+
required: true
|
125
|
+
value_type: string
|
126
|
+
public_key:
|
127
|
+
default_value:
|
128
|
+
required: true
|
129
|
+
value_type: string
|
122
130
|
```
|
123
131
|
|
124
|
-
The methods `permitted_attributes` and `required_attributes`
|
132
|
+
The methods `permitted_attributes` and `required_attributes` return array of specified attributes.
|
125
133
|
|
126
|
-
All
|
134
|
+
All files should stay in appropriate directories, e.g. store members in `members/` directory.
|
127
135
|
|
128
|
-
For more
|
136
|
+
For more details see the [sample permissions repo](https://github.com/netguru/access-permissions-sample).
|
129
137
|
|
130
138
|
## Development
|
131
139
|
|
132
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
|
140
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
133
141
|
|
134
142
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
135
143
|
|
data/lib/data_guru/collection.rb
CHANGED
@@ -32,11 +32,12 @@ module DataGuru
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def collection_resource_url(collection_type)
|
35
|
-
"#{DataGuru.config.api_url}/#{collection_type}
|
35
|
+
"#{DataGuru.config.api_url}/collections/#{collection_type}" \
|
36
|
+
"?token=#{DataGuru.config.access_token}"
|
36
37
|
end
|
37
38
|
|
38
39
|
def config_resource_url
|
39
|
-
"#{DataGuru.config.api_url}/config?token=#{DataGuru.config.access_token}"
|
40
|
+
"#{DataGuru.config.api_url}/collections/config?token=#{DataGuru.config.access_token}"
|
40
41
|
end
|
41
42
|
|
42
43
|
def config_data
|
data/lib/data_guru/validation.rb
CHANGED
data/lib/data_guru/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_guru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Nowak
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|