syro-container 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: 255d006ee6bcaf13b6e60a2bab115db9f0413fe7
4
+ data.tar.gz: b4db4848619dac87b1fa501ddc5c366b8bce6952
5
+ SHA512:
6
+ metadata.gz: d4db5165cb7a3a7887b556edac8e928e086efe4fb4faaf68a5d5b319fb99de9b84f4e22c1de40c37e912ab9169e07857dbf6b8befcb576f5737becc06c71abb9
7
+ data.tar.gz: 76ec3b0455bade8a7930b7bfe803d2379646ee77faa8336e8e9064fadfc89cf6dacbcc17b9bb89b6f4a77a0844cf8ce2bd64556de8d7e13c8bde5c816fe49f18
@@ -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,17 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - rbx-2
7
+ - jruby
8
+ - ruby-head
9
+ - jruby-head
10
+ before_install: gem install bundler -v 1.10.6
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
14
+ - rvm: jruby-head
15
+ addons:
16
+ code_climate:
17
+ repo_token: 12d55ad91467c072ab726972664b9b55ea74379059de60d04c79190ab9e54b1e
@@ -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,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in syro-container.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Seba Gamboa
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,64 @@
1
+ # Syro::Container
2
+
3
+ [![Gem](https://img.shields.io/gem/v/syro-container.svg)](https://rubygems.org/gems/syro-container)
4
+ [![Build Status](https://travis-ci.org/sagmor/syro-container.svg)](https://travis-ci.org/sagmor/syro-container)
5
+ [![Test Coverage](https://codeclimate.com/github/sagmor/syro-container/badges/coverage.svg)](https://codeclimate.com/github/sagmor/syro-container/coverage)
6
+ [![Code Climate](https://codeclimate.com/github/sagmor/syro-container/badges/gpa.svg)](https://codeclimate.com/github/sagmor/syro-container)
7
+ [![Inline docs](http://inch-ci.org/github/sagmor/mruby-cli.svg?branch=master)](http://inch-ci.org/github/sagmor/mruby-cli)
8
+
9
+ A Syro Deck extension that allows it to register and resolve routes from a container.
10
+
11
+ ## Usage
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'syro-container'
17
+ ```
18
+
19
+ Include it in your `Syro::Deck`
20
+
21
+ ```ruby
22
+ require 'syro/container'
23
+
24
+ class MyApp < Syro::Deck
25
+ include Syro::Container
26
+ end
27
+ ```
28
+
29
+ Register your sub-apps in your container:
30
+
31
+ ```ruby
32
+ subapp = Syro.new {
33
+ # Your app code here
34
+ on('innerpath') {
35
+ get {
36
+ res.write "Hello, world!"
37
+ }
38
+ }
39
+ }
40
+
41
+ MyApp.register('path', subapp)
42
+ ```
43
+
44
+ Access your subapp from the main app:
45
+
46
+ ```ruby
47
+ app = Syro.new(MyApp)
48
+
49
+ env = {
50
+ "REQUEST_METHOD" => "GET",
51
+ "PATH_INFO" => "/subapp/innerpath"
52
+ }
53
+ p app.call(env)
54
+ ```
55
+
56
+ ## Contributing
57
+
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sagmor/syro-container. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
59
+
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
64
+
@@ -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 "syro/container"
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
+ require 'syro'
2
+ require 'dry/container'
3
+
4
+ require "syro/container/version"
5
+
6
+ class Syro
7
+ module Container
8
+ def self.included(deck)
9
+ deck.extend ClassMethods
10
+ end
11
+
12
+ def initialize(before)
13
+ code = Proc.new do
14
+ instance_eval(&before) if before
15
+ resolve!
16
+ end
17
+
18
+ super(code)
19
+ end
20
+
21
+ def resolve!
22
+ return if @resolved
23
+ @resolved = true
24
+
25
+ segment = self.path.curr.split('/')[1]
26
+ app = self.class.container.resolve(segment)
27
+ self.path.consume(segment)
28
+ run(app)
29
+ rescue Dry::Container::Error
30
+ end
31
+
32
+ module ClassMethods
33
+
34
+ def container
35
+ @container ||= Dry::Container.new
36
+ end
37
+
38
+ def register(*args)
39
+ container.register(*args)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ class Syro
2
+ module Container
3
+ VERSION = "0.1.0"
4
+ end
5
+ 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 'syro/container/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "syro-container"
8
+ spec.version = Syro::Container::VERSION
9
+ spec.authors = ["Seba Gamboa"]
10
+ spec.email = ["me@sagmor.com"]
11
+
12
+ spec.summary = %q{A Syro extension to resolve paths from a container.}
13
+ spec.description = %q{A Syro extension to resolve paths from a container.}
14
+ spec.homepage = "https://github.com/sagmor/syro-container"
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
+
22
+ spec.add_runtime_dependency "syro"
23
+ spec.add_runtime_dependency "dry-container"
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 "rack-test"
29
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: syro-container
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seba Gamboa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: syro
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: dry-container
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.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: '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: rack-test
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: A Syro extension to resolve paths from a container.
98
+ email:
99
+ - me@sagmor.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/syro/container.rb
115
+ - lib/syro/container/deck.rb
116
+ - lib/syro/container/version.rb
117
+ - syro-container.gemspec
118
+ homepage: https://github.com/sagmor/syro-container
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A Syro extension to resolve paths from a container.
142
+ test_files: []