aga-beacon 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +78 -0
- data/lib/beacon/autoloader.rb +41 -0
- data/lib/beacon/base.rb +11 -0
- data/lib/beacon/resources/service.rb +45 -0
- data/lib/beacon/version.rb +5 -0
- data/lib/beacon.rb +30 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7250e253abc7a17ddbff2aa55de7a9cddec795d355bcb4217679edfad36f2483
|
4
|
+
data.tar.gz: 07d06bf5c64527bb86726f1f38967429d26c384d562e774ef0884e0d24f29be0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fda5177aad164dffd34a6e6122b052afb1ebf746eca083fa409dfce12a9e6318c18c0dfb5c0287087eef956575dcf94998778f2f0b97229fc51f3483b3574987
|
7
|
+
data.tar.gz: 8b87b8d0e24147461ad9e85485c57944514558f387dfec4482c6cab902b4cf1c008b29be59c074ac440d55453070435664747e4c600aefcccf8836a473e77042
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Aga-beacon
|
2
|
+
|
3
|
+
Aga-message is a Ruby gem that provides a convenient way to format messages to be sent to customers. It offers a set of utilities and methods to compose and customize messages before sending them to clients through various communication channels.
|
4
|
+
|
5
|
+
|
6
|
+
## Features
|
7
|
+
|
8
|
+
- Format personalized messages with dynamic content for individual customers.
|
9
|
+
- Customize message layout, styling, and formatting.
|
10
|
+
- Localization and internationalization support for multilingual messaging.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Install the gem and add to the application's Gemfile by executing:
|
15
|
+
|
16
|
+
$ bundle add aga-beacon
|
17
|
+
|
18
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
19
|
+
|
20
|
+
$ gem install aga-beacon
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
To use Aga-beacon in your application, require the gem and start making requests. Here's a basic example:
|
25
|
+
|
26
|
+
```
|
27
|
+
ENVIRONMENT=development irb
|
28
|
+
|
29
|
+
require 'beacon'
|
30
|
+
|
31
|
+
Beacon.configuration
|
32
|
+
|
33
|
+
b = Beacon::Service.new('new')
|
34
|
+
b.log('Hello') # Output: { status: 200 }
|
35
|
+
b.read('.log/development_new.log') # Output: 'Hello'
|
36
|
+
b.clear # Output: 0
|
37
|
+
|
38
|
+
b.log('Hello')
|
39
|
+
b.size('.log/development_new.log') # Output: 56
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Contributions to Aga-beacon are welcome! If you encounter any issues or have suggestions for improvements, please submit an issue on the repository. Pull requests are also encouraged.
|
46
|
+
|
47
|
+
|
48
|
+
## Private License
|
49
|
+
|
50
|
+
Version 0.0.2, 01/06/2023
|
51
|
+
|
52
|
+
By obtaining a copy of this software and associated documentation files (the "Software"), you agree that the Software is proprietary to AIGreenAnt and is protected under intellectual property laws. This license grants you limited rights to use the Software solely for internal purposes within your organization.
|
53
|
+
|
54
|
+
1. License Grant
|
55
|
+
|
56
|
+
1.1 You are granted a non-exclusive, non-transferable license to use the Software for internal purposes only.
|
57
|
+
|
58
|
+
1.2 You may not distribute, sublicense, sell, or transfer the Software to any third party without prior written permission from AIGreenAnt.
|
59
|
+
|
60
|
+
2. Intellectual Property
|
61
|
+
|
62
|
+
2.1 The Software and any associated intellectual property rights, including but not limited to copyrights, patents, trademarks, trade secrets, and any other proprietary rights, are and shall remain the exclusive property of AIGreenAnt.
|
63
|
+
|
64
|
+
2.2 You may not remove, alter, or obscure any proprietary notices or labels on the Software.
|
65
|
+
|
66
|
+
3. Limitation of Liability
|
67
|
+
|
68
|
+
3.1 In no event shall AIGreenAnt be liable for any direct, indirect, incidental, special, or consequential damages arising out of the use or inability to use the Software, even if AIGreenAnt has been advised of the possibility of such damages.
|
69
|
+
|
70
|
+
4. Termination
|
71
|
+
|
72
|
+
4.1 This license is effective until terminated. AIGreenAnt may terminate this license at any time if you fail to comply with the terms and conditions of this agreement.
|
73
|
+
|
74
|
+
4.2 Upon termination, you must immediately cease all use of the Software and destroy all copies in your possession or control.
|
75
|
+
|
76
|
+
5. Governing Law
|
77
|
+
|
78
|
+
5.1 This license shall be governed by and construed in accordance with the laws of Italy, without regard to its conflict of laws principles.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'zeitwerk'
|
4
|
+
|
5
|
+
module Beacon
|
6
|
+
class Autoloader
|
7
|
+
class Inflector < ::Zeitwerk::Inflector
|
8
|
+
INFLECTIONS_MAP = {
|
9
|
+
version: 'VERSION'
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
def camelize(basename, _abspath)
|
13
|
+
INFLECTIONS_MAP[basename.to_sym] || super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
LIB_PATH = ::File.dirname(__dir__).freeze
|
19
|
+
|
20
|
+
def setup!
|
21
|
+
loader = ::Zeitwerk::Loader.new
|
22
|
+
loader.tag = 'beacon'
|
23
|
+
loader.inflector = Inflector.new
|
24
|
+
loader.push_dir(LIB_PATH)
|
25
|
+
loader.collapse(::File.join(LIB_PATH, 'beacon', 'resources'))
|
26
|
+
|
27
|
+
ignored_paths.each { |path| loader.ignore(path) }
|
28
|
+
|
29
|
+
loader.setup
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def ignored_paths
|
35
|
+
[
|
36
|
+
::File.join(LIB_PATH, 'beacon', 'patches')
|
37
|
+
].freeze
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/beacon/base.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Beacon
|
6
|
+
class Service
|
7
|
+
def initialize(service)
|
8
|
+
@environment = ENV['ENVIRONMENT'] || 'production'
|
9
|
+
@service = service.to_s
|
10
|
+
|
11
|
+
FileUtils.mkdir_p('./log/') unless Dir.exist?('./log/')
|
12
|
+
@log_file = "./log/#{@environment}_#{@service}.log"
|
13
|
+
end
|
14
|
+
|
15
|
+
def log(text)
|
16
|
+
FileUtils.touch(@log_file) unless File.exist?(@log_file)
|
17
|
+
|
18
|
+
File.open(@log_file, 'a') do |file|
|
19
|
+
file.puts("#{Time.now} [#{@environment.capitalize}] - [#{@service.capitalize}] - #{text.capitalize}")
|
20
|
+
end
|
21
|
+
|
22
|
+
response
|
23
|
+
end
|
24
|
+
|
25
|
+
def clear
|
26
|
+
File.truncate(@log_file, 0) if File.exist?(@log_file)
|
27
|
+
|
28
|
+
response
|
29
|
+
end
|
30
|
+
|
31
|
+
def read(name)
|
32
|
+
file_content = ''
|
33
|
+
File.open(name, 'r') { |file| file_content = file.read } if File.exist?(name)
|
34
|
+
file_content
|
35
|
+
end
|
36
|
+
|
37
|
+
def size(name)
|
38
|
+
File.exist?(name) ? File.size(name) : 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def response
|
42
|
+
{ status: 200}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/beacon.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tzinfo'
|
4
|
+
require_relative './beacon/autoloader'
|
5
|
+
|
6
|
+
module Beacon
|
7
|
+
NAME = 'Beacon Ruby'
|
8
|
+
|
9
|
+
@mutex = ::Mutex.new
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def app_info=(value)
|
13
|
+
::Beacon::Base.app_info = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def configuration
|
17
|
+
TZInfo::Timezone.get('Europe/Rome')
|
18
|
+
end
|
19
|
+
|
20
|
+
def ping
|
21
|
+
{ status: 200 }
|
22
|
+
end
|
23
|
+
|
24
|
+
def version
|
25
|
+
VERSION
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
::Beacon::Autoloader.setup!
|
metadata
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aga-beacon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefano Baldazzi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zeitwerk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bump
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: digest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.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.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '13.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '13.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.16'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.16'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: nokogiri
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.15'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.15'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.14'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.14'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: tzinfo
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.0.6
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.0.6
|
167
|
+
description: Beacon Ruby is a lightweight gem for write, read & take size of log files.
|
168
|
+
email:
|
169
|
+
- stefanobaldazzi40@gmail.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- README.md
|
175
|
+
- lib/beacon.rb
|
176
|
+
- lib/beacon/autoloader.rb
|
177
|
+
- lib/beacon/base.rb
|
178
|
+
- lib/beacon/resources/service.rb
|
179
|
+
- lib/beacon/version.rb
|
180
|
+
homepage: https://github.com/Baldaz02/aga-beacon-ruby
|
181
|
+
licenses:
|
182
|
+
- MIT
|
183
|
+
metadata: {}
|
184
|
+
post_install_message:
|
185
|
+
rdoc_options: []
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '2.7'
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
requirements: []
|
199
|
+
rubygems_version: 3.3.24
|
200
|
+
signing_key:
|
201
|
+
specification_version: 4
|
202
|
+
summary: aga-beacon0.0.0
|
203
|
+
test_files: []
|