philote 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.sample +7 -0
- data/.gems +2 -0
- data/.gitignore +3 -0
- data/CONTRIBUTING.md +22 -0
- data/LICENSE +21 -0
- data/Makefile +40 -0
- data/lib/philote.rb +16 -0
- data/lib/philote/admin.rb +18 -0
- data/lib/philote/version.rb +3 -0
- data/philote.gemspec +14 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d557198f8bbe6a2c9e3dbdbbe09883bd10823ef0
|
4
|
+
data.tar.gz: 72e9eb3d90d5f08b330a8cfe135d2d4a6a22a05b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f8e06dc95017cf9d64340e5e893e972a378434ea4ba477019b4ff12d8bf97e4605cf3b007a992d6ca379104d6521984a79aed70ab172fbee80889f4c79bf322
|
7
|
+
data.tar.gz: cdd9c5a0156dd88c5912fa777bd0d0d0804c6191c91a8bc977d725e148df5505b8ef835b69ccbad933b35e175c3655b9d9d1df11d3b2694ed6d0db4c26f836b5
|
data/.env.sample
ADDED
data/.gems
ADDED
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
### The Soveran Contribution Guidelines.
|
2
|
+
(taken from some project at https://github.com/soveran)
|
3
|
+
|
4
|
+
This code tries to solve a particular problem with a very simple
|
5
|
+
implementation. We try to keep the code to a minimum while making
|
6
|
+
it as clear as possible. The design is very likely finished, and
|
7
|
+
if some feature is missing it is possible that it was left out on
|
8
|
+
purpose. That said, new usage patterns may arise, and when that
|
9
|
+
happens we are ready to adapt if necessary.
|
10
|
+
|
11
|
+
A good first step for contributing is to meet us on IRC and discuss
|
12
|
+
ideas. We spend a lot of time on #lesscode at freenode, always ready
|
13
|
+
to talk about code and simplicity. If connecting to IRC is not an
|
14
|
+
option, you can create an issue explaining the proposed change and
|
15
|
+
a use case. We pay a lot of attention to use cases, because our
|
16
|
+
goal is to keep the code base simple. Usually the result of a
|
17
|
+
conversation is the creation of a different tool.
|
18
|
+
|
19
|
+
Please don't start the conversation with a pull request. The code
|
20
|
+
should come at last, and even though it may help to convey an idea,
|
21
|
+
more often than not it draws the attention to a particular
|
22
|
+
implementation.
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2015 Pablo Astigarraga | pote <pote@tardis.com.uy>
|
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/Makefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
ifndef GEM_HOME
|
2
|
+
$(error GEM_HOME not set.)
|
3
|
+
endif
|
4
|
+
|
5
|
+
PACKAGES := philote
|
6
|
+
VERSION_FILE := lib/philote/version.rb
|
7
|
+
|
8
|
+
DEPS := ${GEM_HOME}/installed
|
9
|
+
VERSION := $(shell sed -ne '/.*VERSION *= *"\(.*\)".*/s//\1/p' <$(VERSION_FILE))
|
10
|
+
GEMS := $(addprefix pkg/, $(addsuffix -$(VERSION).gem, $(PACKAGES)))
|
11
|
+
|
12
|
+
export RUBYLIB := lib:test:$(RUBYLIB)
|
13
|
+
|
14
|
+
all: test $(GEMS)
|
15
|
+
|
16
|
+
console: $(DEPS)
|
17
|
+
irb -r 'philote'
|
18
|
+
|
19
|
+
test: $(DEPS)
|
20
|
+
cutest ./test/**/*_test.rb
|
21
|
+
|
22
|
+
clean:
|
23
|
+
rm pkg/*.gem
|
24
|
+
|
25
|
+
release: $(GEMS)
|
26
|
+
git tag v$(VERSION)
|
27
|
+
git push --tags
|
28
|
+
for gem in $^; do gem push $$gem; done
|
29
|
+
|
30
|
+
pkg/%-$(VERSION).gem: %.gemspec $(VERSION_FILE) | pkg
|
31
|
+
gem build $<
|
32
|
+
mv $(@F) pkg/
|
33
|
+
|
34
|
+
$(DEPS): $(GEM_HOME) .gems
|
35
|
+
cat .gems | xargs gem install && touch $(GEM_HOME)/installed
|
36
|
+
|
37
|
+
pkg $(GEM_HOME):
|
38
|
+
mkdir -p $@
|
39
|
+
|
40
|
+
.PHONY: all test release clean
|
data/lib/philote.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'redic'
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Philote
|
6
|
+
def self.redis
|
7
|
+
@redis ||= Redic.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.redis=(redis)
|
11
|
+
@redis = redis
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require_relative 'philote/version'
|
16
|
+
require_relative 'philote/admin'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Philote::Admin
|
2
|
+
def self.create_token(read: [], write: [], allowed_uses: 1)
|
3
|
+
permissions = {
|
4
|
+
read: read,
|
5
|
+
write: write,
|
6
|
+
allowed_uses: allowed_uses,
|
7
|
+
uses: 0
|
8
|
+
}
|
9
|
+
|
10
|
+
token = SecureRandom.urlsafe_base64
|
11
|
+
|
12
|
+
Philote.redis.call('SET', "philote:access_key:#{token}", permissions.to_json )
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.publish(channel, message)
|
16
|
+
Philote.redis.call('PUBLISH', channel, message )
|
17
|
+
end
|
18
|
+
end
|
data/philote.gemspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "lib/philote/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'philote'
|
5
|
+
s.version = Philote::VERSION
|
6
|
+
s.summary = 'A philote websocket server admin/client library.'
|
7
|
+
s.authors = ['pote']
|
8
|
+
s.email = ['pote@tardis.com.uy']
|
9
|
+
s.homepage = 'https://github.com/pote/philote-rb'
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
|
13
|
+
s.add_dependency "redic"
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: philote
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pote
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- pote@tardis.com.uy
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".env.sample"
|
35
|
+
- ".gems"
|
36
|
+
- ".gitignore"
|
37
|
+
- CONTRIBUTING.md
|
38
|
+
- LICENSE
|
39
|
+
- Makefile
|
40
|
+
- lib/philote.rb
|
41
|
+
- lib/philote/admin.rb
|
42
|
+
- lib/philote/version.rb
|
43
|
+
- philote.gemspec
|
44
|
+
homepage: https://github.com/pote/philote-rb
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.5.1
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: A philote websocket server admin/client library.
|
68
|
+
test_files: []
|