arisaid 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89cb41031b8b5b42435bf5382e22ec237f4e6f0c
4
- data.tar.gz: e96f70eb47bd4b9c2ec22b3a95eb41d50649c192
3
+ metadata.gz: 3186d61dfb948e53ef40c82c50a2752bea6e9d5b
4
+ data.tar.gz: dca7327a42f698e108b4d5414f9ff9b6f8de9f3e
5
5
  SHA512:
6
- metadata.gz: 81c428b0fbc14d7bce6a129b53f1aa0c6deb7937fec0b0d65306091a8e1154fa79eb2dfa3349aca23a68042c5f6997ced8cc127ed868fad8deade0b7b5adac63
7
- data.tar.gz: 2cce61a0a56475b78e2e210f788649ff5bd2376ec6547d8e572d025a064175e6c30aa6400f38499fc2643c4f5f7026a1f736a4be8d1383cbf1375da3069b2c6c
6
+ metadata.gz: 8760b4bbda977080ad3eb161a20bd77adb8821b6089261eb78201b17ac8674fa4af5344aaeb8a88413cbf63c41c6a948ef69b5208c6e1ad75077f9906df0df35
7
+ data.tar.gz: e6f7c4ba4e6eb3c58b1d7132baafdb8ebbf0a77e478838d13652d86efbb09ca710b4184da28efeca34004cd56aef1b215a424e3f41078658de4c6e386c88e540
data/README.md CHANGED
@@ -32,7 +32,7 @@ $ arisaid save users
32
32
  Development
33
33
  -----------
34
34
 
35
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
36
 
37
37
  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).
38
38
 
@@ -45,6 +45,44 @@ module Arisaid
45
45
 
46
46
  remote! if enabled
47
47
 
48
+ if Arisaid.read_only?
49
+ local.each do |src|
50
+ dst = remote.find_by(name: src['name'])
51
+
52
+ if dst.nil?
53
+ puts "create usergroup: #{src['name']}"
54
+ puts " + description: #{src['description']}"
55
+ src['users'].flatten.each do |user|
56
+ puts " + user #{user}"
57
+ end
58
+
59
+ next
60
+ end
61
+
62
+ next if same?(src, dst)
63
+
64
+ if changed?(src, dst)
65
+ puts "update usergroup: #{src['name']}"
66
+ end
67
+
68
+ if users_changed?(src, dst)
69
+ add = src['users'].flatten.sort - dst['users'].flatten.sort
70
+ delete = dst['users'].flatten.sort - src['users'].flatten.sort
71
+ add.each do |u|
72
+ puts " + user #{u}"
73
+ end
74
+ delete.each do |u|
75
+ puts " - user #{u}"
76
+ end
77
+ end
78
+ end
79
+
80
+ remote.each do |dst|
81
+ src = local.find_by(name: dst['name'])
82
+ puts "disable #{dst['name']}" if src.nil?
83
+ end
84
+ end
85
+
48
86
  local.each do |src|
49
87
  dst = remote.find_by(name: src['name'])
50
88
  case
@@ -65,8 +103,23 @@ module Arisaid
65
103
  nil
66
104
  end
67
105
 
106
+ def same?(src, dst)
107
+ src['name'] == dst['name'] &&
108
+ src['description'] == dst['description'] &&
109
+ src['handle'] == dst['handle'] &&
110
+ src['users'].flatten.sort == dst['users'].flatten.sort
111
+ end
112
+
68
113
  def changed?(src, dst)
69
- !same?(src, dst) && src['users'] == dst['users']
114
+ !same?(src, dst) && (users_changed?(src, dst) || description_changed?(src, dst))
115
+ end
116
+
117
+ def users_changed?(src, dst)
118
+ src['users'].flatten.sort != dst['users'].flatten.sort
119
+ end
120
+
121
+ def description_changed?(src, dst)
122
+ src['description'] != dst['description']
70
123
  end
71
124
 
72
125
  def create(src)
@@ -1,3 +1,3 @@
1
1
  module Arisaid
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arisaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - linyows
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: breacan
@@ -117,6 +117,7 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
+ - ".travis.yml"
120
121
  - Gemfile
121
122
  - README.md
122
123
  - Rakefile
@@ -160,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
161
  version: '0'
161
162
  requirements: []
162
163
  rubyforge_project:
163
- rubygems_version: 2.5.1
164
+ rubygems_version: 2.6.14
164
165
  signing_key:
165
166
  specification_version: 4
166
167
  summary: Slack configuration.