rails_templated_urls 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +34 -7
- data/lib/rails_templated_urls.rb +5 -0
- data/lib/rails_templated_urls/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 760d59f73f0f27a9f981644d3720e604203b0f3a
|
4
|
+
data.tar.gz: 5bd78dd7c05b22ac1e4f166530c0c96a9465037c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840b7d47ed1ab8556b3a5ed7232bdad62ab376b071402fa4f55afd7b861ce37e56897070799ee38fbffe61dbfcbd1073a9167a23226da27394a158d5da6f25f2
|
7
|
+
data.tar.gz: 579128c5fcc116976aeacfc71942338ca6d5ec1e48c9df087daab9b4b3f6f9581d53863ffae0a411902e91f428e7edb3ce399d8d204ef9881fac49834ccb3471
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# RailsTemplatedUrls
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem provides some helpers to build [templated URLS][1] based on the named
|
4
|
+
routes of your Rails application.
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -22,18 +21,46 @@ Or install it yourself as:
|
|
22
21
|
|
23
22
|
## Usage
|
24
23
|
|
25
|
-
|
24
|
+
Assuming you have the following route on your `routes.rb` file:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Rails.application.routes.draw do
|
28
|
+
resources :books
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
You can use the following helpers on your views:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
templated_path :books # => "/books"
|
36
|
+
templated_path :book # => "/books/{id}"
|
37
|
+
templated_path :edit_book # => "/books/{id}/edit"
|
38
|
+
templated_path :books, :foo, :bar # => "/books{?foo,bar}"
|
39
|
+
```
|
40
|
+
|
41
|
+
If you want the full URL, you can use another helper:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
templated_url :book # => "http://localhost:3000/books/{id}"
|
45
|
+
```
|
26
46
|
|
27
47
|
## Development
|
28
48
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
50
|
+
`bin/console` for an interactive prompt that will allow you to experiment.
|
30
51
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
52
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
53
|
+
release a new version, update the version number in `version.rb`, and then run
|
54
|
+
`bundle exec rake release` to create a git tag for the version, push git commits
|
55
|
+
and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
56
|
|
33
57
|
## Contributing
|
34
58
|
|
35
|
-
1. Fork it ( https://github.com/
|
59
|
+
1. Fork it ( https://github.com/lenon/rails_templated_urls/fork )
|
36
60
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
61
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
62
|
4. Push to the branch (`git push origin my-new-feature`)
|
39
63
|
5. Create a new Pull Request
|
64
|
+
|
65
|
+
[1]: http://tools.ietf.org/html/rfc6570
|
66
|
+
[2]: http://devdocs.io/rails/abstractcontroller/helpers/classmethods#method-i-helper
|
data/lib/rails_templated_urls.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
require 'rails'
|
1
2
|
require 'rails_templated_urls/version'
|
2
3
|
require 'rails_templated_urls/errors'
|
3
4
|
require 'rails_templated_urls/builder'
|
4
5
|
require 'rails_templated_urls/view_helpers'
|
6
|
+
|
7
|
+
ActiveSupport.on_load :action_view do
|
8
|
+
include RailsTemplatedUrls::ViewHelpers
|
9
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_templated_urls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lenon Marcel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|