marauders_map 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9518b408ca768cb31dc3a14fed316c67f75d35c4651ecd34b39425cbf98fcfe0
4
+ data.tar.gz: c24ca9236a607d11284f792f1bdf84ee550aeda61e14f0350f87eceb6c62e4cc
5
+ SHA512:
6
+ metadata.gz: c5c38b1fc868a5cc3998f24330d05c95a589681b7ebec371987111e4961285f4a8a13f5a72e68625fec5c3fa4a388f278e4d71ee1162cc5492691eafd4dcacf9
7
+ data.tar.gz: f6c986f7da6e45d0bdff78b4c7b887c28771e71ab614067e064dff082b38ef80aac5774f2bb1ac991773d0a80bd6731ce086b6fc6b8ea11c833c1b317f08bf2b
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.0
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in marauders_map.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,136 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ marauders_map (0.1.0)
5
+ activesupport (>= 5.1, <= 6.0.0.rc1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.3)
11
+ actionpack (= 5.2.3)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.3)
15
+ actionpack (= 5.2.3)
16
+ actionview (= 5.2.3)
17
+ activejob (= 5.2.3)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.3)
21
+ actionview (= 5.2.3)
22
+ activesupport (= 5.2.3)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.3)
28
+ activesupport (= 5.2.3)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.3)
34
+ activesupport (= 5.2.3)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.3)
37
+ activesupport (= 5.2.3)
38
+ activerecord (5.2.3)
39
+ activemodel (= 5.2.3)
40
+ activesupport (= 5.2.3)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.3)
43
+ actionpack (= 5.2.3)
44
+ activerecord (= 5.2.3)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.3)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ arel (9.0.0)
52
+ builder (3.2.3)
53
+ coderay (1.1.2)
54
+ concurrent-ruby (1.1.5)
55
+ crass (1.0.4)
56
+ erubi (1.8.0)
57
+ globalid (0.4.2)
58
+ activesupport (>= 4.2.0)
59
+ i18n (1.6.0)
60
+ concurrent-ruby (~> 1.0)
61
+ loofah (2.2.3)
62
+ crass (~> 1.0.2)
63
+ nokogiri (>= 1.5.9)
64
+ mail (2.7.1)
65
+ mini_mime (>= 0.1.1)
66
+ marcel (0.3.3)
67
+ mimemagic (~> 0.3.2)
68
+ method_source (0.9.2)
69
+ mimemagic (0.3.3)
70
+ mini_mime (1.0.1)
71
+ mini_portile2 (2.4.0)
72
+ minitest (5.11.3)
73
+ nio4r (2.3.1)
74
+ nokogiri (1.10.3)
75
+ mini_portile2 (~> 2.4.0)
76
+ pry (0.12.2)
77
+ coderay (~> 1.1.0)
78
+ method_source (~> 0.9.0)
79
+ rack (2.0.7)
80
+ rack-test (1.1.0)
81
+ rack (>= 1.0, < 3)
82
+ rails (5.2.3)
83
+ actioncable (= 5.2.3)
84
+ actionmailer (= 5.2.3)
85
+ actionpack (= 5.2.3)
86
+ actionview (= 5.2.3)
87
+ activejob (= 5.2.3)
88
+ activemodel (= 5.2.3)
89
+ activerecord (= 5.2.3)
90
+ activestorage (= 5.2.3)
91
+ activesupport (= 5.2.3)
92
+ bundler (>= 1.3.0)
93
+ railties (= 5.2.3)
94
+ sprockets-rails (>= 2.0.0)
95
+ rails-dom-testing (2.0.3)
96
+ activesupport (>= 4.2.0)
97
+ nokogiri (>= 1.6)
98
+ rails-html-sanitizer (1.0.4)
99
+ loofah (~> 2.2, >= 2.2.2)
100
+ railties (5.2.3)
101
+ actionpack (= 5.2.3)
102
+ activesupport (= 5.2.3)
103
+ method_source
104
+ rake (>= 0.8.7)
105
+ thor (>= 0.19.0, < 2.0)
106
+ rake (10.5.0)
107
+ sprockets (3.7.2)
108
+ concurrent-ruby (~> 1.0)
109
+ rack (> 1, < 3)
110
+ sprockets-rails (3.2.1)
111
+ actionpack (>= 4.0)
112
+ activesupport (>= 4.0)
113
+ sprockets (>= 3.0.0)
114
+ sqlite3 (1.4.1)
115
+ thor (0.20.3)
116
+ thread_safe (0.3.6)
117
+ tzinfo (1.2.5)
118
+ thread_safe (~> 0.1)
119
+ websocket-driver (0.7.0)
120
+ websocket-extensions (>= 0.1.0)
121
+ websocket-extensions (0.1.3)
122
+
123
+ PLATFORMS
124
+ ruby
125
+
126
+ DEPENDENCIES
127
+ bundler (~> 2.0)
128
+ marauders_map!
129
+ minitest (~> 5.0)
130
+ pry (~> 0.12.2)
131
+ rails (~> 5.2)
132
+ rake (~> 10.0)
133
+ sqlite3 (~> 1.0)
134
+
135
+ BUNDLED WITH
136
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Lee Machin
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.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Marauder's Map
2
+
3
+ Colocate your Rails routes with your domain specific code.
4
+
5
+
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'marauders_map'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install marauders_map
22
+
23
+ ## Usage
24
+
25
+ 1. Create an initializer, `config/initializers/marauders_map.rb`, with the following code:
26
+
27
+ ``` ruby
28
+ MaraudersMap.pledge("I solemnly swear that I am up to no good.")
29
+ ```
30
+
31
+ Failure to recite this pledge, _verbatim_, will render Marauder's Map inoperable. Note that it is *not* necessary to declare 'Mischief managed' upon application shutdown.
32
+
33
+
34
+ 2. Update `config/routes.rb` to include this:
35
+
36
+ ``` ruby
37
+ MaraudersMap.reveal_routes!
38
+ ```
39
+
40
+ This will throw an exception if the pledge has not been recited, and your routes will not be revealed.
41
+
42
+ 3. Define your routes in the same place you manage your domains. For example, in `app/domains/sorting_hat/routes.rb`:
43
+
44
+ ``` ruby
45
+ MaraudersMap.draw(:sorting_hat) do
46
+ resource :house do
47
+ get :gryffindor, on: :member
48
+ get :hufflepuff, on: :member
49
+ get :slytherin, on: :member
50
+ get :ravenclaw, on: :meber
51
+ end
52
+ end
53
+ ```
54
+
55
+ The routing DSL is exactly the same as the one you use in your traditional routes files.
56
+
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ 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).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://code.wellware.dev/leemachin/marauders_map.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'marauders_map'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'marauders_map/version'
4
+ require 'active_support/core_ext/module/attribute_accessors_per_thread'
5
+
6
+ module MaraudersMap
7
+ extend self
8
+
9
+ UnrecitedPledgeError = Class.new(StandardError)
10
+
11
+ PLEDGE = 'I solemnly swear that I am up to no good.'
12
+
13
+ def pledge(statement)
14
+ self.statement = statement
15
+ end
16
+
17
+ def reveal_routes!
18
+ raise UnrecitedPledgeError, <<~MSG unless pledge_recited?
19
+ In order to use Marauder's Map you must recite the pledge. Do so by adding the following to your code.
20
+
21
+ MaraudersMap.pledge("#{PLEDGE}")
22
+ MSG
23
+
24
+ routes.each do |(_name, route)|
25
+ app.routes.append(&route)
26
+ end
27
+
28
+ app.routes.finalize!
29
+ end
30
+
31
+ def draw(name, &routes)
32
+ append_route(name, &routes)
33
+ end
34
+
35
+ private
36
+
37
+ thread_mattr_accessor :statement, :routes
38
+
39
+ def app
40
+ Rails.application
41
+ end
42
+
43
+ def pledge_recited?
44
+ statement == PLEDGE
45
+ end
46
+
47
+ def append_route(name, &definition)
48
+ self.routes ||= {}
49
+ routes[name] = definition
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MaraudersMap
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'marauders_map/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'marauders_map'
9
+ spec.version = MaraudersMap::VERSION
10
+ spec.authors = ['Lee Machin']
11
+ spec.email = ['me@mrl.ee']
12
+
13
+ spec.summary = 'Declare your Rails routes using DDD principles'
14
+
15
+ spec.homepage = 'https://code.wellware.dev/leemachin/marauders_map'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_runtime_dependency 'activesupport', '>= 5.1', '<= 6.0.0.rc1'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 2.0'
30
+ spec.add_development_dependency 'minitest', '~> 5.0'
31
+ spec.add_development_dependency 'pry', '~> 0.12.2'
32
+ spec.add_development_dependency 'rails', '~> 5.2'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'sqlite3', '~> 1.0'
35
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marauders_map
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lee Machin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-06-06 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: '5.1'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.0.rc1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.1'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.0.rc1
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '5.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.12.2
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.12.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: rails
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '5.2'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '5.2'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '10.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '10.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: sqlite3
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.0'
117
+ description:
118
+ email:
119
+ - me@mrl.ee
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".gitignore"
125
+ - ".travis.yml"
126
+ - Gemfile
127
+ - Gemfile.lock
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - bin/console
132
+ - bin/setup
133
+ - lib/marauders_map.rb
134
+ - lib/marauders_map/version.rb
135
+ - marauders_map.gemspec
136
+ homepage: https://code.wellware.dev/leemachin/marauders_map
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubygems_version: 3.0.1
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Declare your Rails routes using DDD principles
159
+ test_files: []