draw_static 0.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/draw_static.rb +13 -0
  3. data/lib/static_routes.rb +18 -0
  4. metadata +65 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f137de6dc58759a5e0bbc3c02a6da62b82c910f39fe4c6ea92b355e65fe903b3
4
+ data.tar.gz: 41a40abd2a9a2ec7b6d82f21b98c67991858efe1f73c8ffda3a43bf0f4f853f2
5
+ SHA512:
6
+ metadata.gz: 5f09a5279412d1ada7dd7832ccbcde68dfd3cf6a598bf91e81974ba41fdad9f061c17e4f60b245e8f0fd0806027682cde76fe1091676592ca8a7a37bd0986c82
7
+ data.tar.gz: f46c2a960e6b6599ebb89cbf203efed82edcf9dac1bb985e471c6f2efe7085f56959a7c84bcf58c8400cbcc45b35e399f833faeceed76f658655e823d78cc21a
@@ -0,0 +1,13 @@
1
+ require_relative 'static_routes'
2
+
3
+ begin
4
+ ActionDispatch::Routing::Mapper.class_eval do
5
+ def draw_static(*controllers)
6
+ controllers.each do |controller|
7
+ StaticRoutes.for(controller, self)
8
+ end
9
+ end
10
+ end
11
+ rescue
12
+ puts "Please add this gem to rails - it is dependent on ActionDispatch::Routing::Mapper"
13
+ end
@@ -0,0 +1,18 @@
1
+ class StaticRoutes
2
+ class << self
3
+ def route_from_action(action)
4
+ action.to_s.gsub(/[^a-zA-Z]/, "-")
5
+ end
6
+
7
+ def controller_from_chars(chars)
8
+ "#{chars.to_s.camelize}Controller".constantize
9
+ end
10
+
11
+ def for(controller, context)
12
+ controller_constant = controller_from_chars(controller)
13
+ controller_constant.instance_methods(false).each do |action|
14
+ context.get(route_from_action(action), to: "#{controller}##{action}")
15
+ end
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: draw_static
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Inou Ridder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '5.0'
30
+ - - ">"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ description: A gem to avoid repitition in your rails routes file
34
+ email: inouridder@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - lib/draw_static.rb
40
+ - lib/static_routes.rb
41
+ homepage: https://github.com/InouRidder/draw_static
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.7.6
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Draw static routes
65
+ test_files: []