adam_signals 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4292649941f95e37f44cd91518c6d6d3bc57d04
4
+ data.tar.gz: 11ef21b4b0b7695f4f919c8f5ab2690ea29db5a8
5
+ SHA512:
6
+ metadata.gz: ce499d494862a08bf1e1361a481562a426450f73161f4a8e928a4c6f5e11bb3078a8d84fcabf99cfa5d6a5a59a2bd074e14247580d686dc26b7f2b12fba85425
7
+ data.tar.gz: df786fe591f5e164583512c41f8d57965e1891f6cdd297530dd7fae28e205705c481b533bae2774954a22147d4516dffbc63cb500d8af7ba3c677fce82ce8ff7
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/ruby
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --tty
3
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+ - ruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # [develop](https://github.com/mojolingo/adam_signals)
2
+
3
+ # [1.0.0](https://github.com/mojolingo/adam_signals/compare/c05b045f041eb8e0364e8348e9e6fc868462cf40...v1.0.0) - [2013-11-12](https://rubygems.org/gems/adam_signals/versions/1.0.0)
4
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec/" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2013 Mojo Lingo LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ [![Gem Version](https://badge.fury.io/rb/adam_signals.png)](https://rubygems.org/gems/adam_signals)
2
+ [![Build Status](https://secure.travis-ci.org/mojolingo/adam_signals.png?branch=develop)](http://travis-ci.org/mojolingo/adam_signals)
3
+ [![Dependency Status](https://gemnasium.com/mojolingo/adam_signals.png?travis)](https://gemnasium.com/mojolingo/adam_signals)
4
+ [![Code Climate](https://codeclimate.com/github/mojolingo/adam_signals.png)](https://codeclimate.com/github/mojolingo/adam_signals)
5
+ [![Coverage Status](https://coveralls.io/repos/mojolingo/adam_signals/badge.png?branch=develop)](https://coveralls.io/r/mojolingo/adam_signals)
6
+
7
+ # AdamSignals
8
+
9
+ Common message formats exchanged between Adam Snark Rabbit organs. You can use this gem to help you implement components which interface with Adam.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'adam_signals'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install adam_signals
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Links:
30
+ * [Source](https://github.com/mojolingo/adam_signals)
31
+ * [Documentation](http://rdoc.info/gems/adam_signals/frames)
32
+ * [Bug Tracker](https://github.com/mojolingo/adam_signals/issues)
33
+ * [CI](https://travis-ci.org/#!/mojolingo/adam_signals)
34
+
35
+ ## Note on Patches/Pull Requests
36
+
37
+ * Fork the project.
38
+ * Make your feature addition or bug fix.
39
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
40
+ * Commit, do not mess with rakefile, version, or history.
41
+ * If you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull
42
+ * Send me a pull request. Bonus points for topic branches.
43
+
44
+ Copyright (c) 2013 Mojo Lingo LLC. MIT licence (see LICENSE for details).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+
5
+ require 'bundler'
6
+ Bundler.setup
7
+
8
+ task :default => :spec
9
+
10
+ require 'rspec/core/rake_task'
11
+ RSpec::Core::RakeTask.new(:spec) do |spec|
12
+ spec.pattern = 'spec/**/*_spec.rb'
13
+ spec.rspec_opts = '--color'
14
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/adam_signals/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "adam_signals"
6
+ gem.authors = ["Ben Langfeld"]
7
+ gem.email = ["ben@langfeld.me"]
8
+ gem.description = %q{Common message formats exchanged between Adam Snark Rabbit organs}
9
+ gem.summary = %q{Adam Snark Rabbit shared message formats}
10
+ gem.homepage = ""
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+
16
+ gem.require_paths = ["lib"]
17
+ gem.version = AdamSignals::VERSION
18
+
19
+ gem.add_runtime_dependency 'virtus', '~> 1.0'
20
+
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'rspec'
23
+ gem.add_development_dependency 'guard'
24
+ gem.add_development_dependency 'guard-rspec'
25
+ gem.add_development_dependency 'coveralls'
26
+ end
@@ -0,0 +1,6 @@
1
+ require "adam_signals/version"
2
+ require "adam_signals/message"
3
+ require "adam_signals/response"
4
+
5
+ module AdamSignals
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+ require 'virtus'
3
+
4
+ class AdamSignals::Message
5
+ include Virtus.value_object
6
+
7
+ values do
8
+ attribute :source_type, Symbol
9
+ attribute :source_address, String
10
+ attribute :auth_address, String
11
+ attribute :body, String
12
+ attribute :user, Hash
13
+ end
14
+
15
+ def self.from_json(json)
16
+ new JSON.parse(json)
17
+ end
18
+
19
+ def to_json
20
+ JSON.generate attributes
21
+ end
22
+
23
+ def to_s
24
+ "#<#{self.class.name} #{attributes}>"
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+ require 'virtus'
3
+
4
+ class AdamSignals::Response
5
+ include Virtus.value_object
6
+
7
+ values do
8
+ attribute :target_type, Symbol
9
+ attribute :target_address, String
10
+ attribute :body, String
11
+ end
12
+
13
+ def self.from_json(json)
14
+ new JSON.parse(json)
15
+ end
16
+
17
+ def to_json
18
+ JSON.generate attributes
19
+ end
20
+
21
+ def to_s
22
+ "#<#{self.class.name} #{attributes}>"
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module AdamSignals
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdamSignals::Message do
4
+ let(:source_type) { :xmpp }
5
+ let(:source_address) { 'foo@bar.com' }
6
+ let(:auth_address) { 'doo@dah.com' }
7
+ let(:body) { 'Hello there' }
8
+ let(:user) { { 'profile' => {'name' => 'Ben Langfeld'} } }
9
+
10
+ subject { described_class.new source_type: source_type, source_address: source_address, auth_address: auth_address, body: body, user: user }
11
+
12
+ its(:source_type) { should == source_type }
13
+ its(:source_address) { should == source_address }
14
+ its(:auth_address) { should == auth_address }
15
+ its(:body) { should == body }
16
+ its(:user) { should == { 'profile' => {'name' => 'Ben Langfeld'} } }
17
+
18
+ it "should be able to encode to and decode from JSON" do
19
+ subject.should eql(described_class.from_json(subject.to_json))
20
+ end
21
+
22
+ describe "equality" do
23
+ context "with no attributes set" do
24
+ it "should be equal" do
25
+ described_class.new.should eql(described_class.new)
26
+ end
27
+ end
28
+
29
+ context "with attributes set the same" do
30
+ it "should be equal" do
31
+ described_class.new(source_type: :xmpp).should eql(described_class.new(source_type: :xmpp))
32
+ end
33
+ end
34
+
35
+ context "with attributes set differently" do
36
+ it "should be equal" do
37
+ described_class.new(source_type: :email).should_not eql(described_class.new(source_type: :xmpp))
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdamSignals::Response do
4
+ let(:target_type) { :xmpp }
5
+ let(:target_address) { 'foo@bar.com' }
6
+ let(:body) { 'Hello there' }
7
+
8
+ subject { described_class.new target_type: target_type, target_address: target_address, body: body }
9
+
10
+ its(:target_type) { should == target_type }
11
+ its(:target_address) { should == target_address }
12
+ its(:body) { should == body }
13
+
14
+ it "should be able to encode to and decode from JSON" do
15
+ subject.should eql(described_class.from_json(subject.to_json))
16
+ end
17
+
18
+ describe "equality" do
19
+ context "with no attributes set" do
20
+ it "should be equal" do
21
+ described_class.new.should eql(described_class.new)
22
+ end
23
+ end
24
+
25
+ context "with attributes set the same" do
26
+ it "should be equal" do
27
+ described_class.new(target_type: :xmpp).should eql(described_class.new(target_type: :xmpp))
28
+ end
29
+ end
30
+
31
+ context "with attributes set differently" do
32
+ it "should be equal" do
33
+ described_class.new(target_type: :email).should_not eql(described_class.new(target_type: :xmpp))
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,12 @@
1
+ require 'adam_signals'
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+ config.mock_with :rspec
10
+ config.filter_run :focus => true
11
+ config.run_all_when_everything_filtered = true
12
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adam_signals
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Langfeld
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
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: guard-rspec
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
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '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'
97
+ description: Common message formats exchanged between Adam Snark Rabbit organs
98
+ email:
99
+ - ben@langfeld.me
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - .travis.yml
107
+ - CHANGELOG.md
108
+ - Gemfile
109
+ - Guardfile
110
+ - LICENSE
111
+ - README.md
112
+ - Rakefile
113
+ - adam_signals.gemspec
114
+ - lib/adam_signals.rb
115
+ - lib/adam_signals/message.rb
116
+ - lib/adam_signals/response.rb
117
+ - lib/adam_signals/version.rb
118
+ - spec/adam_signals/message_spec.rb
119
+ - spec/adam_signals/response_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: ''
122
+ licenses: []
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.0.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Adam Snark Rabbit shared message formats
144
+ test_files:
145
+ - spec/adam_signals/message_spec.rb
146
+ - spec/adam_signals/response_spec.rb
147
+ - spec/spec_helper.rb