sqs_facade 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a61eb1e0ce4acc3c9fd9a2932721265d7c405069
4
+ data.tar.gz: 39c71d485d2be6f44449cc910bfd92a8e8d0d3f2
5
+ SHA512:
6
+ metadata.gz: 32d0a13b790fedd2ac74dbaf728d476b120405771bd70dc4ac30d9880b2244a09af98cfb7581723beb17ec10f8b940b545d3a8415880b718f2e22ad7797ba892
7
+ data.tar.gz: 4023a1fae1171a9002890622076fa7bc42361e58cc1d50861c85db9ca47c9de755933a46ccd422075059be2a47fc6591e375cc052dacf260320ce21201b28010
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ 2.3.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sqs_facade.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nephtali Rodriguez
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.
@@ -0,0 +1,91 @@
1
+ # SQS Facade
2
+
3
+ [![Build Status](https://semaphoreci.com/api/v1/nrodriguez/sqs_facade/branches/master/badge.svg)](https://semaphoreci.com/nrodriguez/sqs_facade)
4
+
5
+ This gem is geared towards making your life easier when it comes to testing using AWS SQS messages. Think Factory Girl/Faker for AWS SQS purposes. It works by generating a message skeleton and allows you to override the defaults with anything you want. Internal message are stored as JSON strings.
6
+
7
+ It works by generating objects with an internal message structure such as:
8
+
9
+ ```ruby
10
+ {
11
+ "Type"=> "Notification",
12
+ "MessageId"=> "b2632fcd-b735-57ae-84aa-6075ace8a47c",
13
+ "TopicArn"=> "arn:aws:sns:us-east-1:123456789:sample_sns",
14
+ "Subject"=> "entityupsert",
15
+ "Message"=> "{\"something\":\"hey\",\"really\":\"there\",\"cool\":\"lonely girl\"}",
16
+ "Timestamp"=> "2016-05-19T19:53:01.936Z",
17
+ "SignatureVersion"=> "1",
18
+ "Signature"=> "cf23df2207d99a74fbe169e3eba035e633b65d94==",
19
+ "SigningCertURL"=> "https://sns.us-east-1.amazonaws.com/SampleSNS.pem",
20
+ "UnsubscribeURL"=> "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789:sample_sns"
21
+ }
22
+ ```
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem 'sqs_facade'
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install sqs_facade
39
+
40
+ ## Usage
41
+
42
+ Usage is easy. Simply instantiate the class and by default new will return an object with generated dummy values.
43
+
44
+ ```ruby
45
+ SqsFacade.new
46
+
47
+ -> <SqsFacade:0x007fcea2944260 @full_message={"Type"=>"Notification", "MessageId"=>"be3b6b8b-ce76-4e6e-a800-bba8377a37a7", "TopicArn"=>"arn:aws:sns:us-east-1:31cf754f-bbd7-4c14-9c78-e81f7d115958:some-sns-topic", "Subject"=>"entityupsert", "Message"=>"{\"something\":\"hey\",\"really\":\"there\",\"cool\":\"lonely girl\"}", "Timestamp"=>"2016-05-19T19:53:01.936Z", "SignatureVersion"=>"1", "Signature"=>"c+9MIvg7+87QVQzm3xAxog==", "SigningCertURL"=>"https://sns.us-east-1.amazonaws.com/eb74a61a20c15ac1c53db21a4af05993.pem", "UnsubscribeURL"=>"https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:31cf754f-bbd7-4c14-9c78-e81f7d115958:some-sns-topic:1234"}>
48
+ ```
49
+ To access the full message as a hash use the ```full_message``` method
50
+
51
+ ```ruby
52
+ SqsFacade.new.full_message
53
+
54
+ -> {"Type"=>"Notification", "MessageId"=>"e1cbeb58-9b36-4ee4-94ff-d195f2b7fcbf", "TopicArn"=>"arn:aws:sns:us-east-1:e9f8a671-2d08-4fc4-b54b-6109c02da13a:some-sns-topic", "Subject"=>"entityupsert", "Message"=>"{\"something\":\"hey\",\"really\":\"there\",\"cool\":\"lonely girl\"}", "Timestamp"=>"2016-05-19T19:53:01.936Z", "SignatureVersion"=>"1", "Signature"=>"DBHK4iOEfwT99DLhLz2EqQ==", "SigningCertURL"=>"https://sns.us-east-1.amazonaws.com/0fae4284696382f2784a1670d2a56b81.pem", "UnsubscribeURL"=>"https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:e9f8a671-2d08-4fc4-b54b-6109c02da13a:some-sns-topic:1234"}
55
+ ```
56
+
57
+ You can override certain values by passing them in during instantiation:
58
+
59
+ ```ruby
60
+ SqsFacade.new(message: {awesome_person: "justneph", career: "software engineer/pro wrestler"})
61
+
62
+ -> <SqsFacade:0x007fcea306c5b0 @full_message={"Type"=>"Notification", "MessageId"=>"20c8433e-16c1-4aec-a0a5-d8f6e3e445e1", "TopicArn"=>"arn:aws:sns:us-east-1:e82988d7-1a3f-45e8-b718-8e7565631c35:some-sns-topic", "Subject"=>"entityupsert", "Message"=>"{\"awesome_person\":\"justneph\",\"career\":\"software engineer/pro wrestler\"}", "Timestamp"=>"2016-05-19T19:53:01.936Z", "SignatureVersion"=>"1", "Signature"=>"/MX5p5Se7ujuIYY2o/vVJQ==", "SigningCertURL"=>"https://sns.us-east-1.amazonaws.com/4c7e432f8f8c3d425fecb50d5c81409c.pem", "UnsubscribeURL"=>"https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:e82988d7-1a3f-45e8-b718-8e7565631c35:some-sns-topic:1234"}>
63
+ ```
64
+
65
+ Each parameter is accessible via a method call as well
66
+
67
+ ```ruby
68
+ irb(main):012:0> SqsFacade.new(message: {awesome_person: "justneph", career: "software engineer/pro wrestler"}).message
69
+ => "{\"awesome_person\":\"justneph\",\"career\":\"software engineer/pro wrestler\"}"
70
+
71
+ irb(main):013:0> SqsFacade.new(message: {awesome_person: "justneph", career: "software engineer/pro wrestler"}).timestamp
72
+ => "2016-05-19T19:53:01.936Z"
73
+
74
+ irb(main):014:0> SqsFacade.new(message: {awesome_person: "justneph", career: "software engineer/pro wrestler"}).topic_arn
75
+ => "arn:aws:sns:us-east-1:61458f06-5922-4fcf-a165-e52531e7f1ee:some-sns-topic"
76
+ ```
77
+
78
+ ## Development
79
+
80
+ 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.
81
+
82
+ 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).
83
+
84
+ ## Contributing
85
+
86
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sqs_facade. This project is intended to be a safe, welcoming space for collaboration. Contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
87
+
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sqs_facade"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+ module Facade
2
+ class Message
3
+ attr_accessor :full_message
4
+
5
+ def initialize(args = "")
6
+ @full_message = create_message(args)
7
+ set_accessors
8
+ end
9
+
10
+ def set_accessors
11
+ full_message.keys.each do |key|
12
+ define_singleton_method(key.underscore.to_sym) do
13
+ full_message[key]
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def message_template
21
+ topic_id = SecureRandom.uuid
22
+ {
23
+ "Type"=> "Notification",
24
+ "MessageId"=> SecureRandom.uuid,
25
+ "TopicArn"=> "arn:aws:sns:us-east-1:#{topic_id}:some-sns-topic",
26
+ "Subject"=> "entityupsert",
27
+ "Message"=> "{\"something\":\"hey\",\"really\":\"there\",\"cool\":\"lonely girl\"}",
28
+ "Timestamp"=> "2016-05-19T19:53:01.936Z",
29
+ "SignatureVersion"=> "1",
30
+ "Signature"=> SecureRandom.base64(16),
31
+ "SigningCertURL"=> "https://sns.us-east-1.amazonaws.com/#{SecureRandom.hex}.pem",
32
+ "UnsubscribeURL"=> "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:#{topic_id}:some-sns-topic:1234"
33
+ }
34
+ end
35
+
36
+ def create_message(args)
37
+ return message_template if args.empty?
38
+ skeleton = message_template
39
+ args.each{|k,v| skeleton[k.to_s.capitalize] = args[k] }
40
+ skeleton["Message"] = skeleton["Message"].to_json
41
+ skeleton
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module Facade
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ require "json"
2
+ require "active_support/inflector"
3
+ require "securerandom"
4
+ require "facade/version"
5
+ require "facade/message"
6
+
7
+ class SqsFacade < Facade::Message
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'facade/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sqs_facade"
8
+ spec.version = Facade::VERSION
9
+ spec.authors = ["Nephtali Rodriguez"]
10
+ spec.email = ["nrodriguez@xogrp.com"]
11
+
12
+ spec.summary = %q{Allows fake AWS SQS messages to be generated for testing.}
13
+ spec.description = %q{Allows fake AWS SQS messages to be generated for testing. This is intended to be used as a Faker/Factory Girl equivalent for stubbing out AWS SQS messages.}
14
+ spec.homepage = "https://github.com/xogroup/sqs_facade"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = '~> 2.3'
22
+
23
+ spec.add_dependency "activesupport"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "pry-byebug"
29
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sqs_facade
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nephtali Rodriguez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
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
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Allows fake AWS SQS messages to be generated for testing. This is intended
84
+ to be used as a Faker/Factory Girl equivalent for stubbing out AWS SQS messages.
85
+ email:
86
+ - nrodriguez@xogrp.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".ruby-version"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/facade/message.rb
102
+ - lib/facade/version.rb
103
+ - lib/sqs_facade.rb
104
+ - sqs_facade.gemspec
105
+ homepage: https://github.com/xogroup/sqs_facade
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.3'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.5.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Allows fake AWS SQS messages to be generated for testing.
129
+ test_files: []