lighthouse-core 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/lighthouse/client.rb +34 -0
- data/lib/lighthouse/core.rb +87 -0
- data/lib/lighthouse/core/version.rb +5 -0
- data/lighthouse-core.gemspec +35 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df70253718d8964dc610049942952fdcb9434166
|
4
|
+
data.tar.gz: a0778020ea1034b5b6a4261a3fa1ace5df0863a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e7836b2acf0d973bd376ac281d4ff8c521aec71f2cd4883c5240a3421034a7ab11a6fd636ab79175706d598183e4334d24b6c4409582192649b74e2b40dda7e9
|
7
|
+
data.tar.gz: 03a45dc6f3bec45cdfcf2f6576985d00a8f97a2ddd3dfca0e22369c3745929bdcc9db48b112ec50f10a3dc48afbcd3f38067fe5c3e16277da6a79046160e153c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Tanapat Sainak
|
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/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Lighthouse::Core
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lighthouse/core`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'lighthouse-core'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install lighthouse-core
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lighthouse-core.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lighthouse/core"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'restclient'
|
2
|
+
module Lighthouse
|
3
|
+
module Client
|
4
|
+
class << self
|
5
|
+
DATA_API_PATH = "/api/v1/data"
|
6
|
+
|
7
|
+
def config=(config)
|
8
|
+
@config = config
|
9
|
+
@host = config["host"].to_s.blank? ? config[:host].to_s : config["host"].to_s
|
10
|
+
@port = config["port"].to_s.blank? ? config[:port].to_s : config["port"].to_s
|
11
|
+
@access_token = config["access_token"].to_s.blank? ? config[:access_token].to_s : config["access_token"].to_s
|
12
|
+
@url = @port.nil? ? @host+DATA_API_PATH : @host+":"+@port+DATA_API_PATH
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
@config
|
17
|
+
end
|
18
|
+
|
19
|
+
def uri
|
20
|
+
@url
|
21
|
+
end
|
22
|
+
|
23
|
+
def send_message(data)
|
24
|
+
validate_config
|
25
|
+
RestClient.post(@url, data, {auth_token: @access_token})
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate_config
|
29
|
+
raise "Lighthouse config is not set." if @url == ":" || @url.nil?
|
30
|
+
raise "Access token is undefined." unless @access_token
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "lighthouse/core/version"
|
2
|
+
require "lighthouse/client"
|
3
|
+
|
4
|
+
class LighthouseException < Exception
|
5
|
+
end
|
6
|
+
|
7
|
+
module Lighthouse
|
8
|
+
STATUS_MAPPER = {
|
9
|
+
"g" => "good",
|
10
|
+
"p" => "good",
|
11
|
+
"pass" => "good",
|
12
|
+
"passed" => "good",
|
13
|
+
"true" => "good",
|
14
|
+
"good" => "good",
|
15
|
+
"t" => "good",
|
16
|
+
"1" => "good",
|
17
|
+
"nil" => "medium",
|
18
|
+
"medium" => "medium",
|
19
|
+
"med" => "medium",
|
20
|
+
"normal" => "medium",
|
21
|
+
"middle" => "medium",
|
22
|
+
"fail" => "bad",
|
23
|
+
"failed" => "bad",
|
24
|
+
"failure" => "bad",
|
25
|
+
"bad" => "bad",
|
26
|
+
"false" => "bad",
|
27
|
+
"0" => "bad",
|
28
|
+
"b" => "bad",
|
29
|
+
"f" => "bad"
|
30
|
+
}
|
31
|
+
|
32
|
+
class << self
|
33
|
+
def project(name="unknown")
|
34
|
+
raise "project shouldn't be inside project block." if @project != nil
|
35
|
+
@project=name
|
36
|
+
if block_given?
|
37
|
+
yield
|
38
|
+
end
|
39
|
+
rescue => e
|
40
|
+
raise "This is custom raising error\nChange this at Lighthouse::Core\n"+e.message
|
41
|
+
ensure
|
42
|
+
@node=nil
|
43
|
+
@topic=nil
|
44
|
+
@group=nil
|
45
|
+
@project=nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def topic(name="unknown", options={})
|
49
|
+
raise "topic shouldn't be inside topic block." if @topic != nil
|
50
|
+
@topic=name
|
51
|
+
if block_given?
|
52
|
+
yield
|
53
|
+
end
|
54
|
+
ensure
|
55
|
+
@topic=nil
|
56
|
+
end
|
57
|
+
|
58
|
+
def node(name="unknown", options={})
|
59
|
+
raise "node shouldn't be inside node block." if @node != nil
|
60
|
+
@node=name
|
61
|
+
@group=options[:group]
|
62
|
+
@contact=options[:contact]
|
63
|
+
@variables=options[:variables]
|
64
|
+
if block_given?
|
65
|
+
yield
|
66
|
+
end
|
67
|
+
rescue LighthouseException
|
68
|
+
rescue => e
|
69
|
+
report(:fail, e.message, true)
|
70
|
+
ensure
|
71
|
+
@node=nil
|
72
|
+
@group=nil
|
73
|
+
@contact=nil
|
74
|
+
@variables=nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def report(status, message=nil, noraise=false)
|
78
|
+
status = map_status(status)
|
79
|
+
Client.send_message({:status => status, :message => message, :project => @project, :topic => @topic, :group => @group, :node => @node, :contact => @contact, :variables => @variables})
|
80
|
+
raise LighthouseException.new("done") unless noraise
|
81
|
+
end
|
82
|
+
|
83
|
+
def map_status(status)
|
84
|
+
STATUS_MAPPER[(status.to_s rescue nil)]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lighthouse/core/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lighthouse-core"
|
8
|
+
spec.version = Lighthouse::Core::VERSION
|
9
|
+
spec.authors = ["Tanapat Sainak"]
|
10
|
+
spec.email = ["tanapat@computerlogy.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Core for Lighthouse project.}
|
13
|
+
spec.description = %q{Core for Lighthouse project..}
|
14
|
+
spec.homepage = "https://www.computerlogy.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
|
34
|
+
spec.add_runtime_dependency "rest-client", "~> 1.8", ">= 1.8.0"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lighthouse-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tanapat Sainak
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.8.0
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '1.8'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.8.0
|
75
|
+
description: Core for Lighthouse project..
|
76
|
+
email:
|
77
|
+
- tanapat@computerlogy.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- ".rspec"
|
84
|
+
- ".travis.yml"
|
85
|
+
- Gemfile
|
86
|
+
- LICENSE.txt
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- bin/console
|
90
|
+
- bin/setup
|
91
|
+
- lib/lighthouse/client.rb
|
92
|
+
- lib/lighthouse/core.rb
|
93
|
+
- lib/lighthouse/core/version.rb
|
94
|
+
- lighthouse-core.gemspec
|
95
|
+
homepage: https://www.computerlogy.com
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.5.1
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Core for Lighthouse project.
|
119
|
+
test_files: []
|