mailaliaser 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +48 -0
- data/.rspec +2 -0
- data/.rubocop.yml +24 -0
- data/.tool-versions +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +69 -0
- data/LICENSE +21 -0
- data/PERFORMANCE.md +130 -0
- data/README.md +248 -0
- data/Rakefile +12 -0
- data/bin/mailaliaser +43 -0
- data/lib/mailaliaser/generator.rb +44 -0
- data/lib/mailaliaser/version.rb +3 -0
- data/lib/mailaliaser.rb +5 -0
- data/mailaliaser.gemspec +31 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32eb85963dee09413331b2bc0a48550a15025c01dd85c046e7b320a25cf74677
|
4
|
+
data.tar.gz: 5c6f474c8bf550973d2f0d761792f3c73e3c4c3a19dfe9a67d2a16a6fac1a5b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0e4f9a313187fc30848229e324e55623fe254d8cdf824fd121da577496de08c142025853e3881b7f035c208999a32308545b578a21d7be72701f80fc4b97af88
|
7
|
+
data.tar.gz: 3a6036e264d11de14194c178da99370f7dead5c37ae03b46e9cccec0a255f0fda6c7ed10b4b096ea6cb36c98fd1370851bac46038d51e04682efcc2ecc88a5e9
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2']
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v4
|
14
|
+
|
15
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby-version }}
|
19
|
+
bundler-cache: true
|
20
|
+
|
21
|
+
- name: Install system dependencies
|
22
|
+
run: |
|
23
|
+
sudo apt-get update
|
24
|
+
sudo apt-get install -y xsel
|
25
|
+
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rake spec
|
28
|
+
|
29
|
+
- name: Check gem can be built
|
30
|
+
run: gem build mailaliaser.gemspec
|
31
|
+
|
32
|
+
lint:
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v4
|
37
|
+
|
38
|
+
- name: Set up Ruby
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: '3.2'
|
42
|
+
bundler-cache: true
|
43
|
+
|
44
|
+
- name: Install RuboCop
|
45
|
+
run: gem install rubocop
|
46
|
+
|
47
|
+
- name: Run RuboCop
|
48
|
+
run: rubocop --format github
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
Exclude:
|
6
|
+
- 'vendor/**/*'
|
7
|
+
- 'spec/examples.txt'
|
8
|
+
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- 'spec/**/*'
|
15
|
+
- 'mailaliaser.gemspec'
|
16
|
+
|
17
|
+
Layout/LineLength:
|
18
|
+
Max: 120
|
19
|
+
|
20
|
+
Style/StringLiterals:
|
21
|
+
EnforcedStyle: single_quotes
|
22
|
+
|
23
|
+
Style/FrozenStringLiteralComment:
|
24
|
+
Enabled: false
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.0.7
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mailaliaser (0.1.0)
|
5
|
+
clipboard (~> 1.3)
|
6
|
+
slop (~> 4.9)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.3)
|
12
|
+
clipboard (1.4.1)
|
13
|
+
diff-lcs (1.6.2)
|
14
|
+
json (2.12.2)
|
15
|
+
language_server-protocol (3.17.0.5)
|
16
|
+
lint_roller (1.1.0)
|
17
|
+
parallel (1.27.0)
|
18
|
+
parser (3.3.8.0)
|
19
|
+
ast (~> 2.4.1)
|
20
|
+
racc
|
21
|
+
prism (1.4.0)
|
22
|
+
racc (1.8.1)
|
23
|
+
rainbow (3.1.1)
|
24
|
+
rake (13.3.0)
|
25
|
+
regexp_parser (2.10.0)
|
26
|
+
rspec (3.13.1)
|
27
|
+
rspec-core (~> 3.13.0)
|
28
|
+
rspec-expectations (~> 3.13.0)
|
29
|
+
rspec-mocks (~> 3.13.0)
|
30
|
+
rspec-core (3.13.4)
|
31
|
+
rspec-support (~> 3.13.0)
|
32
|
+
rspec-expectations (3.13.5)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.13.0)
|
35
|
+
rspec-mocks (3.13.5)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.13.0)
|
38
|
+
rspec-support (3.13.4)
|
39
|
+
rubocop (1.77.0)
|
40
|
+
json (~> 2.3)
|
41
|
+
language_server-protocol (~> 3.17.0.2)
|
42
|
+
lint_roller (~> 1.1.0)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 3.3.0.2)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
47
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
48
|
+
ruby-progressbar (~> 1.7)
|
49
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
50
|
+
rubocop-ast (1.45.1)
|
51
|
+
parser (>= 3.3.7.2)
|
52
|
+
prism (~> 1.4)
|
53
|
+
ruby-progressbar (1.13.0)
|
54
|
+
slop (4.10.1)
|
55
|
+
unicode-display_width (3.1.4)
|
56
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
57
|
+
unicode-emoji (4.0.4)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
x86_64-linux
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
mailaliaser!
|
64
|
+
rake (~> 13.0)
|
65
|
+
rspec (~> 3.0)
|
66
|
+
rubocop (~> 1.0)
|
67
|
+
|
68
|
+
BUNDLED WITH
|
69
|
+
2.2.33
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Fabien
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/PERFORMANCE.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# Mailaliaser Performance
|
2
|
+
|
3
|
+
This document outlines the performance characteristics and benchmarks for the Mailaliaser gem.
|
4
|
+
|
5
|
+
## Performance Summary
|
6
|
+
|
7
|
+
The Mailaliaser gem is designed for high performance email alias generation:
|
8
|
+
|
9
|
+
- **Generation Rate**: ~1M+ emails per second for large batches
|
10
|
+
- **Single Email**: <0.01ms per email
|
11
|
+
- **Memory Efficient**: ~2-3 string objects per email
|
12
|
+
- **CLI Startup**: <1 second including Ruby VM startup
|
13
|
+
- **Scalability**: Linear scaling with number of emails
|
14
|
+
|
15
|
+
## Benchmark Results
|
16
|
+
|
17
|
+
### Email Generation Performance
|
18
|
+
|
19
|
+
| Count | Time | Rate | Per Email |
|
20
|
+
|-------|------|------|-----------|
|
21
|
+
| 1 | 0.01ms | - | 0.01ms |
|
22
|
+
| 10 | 0.02ms | 500k/sec | 0.002ms |
|
23
|
+
| 100 | 0.08ms | 1.25M/sec | 0.0008ms |
|
24
|
+
| 1,000 | 0.8ms | 1.25M/sec | 0.0008ms |
|
25
|
+
| 10,000 | 8-15ms | 650k-1.2M/sec | 0.0008-0.0015ms |
|
26
|
+
|
27
|
+
### Configuration Impact
|
28
|
+
|
29
|
+
| Configuration | Time (100 emails) | Notes |
|
30
|
+
|---------------|-------------------|-------|
|
31
|
+
| Minimal (no clipboard, quiet) | 0.1ms | Fastest |
|
32
|
+
| Clipboard enabled | 2-10ms | Depends on system |
|
33
|
+
| Output enabled | 0.2ms | Minimal overhead |
|
34
|
+
| Default (clipboard + output) | 2-10ms | Production typical |
|
35
|
+
|
36
|
+
### Memory Usage
|
37
|
+
|
38
|
+
- **String Objects**: ~2-3 per email generated
|
39
|
+
- **Memory Growth**: Linear with email count
|
40
|
+
- **No Memory Leaks**: Stable memory usage across repeated operations
|
41
|
+
|
42
|
+
### CLI Performance
|
43
|
+
|
44
|
+
- **Startup Time**: <1 second (including Ruby VM)
|
45
|
+
- **Single Email**: <1 second total
|
46
|
+
- **100 Emails**: <2 seconds total
|
47
|
+
- **1000 Emails**: <5 seconds total
|
48
|
+
|
49
|
+
## Performance Characteristics
|
50
|
+
|
51
|
+
### Strengths
|
52
|
+
|
53
|
+
1. **High Throughput**: Excellent for batch generation
|
54
|
+
2. **Low Latency**: Sub-millisecond per email for library usage
|
55
|
+
3. **Memory Efficient**: Minimal object allocation
|
56
|
+
4. **Predictable**: Linear scaling characteristics
|
57
|
+
|
58
|
+
### Considerations
|
59
|
+
|
60
|
+
1. **Timestamp Precision**: Uses millisecond precision for uniqueness
|
61
|
+
2. **Clipboard Overhead**: System clipboard operations add latency
|
62
|
+
3. **Ruby VM Startup**: CLI has Ruby startup overhead (~200-500ms)
|
63
|
+
4. **Rapid Generation**: Very fast generation may have timestamp collisions
|
64
|
+
|
65
|
+
## Running Performance Tests
|
66
|
+
|
67
|
+
```bash
|
68
|
+
# Run all performance tests
|
69
|
+
bundle exec rake performance
|
70
|
+
|
71
|
+
# Run specific performance test categories
|
72
|
+
bundle exec rspec spec/performance/generator_performance_spec.rb
|
73
|
+
bundle exec rspec spec/performance/cli_performance_spec.rb
|
74
|
+
bundle exec rspec spec/performance/benchmark_spec.rb
|
75
|
+
|
76
|
+
# Alternative command
|
77
|
+
bundle exec rake bench
|
78
|
+
```
|
79
|
+
|
80
|
+
## Performance Optimization Tips
|
81
|
+
|
82
|
+
### For Library Usage
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
# Best performance: disable I/O operations
|
86
|
+
generator = Mailaliaser::Generator.new(
|
87
|
+
local_part: 'user',
|
88
|
+
domain: 'example.com',
|
89
|
+
clipboard: false, # Skip clipboard
|
90
|
+
quiet: true # Skip stdout
|
91
|
+
)
|
92
|
+
|
93
|
+
# Batch generation is most efficient
|
94
|
+
generator = Mailaliaser::Generator.new(
|
95
|
+
local_part: 'batch',
|
96
|
+
domain: 'example.com',
|
97
|
+
number: 1000, # Generate many at once
|
98
|
+
clipboard: false,
|
99
|
+
quiet: true
|
100
|
+
)
|
101
|
+
```
|
102
|
+
|
103
|
+
### For CLI Usage
|
104
|
+
|
105
|
+
```bash
|
106
|
+
# Fastest CLI usage
|
107
|
+
mailaliaser -l user -d example.com --no-clipboard -q
|
108
|
+
|
109
|
+
# Batch generation
|
110
|
+
mailaliaser -l user -d example.com -n 1000 --no-clipboard -q
|
111
|
+
```
|
112
|
+
|
113
|
+
## Test Environment
|
114
|
+
|
115
|
+
Performance tests were conducted on:
|
116
|
+
- Ruby 3.0.7
|
117
|
+
- Linux environment
|
118
|
+
- Standard development machine
|
119
|
+
- Results may vary by system specifications
|
120
|
+
|
121
|
+
## Monitoring Performance
|
122
|
+
|
123
|
+
The gem includes comprehensive performance tests that verify:
|
124
|
+
- Generation speed under various loads
|
125
|
+
- Memory usage patterns
|
126
|
+
- CLI startup and execution time
|
127
|
+
- Concurrent access behavior
|
128
|
+
- Error handling performance
|
129
|
+
|
130
|
+
These tests ensure consistent performance across releases and help identify any performance regressions.
|
data/README.md
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
# Mailaliaser
|
2
|
+
|
3
|
+
[](https://github.com/fabienpiette/mailaliaser/actions)
|
4
|
+
[](https://badge.fury.io/rb/mailaliaser)
|
5
|
+
|
6
|
+
A Ruby gem for generating unique email aliases with timestamp-based suffixes. Perfect for testing, temporary accounts, service sign-ups, or organizing email workflows with automatically generated unique variations.
|
7
|
+
|
8
|
+
## Features
|
9
|
+
|
10
|
+
- **Unique Generation**: Creates email aliases with timestamp-based suffixes to ensure uniqueness
|
11
|
+
- **Flexible Configuration**: Customize local parts, domains, and number of emails generated
|
12
|
+
- **CLI & Library**: Use from command line or integrate into your Ruby applications
|
13
|
+
- **Clipboard Integration**: Optionally copy generated emails to system clipboard (graceful fallback if unavailable)
|
14
|
+
- **Cross-Platform**: Works on Linux, macOS, and Windows
|
15
|
+
- **Multiple Output Formats**: Single email or semicolon-separated list for multiple emails
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
### System Installation
|
20
|
+
|
21
|
+
```bash
|
22
|
+
gem install mailaliaser
|
23
|
+
```
|
24
|
+
|
25
|
+
### Bundler
|
26
|
+
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'mailaliaser'
|
31
|
+
```
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
```bash
|
35
|
+
bundle install
|
36
|
+
```
|
37
|
+
|
38
|
+
### Optional: Clipboard Support
|
39
|
+
|
40
|
+
For clipboard functionality, install system dependencies:
|
41
|
+
|
42
|
+
**Ubuntu/Debian:**
|
43
|
+
```bash
|
44
|
+
sudo apt-get install xsel
|
45
|
+
# or for Wayland
|
46
|
+
sudo apt-get install wl-clipboard
|
47
|
+
```
|
48
|
+
|
49
|
+
**macOS:**
|
50
|
+
```bash
|
51
|
+
# Clipboard support included by default
|
52
|
+
```
|
53
|
+
|
54
|
+
**Windows:**
|
55
|
+
```bash
|
56
|
+
# Clipboard support included by default
|
57
|
+
```
|
58
|
+
|
59
|
+
## Usage
|
60
|
+
|
61
|
+
### Command Line Interface
|
62
|
+
|
63
|
+
#### Basic Usage
|
64
|
+
```bash
|
65
|
+
# Generate a single email alias
|
66
|
+
mailaliaser -l myname -d example.com
|
67
|
+
# Output: myname+1640995200001@example.com
|
68
|
+
|
69
|
+
# Generate multiple aliases
|
70
|
+
mailaliaser -l user -d test.org -n 5
|
71
|
+
# Output: user+1640995200001@test.org;user+1640995200002@test.org;...
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Options
|
75
|
+
|
76
|
+
| Option | Short | Description | Required | Default |
|
77
|
+
|--------|-------|-------------|----------|---------|
|
78
|
+
| `--local-part` | `-l` | Local part of email address | ✅ | - |
|
79
|
+
| `--domain` | `-d` | Domain part of email address | ✅ | - |
|
80
|
+
| `--number` | `-n` | Number of emails to generate | ❌ | 1 |
|
81
|
+
| `--clipboard` | `-c` | Copy to system clipboard | ❌ | true |
|
82
|
+
| `--quiet` | `-q` | Suppress output to stdout | ❌ | false |
|
83
|
+
| `--help` | `-h` | Show help message | ❌ | - |
|
84
|
+
| `--version` | `-v` | Show version information | ❌ | - |
|
85
|
+
|
86
|
+
#### Examples
|
87
|
+
|
88
|
+
```bash
|
89
|
+
# Generate 3 aliases for testing
|
90
|
+
mailaliaser -l testuser -d myapp.com -n 3
|
91
|
+
|
92
|
+
# Generate without clipboard (useful in CI/scripts)
|
93
|
+
mailaliaser -l api -d service.com --no-clipboard
|
94
|
+
|
95
|
+
# Generate quietly (only copy to clipboard)
|
96
|
+
mailaliaser -l silent -d example.org -q
|
97
|
+
|
98
|
+
# Generate for multiple services
|
99
|
+
mailaliaser -l newsletter -d news.com -n 10
|
100
|
+
```
|
101
|
+
|
102
|
+
### Ruby Library
|
103
|
+
|
104
|
+
#### Basic Usage
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
require 'mailaliaser'
|
108
|
+
|
109
|
+
# Generate a single email
|
110
|
+
generator = Mailaliaser::Generator.new(
|
111
|
+
local_part: 'user',
|
112
|
+
domain: 'example.com'
|
113
|
+
)
|
114
|
+
|
115
|
+
email = generator.generate
|
116
|
+
puts email
|
117
|
+
# => "user+1640995200001@example.com"
|
118
|
+
```
|
119
|
+
|
120
|
+
#### Advanced Configuration
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
# Generate multiple emails with custom options
|
124
|
+
generator = Mailaliaser::Generator.new(
|
125
|
+
local_part: 'service',
|
126
|
+
domain: 'myapp.com',
|
127
|
+
number: 5,
|
128
|
+
clipboard: false, # Don't copy to clipboard
|
129
|
+
quiet: true # Don't output to stdout
|
130
|
+
)
|
131
|
+
|
132
|
+
emails = generator.generate
|
133
|
+
# Returns array of 5 unique email addresses
|
134
|
+
```
|
135
|
+
|
136
|
+
#### Integration Examples
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
# Testing scenarios
|
140
|
+
RSpec.describe 'User Registration' do
|
141
|
+
let(:test_email) do
|
142
|
+
Mailaliaser::Generator.new(
|
143
|
+
local_part: 'test',
|
144
|
+
domain: 'example.com',
|
145
|
+
clipboard: false,
|
146
|
+
quiet: true
|
147
|
+
).generate
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'creates user with unique email' do
|
151
|
+
user = User.create(email: test_email)
|
152
|
+
expect(user).to be_valid
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Service integrations
|
157
|
+
class NewsletterSignup
|
158
|
+
def self.generate_test_email
|
159
|
+
Mailaliaser::Generator.new(
|
160
|
+
local_part: 'newsletter-test',
|
161
|
+
domain: ENV['TEST_DOMAIN'],
|
162
|
+
quiet: true
|
163
|
+
).generate
|
164
|
+
end
|
165
|
+
end
|
166
|
+
```
|
167
|
+
|
168
|
+
## Use Cases
|
169
|
+
|
170
|
+
- **Software Testing**: Generate unique email addresses for test scenarios
|
171
|
+
- **Service Sign-ups**: Create temporary emails for service registrations
|
172
|
+
- **Email Organization**: Generate tagged emails for different purposes
|
173
|
+
- **Load Testing**: Create multiple unique email addresses for performance testing
|
174
|
+
- **Development**: Generate test data with guaranteed unique email addresses
|
175
|
+
- **CI/CD Pipelines**: Automated testing with unique email generation
|
176
|
+
|
177
|
+
## Output Format
|
178
|
+
|
179
|
+
- **Single email**: Returns the email address directly
|
180
|
+
- **Multiple emails**: Returns semicolon-separated list for easy parsing
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
# Single email
|
184
|
+
"user+1640995200001@example.com"
|
185
|
+
|
186
|
+
# Multiple emails
|
187
|
+
"user+1640995200001@example.com;user+1640995200002@example.com;user+1640995200003@example.com"
|
188
|
+
```
|
189
|
+
|
190
|
+
## Requirements
|
191
|
+
|
192
|
+
- Ruby >= 2.7
|
193
|
+
- Optional: System clipboard utilities (xsel, wl-clipboard, or built-in on macOS/Windows)
|
194
|
+
|
195
|
+
## Development
|
196
|
+
|
197
|
+
After checking out the repo, run:
|
198
|
+
|
199
|
+
```bash
|
200
|
+
# Install dependencies
|
201
|
+
bundle install
|
202
|
+
|
203
|
+
# Run tests
|
204
|
+
bundle exec rake spec
|
205
|
+
|
206
|
+
# Run linting
|
207
|
+
bundle exec rake rubocop
|
208
|
+
|
209
|
+
# Run all checks (linting + tests)
|
210
|
+
bundle exec rake
|
211
|
+
```
|
212
|
+
|
213
|
+
## Contributing
|
214
|
+
|
215
|
+
1. Fork the repository
|
216
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
217
|
+
3. Make your changes
|
218
|
+
4. Add tests for new functionality
|
219
|
+
5. Ensure all tests pass (`bundle exec rake`)
|
220
|
+
6. Commit your changes (`git commit -am 'Add amazing feature'`)
|
221
|
+
7. Push to the branch (`git push origin feature/amazing-feature`)
|
222
|
+
8. Open a Pull Request
|
223
|
+
|
224
|
+
### Code Style
|
225
|
+
|
226
|
+
This project uses RuboCop for code style enforcement. Please ensure your code follows the established conventions by running:
|
227
|
+
|
228
|
+
```bash
|
229
|
+
bundle exec rake rubocop
|
230
|
+
```
|
231
|
+
|
232
|
+
## Versioning
|
233
|
+
|
234
|
+
This gem follows [Semantic Versioning](https://semver.org/). For available versions, see the [releases page](https://github.com/fabienpiette/mailaliaser/releases).
|
235
|
+
|
236
|
+
## License
|
237
|
+
|
238
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
239
|
+
|
240
|
+
## Support
|
241
|
+
|
242
|
+
- **Issues**: [GitHub Issues](https://github.com/fabienpiette/mailaliaser/issues)
|
243
|
+
- **Documentation**: This README and inline code documentation
|
244
|
+
- **Changelog**: [CHANGELOG.md](CHANGELOG.md)
|
245
|
+
|
246
|
+
---
|
247
|
+
|
248
|
+
Made with ❤️ for the Ruby community
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
RSpec::Core::RakeTask.new(:performance) do |t|
|
7
|
+
t.rspec_opts = '--tag performance'
|
8
|
+
end
|
9
|
+
RuboCop::RakeTask.new
|
10
|
+
|
11
|
+
task default: %i[rubocop spec]
|
12
|
+
task :bench => :performance
|
data/bin/mailaliaser
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'mailaliaser'
|
5
|
+
require 'slop'
|
6
|
+
|
7
|
+
opts = Slop.parse do |o|
|
8
|
+
o.banner = 'Usage: mailaliaser [options] ...'
|
9
|
+
o.separator 'Generates a unique random email: local-part@domain'
|
10
|
+
o.separator ''
|
11
|
+
o.separator 'Options:'
|
12
|
+
|
13
|
+
o.string '-l', '--local-part', 'the local part of the email address', required: true
|
14
|
+
o.string '-d', '--domain', 'the domain part of the email address', required: true
|
15
|
+
o.bool '-c', '--clipboard', 'copies email address to system clipboard', default: true
|
16
|
+
o.bool '-q', '--quiet', 'suppress output (quiet mode)', default: false
|
17
|
+
o.integer '-n', '--number', 'number of emails to generate', default: 1
|
18
|
+
o.on '-v', '--version', 'print the version' do
|
19
|
+
puts "Mailaliaser version: #{Mailaliaser::VERSION}"
|
20
|
+
puts "Slop version: #{Slop::VERSION}"
|
21
|
+
begin
|
22
|
+
require 'clipboard'
|
23
|
+
puts "Clipboard version: #{Clipboard::VERSION}"
|
24
|
+
rescue LoadError
|
25
|
+
puts 'Clipboard: not installed'
|
26
|
+
end
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
o.on '-h', '--help', 'give this help list' do
|
30
|
+
puts o
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
generator = Mailaliaser::Generator.new(
|
36
|
+
local_part: opts[:local_part],
|
37
|
+
domain: opts[:domain],
|
38
|
+
number: opts[:number],
|
39
|
+
clipboard: opts[:clipboard],
|
40
|
+
quiet: opts[:quiet]
|
41
|
+
)
|
42
|
+
|
43
|
+
generator.generate
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Mailaliaser
|
2
|
+
class Generator
|
3
|
+
def initialize(local_part:, domain:, number: 1, clipboard: true, quiet: false)
|
4
|
+
@local_part = local_part
|
5
|
+
@domain = domain
|
6
|
+
@number = number
|
7
|
+
@clipboard = clipboard
|
8
|
+
@quiet = quiet
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
base_timestamp = (Time.now.to_f * 1000).to_i # Millisecond precision
|
13
|
+
|
14
|
+
emails = (1..@number).map do |i|
|
15
|
+
"#{@local_part}+#{base_timestamp}#{i}@#{@domain}"
|
16
|
+
end
|
17
|
+
|
18
|
+
result = format_result(emails)
|
19
|
+
|
20
|
+
puts result unless @quiet
|
21
|
+
|
22
|
+
copy_to_clipboard(result) if @clipboard
|
23
|
+
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def format_result(emails)
|
30
|
+
return emails.first if emails.size == 1
|
31
|
+
|
32
|
+
emails.join(';')
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy_to_clipboard(text)
|
36
|
+
require 'clipboard'
|
37
|
+
Clipboard.copy(text)
|
38
|
+
rescue LoadError
|
39
|
+
warn 'clipboard gem not available - install with: gem install clipboard'
|
40
|
+
rescue StandardError => e
|
41
|
+
warn "clipboard functionality not available: #{e.message}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/mailaliaser.rb
ADDED
data/mailaliaser.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'lib/mailaliaser/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'mailaliaser'
|
5
|
+
spec.version = Mailaliaser::VERSION
|
6
|
+
spec.authors = ['Fabien Piette']
|
7
|
+
spec.email = ['fab.piette@gmail.com']
|
8
|
+
|
9
|
+
spec.summary = 'Generate unique email aliases with timestamps'
|
10
|
+
spec.description = 'A Ruby gem for generating unique email addresses with customizable local parts, domains, and ' \
|
11
|
+
'timestamp suffixes'
|
12
|
+
spec.homepage = 'https://github.com/fabienpiette/mailaliaser'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
18
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
19
|
+
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'bin'
|
24
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_dependency 'clipboard', '~> 1.3'
|
28
|
+
spec.add_dependency 'slop', '~> 4.9'
|
29
|
+
|
30
|
+
spec.required_ruby_version = '>= 2.7.0'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailaliaser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabien Piette
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: clipboard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.9'
|
41
|
+
description: A Ruby gem for generating unique email addresses with customizable local
|
42
|
+
parts, domains, and timestamp suffixes
|
43
|
+
email:
|
44
|
+
- fab.piette@gmail.com
|
45
|
+
executables:
|
46
|
+
- mailaliaser
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".github/workflows/ci.yml"
|
51
|
+
- ".rspec"
|
52
|
+
- ".rubocop.yml"
|
53
|
+
- ".tool-versions"
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE
|
57
|
+
- PERFORMANCE.md
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/mailaliaser
|
61
|
+
- lib/mailaliaser.rb
|
62
|
+
- lib/mailaliaser/generator.rb
|
63
|
+
- lib/mailaliaser/version.rb
|
64
|
+
- mailaliaser.gemspec
|
65
|
+
homepage: https://github.com/fabienpiette/mailaliaser
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata:
|
69
|
+
allowed_push_host: https://rubygems.org
|
70
|
+
homepage_uri: https://github.com/fabienpiette/mailaliaser
|
71
|
+
source_code_uri: https://github.com/fabienpiette/mailaliaser
|
72
|
+
rubygems_mfa_required: 'true'
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 2.7.0
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.2.33
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Generate unique email aliases with timestamps
|
92
|
+
test_files: []
|