missle 0.1.1

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: f76bd2d883eca63f1acfd94ce1f031b2e9b70447
4
+ data.tar.gz: 0fe26f13411cbe443d01dabb88581f7661b02559
5
+ SHA512:
6
+ metadata.gz: 94fa36094186f8dde57749cf741ea8426f17c5d49be62eb22a720cb3a3d1be7eda3646b51607c7464a03f26dedb73012b502d908eb178f5489a90a7b98b94e25
7
+ data.tar.gz: 83f35526314837b967dafe386c9f885e6dfa4f36ed45bb345e57cca1e8ab32565596790cc8b5116805e95ecc91a968d2b6892f7801b08e9d5f70ec0f6a7ffe3f
data/.gitignore ADDED
@@ -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
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'wepo', path: '/Users/josh/work/wepo'
4
+ # Specify your gem's dependencies in missle.gemspec
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Missle
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/missle`. 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 'missle'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install missle
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 rspec` 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]/missle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rowan"
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,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,34 @@
1
+ require 'wisper'
2
+ require 'ostruct'
3
+
4
+ module Missle
5
+ class Command
6
+ include Wisper::Publisher
7
+
8
+ def initialize(params)
9
+ @params = params
10
+ @errors = OpenStruct.new(messages: [])
11
+ end
12
+
13
+ def run
14
+ fail NotImplementedError, 'Implement #run in subclass'
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :params, :errors
20
+
21
+ def success!(*args)
22
+ broadcast(:success, *args)
23
+ end
24
+
25
+ def fail!(*args)
26
+ broadcast(:failure, *args)
27
+ end
28
+
29
+ def error(message, error = nil)
30
+ errors.messages << message
31
+ Raven.capture_exception(error) if error
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,54 @@
1
+ require 'missle/validatable'
2
+ require 'wepo/adapters/active_record'
3
+
4
+ module Missle
5
+ module Crud
6
+
7
+ def self.included(base)
8
+ base.instance_eval do
9
+ extend Uber::InheritableAttr
10
+ inheritable_attr :repo_class
11
+
12
+ self.repo_class = nil
13
+
14
+ def repo(*args)
15
+ if args[0]
16
+ self.repo_class = args[0]
17
+ else
18
+ self.repo_class
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def repo
25
+ @repo ||= self.class.repo_class.new(adapter: Wepo::Adapters::ActiveRecord.new)
26
+ end
27
+
28
+ attr_reader :adapter
29
+
30
+ def find(id)
31
+ repo.find(id)
32
+ end
33
+
34
+ def save(entity)
35
+ repo.save(entity)
36
+ end
37
+
38
+ def create(entity)
39
+ repo.save(entity)
40
+ end
41
+
42
+ def update(entity, attributes)
43
+ repo.update(entity, attributes)
44
+ end
45
+
46
+ def delete(entity)
47
+ repo.delete(entity)
48
+ end
49
+
50
+ def new_entity
51
+ entity_class.new
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,53 @@
1
+ require 'uber/inheritable_attr'
2
+ require 'reform'
3
+ require 'reform/form/active_model/validations'
4
+
5
+ module Missle
6
+ module Validatable
7
+ attr_reader :contract
8
+ def self.included(base)
9
+ base.instance_eval do
10
+ extend Uber::InheritableAttr
11
+ inheritable_attr :contract_class
12
+
13
+ self.contract_class = Reform::Form.clone
14
+ self.contract_class.class_eval do
15
+ include Reform::Form::ActiveModel::Validations
16
+ def self.name # FIXME: don't use ActiveModel::Validations in Reform, it sucks.
17
+ # for whatever reason, validations climb up the inheritance tree and require _every_ class to have a name (4.1).
18
+ "Reform::Form"
19
+ end
20
+ end
21
+
22
+ def contract(*contract_class, &block)
23
+ if block_given?
24
+ self.contract_class.class_eval(&block)
25
+ else
26
+ self.contract_class = contract_class[0]
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def validate(params, entity, contract_class=nil)
33
+ @contract = contract_for(contract_class, entity)
34
+ if @valid = validate_contract(params)
35
+ contract.sync
36
+ yield entity if block_given?
37
+ else
38
+ broadcast(:failure, { errors: @contract.errors.messages })
39
+ end
40
+ @valid
41
+ end
42
+
43
+ def validate_contract(params)
44
+ contract.validate(params)
45
+ end
46
+
47
+ # Instantiate the contract, either by using the user's contract passed into #validate
48
+ # or infer the Operation contract.
49
+ def contract_for(contract_class, *entity)
50
+ (contract_class || self.class.contract_class).new(*entity)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,3 @@
1
+ module Missle
2
+ VERSION = "0.1.1"
3
+ end
data/lib/missle.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'missle/version'
2
+ require 'missle/command'
3
+ require 'missle/crud'
4
+ require 'missle/validatable'
5
+
6
+ module Missle
7
+ # Your code goes here...
8
+ end
data/missle.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'missle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "missle"
8
+ spec.version = Missle::VERSION
9
+ spec.authors = ["Josh Deeden"]
10
+ spec.email = ["jdeeden@gmail.com"]
11
+
12
+ spec.summary = %q{Command abstraction}
13
+ spec.description = %q{Command abstraction}
14
+ spec.homepage = "http://github.com/gangster/missle"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.10'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.3.0'
32
+ spec.add_development_dependency 'pry'
33
+ spec.add_development_dependency 'wisper-rspec', '~> 0.0.2'
34
+ spec.add_dependency 'wisper', '~> 1.6.1'
35
+ spec.add_dependency 'uber', '~> 0.0.13'
36
+ spec.add_dependency 'reform', '~> 1.2.6'
37
+ spec.add_dependency 'wepo'
38
+ spec.add_dependency 'activemodel', '~> 4.2.0'
39
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: missle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Deeden
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-26 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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.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.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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: wisper-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.0.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: wisper
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: uber
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.0.13
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.0.13
111
+ - !ruby/object:Gem::Dependency
112
+ name: reform
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.2.6
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.2.6
125
+ - !ruby/object:Gem::Dependency
126
+ name: wepo
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: activemodel
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 4.2.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 4.2.0
153
+ description: Command abstraction
154
+ email:
155
+ - jdeeden@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
163
+ - Gemfile
164
+ - README.md
165
+ - Rakefile
166
+ - bin/console
167
+ - bin/setup
168
+ - lib/missle.rb
169
+ - lib/missle/command.rb
170
+ - lib/missle/crud.rb
171
+ - lib/missle/validatable.rb
172
+ - lib/missle/version.rb
173
+ - missle.gemspec
174
+ homepage: http://github.com/gangster/missle
175
+ licenses: []
176
+ metadata: {}
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 2.4.8
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: Command abstraction
197
+ test_files: []
198
+ has_rdoc: