friendly_id-mobility 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
+ SHA1:
3
+ metadata.gz: b795a77df5b0754c68965a8edcaab982dbf16156
4
+ data.tar.gz: 45f876b1fbd1390214ee2435406a8c018dadfc76
5
+ SHA512:
6
+ metadata.gz: f52c7b45cce67256652debbe82f843d465f2d6a80624645b811397dc037225fca021a82e607a18dc358bed13169d099a32ba1083846e7acd297ba26cdc59457f
7
+ data.tar.gz: d3b91e56dfb308bd22d1f4a670a7c17ef5393f484aa38f4b31f5a5aa84b7685646f541a1e03bac252120b40ba8cf5da7d4762e616bf795e764598b6665fdc7ee
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at chris@dejimata.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in friendly_id-mobility.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ friendly_id-mobility (0.1.0)
5
+ friendly_id (>= 5.0.0, <= 5.3.0)
6
+ mobility (~> 0.1.12)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (5.0.2)
12
+ activesupport (= 5.0.2)
13
+ activerecord (5.0.2)
14
+ activemodel (= 5.0.2)
15
+ activesupport (= 5.0.2)
16
+ arel (~> 7.0)
17
+ activesupport (5.0.2)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ i18n (~> 0.7)
20
+ minitest (~> 5.1)
21
+ tzinfo (~> 1.1)
22
+ arel (7.1.4)
23
+ concurrent-ruby (1.0.5)
24
+ diff-lcs (1.3)
25
+ friendly_id (5.2.0)
26
+ activerecord (>= 4.0.0)
27
+ i18n (0.8.1)
28
+ minitest (5.10.1)
29
+ mobility (0.1.12)
30
+ i18n (>= 0.6.10)
31
+ request_store (~> 1.0)
32
+ rake (10.5.0)
33
+ request_store (1.3.2)
34
+ rspec (3.5.0)
35
+ rspec-core (~> 3.5.0)
36
+ rspec-expectations (~> 3.5.0)
37
+ rspec-mocks (~> 3.5.0)
38
+ rspec-core (3.5.4)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-expectations (3.5.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-mocks (3.5.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.5.0)
46
+ rspec-support (3.5.0)
47
+ thread_safe (0.3.6)
48
+ tzinfo (1.2.3)
49
+ thread_safe (~> 0.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ bundler (~> 1.12)
56
+ friendly_id-mobility!
57
+ rake (~> 10.0)
58
+ rspec (~> 3.0)
59
+
60
+ BUNDLED WITH
61
+ 1.12.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Chris Salzberg
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,84 @@
1
+ # FriendlyId Mobility
2
+
3
+ [Mobility](https://github.com/shioyama/mobility) support for
4
+ [FriendlyId](https://github.com/norman/friendly_id).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'friendly_id-mobility'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install friendly_id-mobility
21
+
22
+ ## Translating Slugs using Mobility
23
+
24
+ To translate slugs using Mobility, simply translate the attribute you want to
25
+ use to generate slugs and also translate the slug attribute itself, and then
26
+ call `friendly_id` with `use: :mobility`:
27
+
28
+ ```ruby
29
+ class Post < ActiveRecord::Base
30
+ include Mobility
31
+ translates :title, :slug
32
+
33
+ extend FriendlyId
34
+ friendly_id :title, use: :mobility
35
+ end
36
+ ```
37
+
38
+ You can now save `title` in any locale and FriendlyId will generate a
39
+ slug, stored by Mobility in the current locale:
40
+
41
+ ```ruby
42
+ post = Post.create(title: "My Foo Title")
43
+ post.title
44
+ #=> "My Foo Title"
45
+ post.slug
46
+ #=> "my-foo-title"
47
+ Mobility.locale = :fr
48
+ post.title = "Mon titre foo"
49
+ post.save
50
+ post.slug
51
+ #=> "mon-titre-foo"
52
+ Mobility.locale = :en
53
+ post.slug
54
+ #=> "my-foo-title"
55
+ ```
56
+
57
+ Finders work too:
58
+
59
+ ```ruby
60
+ Mobility.locale = :en
61
+ Post.friendly.find("my-foo-title")
62
+ #=> #<Post id: 1 ...>
63
+ Mobility.locale = :fr
64
+ Post.friendly.find("mon-titre-foo")
65
+ #=> #<Post id: 1 ...>
66
+ ```
67
+
68
+ ## Development
69
+
70
+ (TODO)
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at
75
+ https://github.com/shioyama/friendly_id-mobility. This project is intended to
76
+ be a safe, welcoming space for collaboration, and contributors are expected to
77
+ adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
78
+ conduct.
79
+
80
+
81
+ ## License
82
+
83
+ The gem is available as open source under the terms of the [MIT
84
+ License](http://opensource.org/licenses/MIT).
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
@@ -0,0 +1,31 @@
1
+ require "friendly_id"
2
+ require "friendly_id/mobility/version"
3
+
4
+ module FriendlyId
5
+ module Mobility
6
+ class << self
7
+ def setup(model_class)
8
+ model_class.friendly_id_config.use :slugged
9
+ end
10
+
11
+ def included(model_class)
12
+ advise_against_untranslated_model(model_class)
13
+
14
+ mod = Module.new do
15
+ def friendly
16
+ super.i18n
17
+ end
18
+ end
19
+ model_class.send :extend, mod
20
+ end
21
+
22
+ def advise_against_untranslated_model(model)
23
+ field = model.friendly_id_config.query_field
24
+ if !model.respond_to?(:translated_attribute_names) || model.translated_attribute_names.exclude?(field)
25
+ raise "[FriendlyId] You need to translate the '#{field}' field with " \
26
+ "Mobility (add 'translates :#{field}' in your model '#{model.name}')"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module FriendlyId
2
+ module Mobility
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: friendly_id-mobility
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Salzberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mobility
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.12
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.12
27
+ - !ruby/object:Gem::Dependency
28
+ name: friendly_id
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.0.0
34
+ - - "<="
35
+ - !ruby/object:Gem::Version
36
+ version: 5.3.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 5.0.0
44
+ - - "<="
45
+ - !ruby/object:Gem::Version
46
+ version: 5.3.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.12'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.12'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ description:
90
+ email:
91
+ - chris@dejimata.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - lib/friendly_id/mobility.rb
103
+ - lib/friendly_id/mobility/version.rb
104
+ homepage: https://github.com/shioyama/friendly_id-mobility
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5.1
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Translate your FriendlyId slugs with Mobility.
128
+ test_files: []