lws 0.1.2.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +59 -0
- data/Rakefile +1 -1
- data/lib/lws/auth.rb +6 -2
- data/lib/lws/maps.rb +6 -2
- data/lib/lws/presence.rb +6 -2
- data/lib/lws/version.rb +1 -1
- data/lib/lws.rb +9 -0
- data/test/test_generic.rb +6 -5
- data/test/test_helper.rb +1 -3
- metadata +17 -16
data/README.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
= LeftClick Web Services
|
2
|
+
|
3
|
+
LWS is a library for Ruby provides access to the LeftClick web
|
4
|
+
services/applications using a model-based structure that abstracts from API
|
5
|
+
calls using the available REST interfaces.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
In your Gemfile, add:
|
10
|
+
|
11
|
+
gem "lws"
|
12
|
+
|
13
|
+
or install the +ruby-lws+ package.
|
14
|
+
|
15
|
+
|
16
|
+
== Usage
|
17
|
+
|
18
|
+
First, you have to initialize the library. For example, with Rails, you
|
19
|
+
would create a new +config/initializers/lws.rb+ file with these lines:
|
20
|
+
|
21
|
+
# config/initializers/lws.rb
|
22
|
+
LWS.setup do |config|
|
23
|
+
config.api_token = "…" # Get it from someplace
|
24
|
+
end
|
25
|
+
|
26
|
+
After that, due to the fact that LWS is based on Her, you can access the
|
27
|
+
objects in the LeftClick Web Services similary to many ActiveRecord-like
|
28
|
+
ORM's:
|
29
|
+
|
30
|
+
map = Maps::Map.all.first
|
31
|
+
markers = map.markers
|
32
|
+
|
33
|
+
company = Company.find(6)
|
34
|
+
account = Auth::Account.create(name: "Foo Bar",
|
35
|
+
company: company)
|
36
|
+
|
37
|
+
loc = Presence::Location.where(name: "Test")
|
38
|
+
loc.destroy
|
39
|
+
|
40
|
+
== Configuration
|
41
|
+
|
42
|
+
The following example uses a much more elaborate setup:
|
43
|
+
|
44
|
+
LWS.setup do |config|
|
45
|
+
config.api_token = "…"
|
46
|
+
config.caching_object = MyRedisCache.new
|
47
|
+
config.environment = :development
|
48
|
+
config.endponts = { maps: "https://maps.leftclick.eu" }
|
49
|
+
config.http_debug = true
|
50
|
+
config.json_debug = true
|
51
|
+
end
|
52
|
+
|
53
|
+
In this setup, a caching object is used that follows the
|
54
|
+
+FaradayMiddleWare::Caching+ API. It uses all development API endpoints,
|
55
|
+
except for maps, which is overriden to use the production endpoint. Also
|
56
|
+
HTTP request and JSON data debug logging is enabled.
|
57
|
+
|
58
|
+
The +LC_LWS_ENV+ is supported to override the LWS environment.
|
59
|
+
Allowed values are "production" (default) and "development".
|
data/Rakefile
CHANGED
data/lib/lws/auth.rb
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
module LWS::Auth
|
3
3
|
|
4
4
|
# The API endpoint for the auth app
|
5
|
-
|
5
|
+
unless defined? ENDPOINT
|
6
|
+
ENDPOINT = { production: "https://auth.leftclick.eu/" ,
|
7
|
+
development: "https://auth-dev.leftclick.eu/" }
|
8
|
+
end
|
6
9
|
|
7
10
|
# @!visibility private
|
8
11
|
def self.api
|
9
|
-
LWS.setup_api(LWS.config.endpoints[:auth] ||
|
12
|
+
LWS.setup_api(LWS.config.endpoints[:auth] ||
|
13
|
+
ENDPOINT[LWS.config.environment])
|
10
14
|
end
|
11
15
|
|
12
16
|
### Generic classes
|
data/lib/lws/maps.rb
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
module LWS::Maps
|
3
3
|
|
4
4
|
# The API endpoint for the map app
|
5
|
-
|
5
|
+
unless defined? ENDPOINT
|
6
|
+
ENDPOINT = { production: "https://maps.leftclick.eu/",
|
7
|
+
development: "https://maps-dev.leftclick.eu/" }
|
8
|
+
end
|
6
9
|
|
7
10
|
#@!visibility private
|
8
11
|
def self.api
|
9
|
-
LWS.setup_api(LWS.config.endpoints[:maps] ||
|
12
|
+
LWS.setup_api(LWS.config.endpoints[:maps] ||
|
13
|
+
ENDPOINT[LWS.config.environment])
|
10
14
|
end
|
11
15
|
|
12
16
|
### Generic classes
|
data/lib/lws/presence.rb
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
module LWS::Presence
|
3
3
|
|
4
4
|
# The API endpoint for the presence app
|
5
|
-
|
5
|
+
unless defined? ENDPOINT
|
6
|
+
ENDPOINT = { production: "https://presence.leftclick.eu/",
|
7
|
+
development: "https://presence-dev.leftclick.eu/" }
|
8
|
+
end
|
6
9
|
|
7
10
|
#@!visibility private
|
8
11
|
def self.api
|
9
|
-
LWS.setup_api(LWS.config.endpoints[:presence] ||
|
12
|
+
LWS.setup_api(LWS.config.endpoints[:presence] ||
|
13
|
+
ENDPOINT[LWS.config.environment])
|
10
14
|
end
|
11
15
|
|
12
16
|
### Generic classes
|
data/lib/lws/version.rb
CHANGED
data/lib/lws.rb
CHANGED
@@ -84,6 +84,10 @@ module LWS
|
|
84
84
|
# overrides
|
85
85
|
property :endpoints, default: {}
|
86
86
|
|
87
|
+
#@!attribte environment
|
88
|
+
# @return [Symbol] the (default) API environment
|
89
|
+
property :environment, default: :production
|
90
|
+
|
87
91
|
#@!attribute http_debug
|
88
92
|
# @return [Boolean] whether to show HTTP debug messages
|
89
93
|
property :http_debug, default: false
|
@@ -113,6 +117,11 @@ module LWS
|
|
113
117
|
|
114
118
|
raise "API token is required" if config.api_token.blank?
|
115
119
|
|
120
|
+
# Override the environment if needed
|
121
|
+
if ENV["LC_LWS_ENV"].present?
|
122
|
+
@@config.environment = ENV["LC_LWS_ENV"].to_sym
|
123
|
+
end
|
124
|
+
|
116
125
|
load_app_modules
|
117
126
|
|
118
127
|
return self
|
data/test/test_generic.rb
CHANGED
@@ -9,11 +9,12 @@ class TestGenericConfiguration < MiniTest::Unit::TestCase
|
|
9
9
|
@configuration = Configuration.all.first
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
# FIXME: renable this test once some configurations are available again
|
13
|
+
#def test_valid_configuration
|
14
|
+
# refute_nil(@configuration)
|
15
|
+
# assert_instance_of(Configuration, @configuration)
|
16
|
+
# refute_nil(@configuration.id)
|
17
|
+
#end
|
17
18
|
|
18
19
|
end
|
19
20
|
|
data/test/test_helper.rb
CHANGED
@@ -9,7 +9,5 @@ LWS.setup do |config|
|
|
9
9
|
config.http_debug = true
|
10
10
|
config.json_debug = true
|
11
11
|
end
|
12
|
-
config.
|
13
|
-
maps: "https://maps-dev.leftclick.eu",
|
14
|
-
presence: "https://presence-dev.leftclick.eu" }
|
12
|
+
config.environment = :development
|
15
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday_middleware
|
16
|
-
requirement: &
|
16
|
+
requirement: &10903360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: '1.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *10903360
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: hashie
|
30
|
-
requirement: &
|
30
|
+
requirement: &10902460 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *10902460
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: her
|
41
|
-
requirement: &
|
41
|
+
requirement: &10901740 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: 0.8.1
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *10901740
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: hashie
|
52
|
-
requirement: &
|
52
|
+
requirement: &10901140 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: '0'
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *10901140
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: her
|
63
|
-
requirement: &
|
63
|
+
requirement: &10900440 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: 0.8.1
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *10900440
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: minitest
|
74
|
-
requirement: &
|
74
|
+
requirement: &10899860 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: '0'
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *10899860
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
|
-
requirement: &
|
85
|
+
requirement: &10915620 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
version: 0.9.2
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *10915620
|
94
94
|
description: ! "This library for Ruby provides access to the LeftClick\n web services/applications
|
95
95
|
using a model-based structure that abstracts from API calls\n using the available
|
96
96
|
REST interfaces."
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
105
|
- Gemfile
|
106
|
+
- README.rdoc
|
106
107
|
- Rakefile
|
107
108
|
- bin/lwsconsole
|
108
109
|
- lib/lws.rb
|