the_string_to_slug 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/the_string_to_slug/version.rb +1 -1
- data/lib/the_string_to_slug.rb +33 -22
- data/spec/dummy_app/README.md +14 -0
- data/spec/dummy_app/db/schema.rb +16 -0
- data/spec/dummy_app/spec/helpers/string.rb +11 -0
- metadata +27 -18
- data/spec/dummy_app/README.rdoc +0 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee96cdf83aae4e27d147ffe28a082a53a304e497
|
4
|
+
data.tar.gz: 670d91f17e1405c90528b0d0b939cdeaf4c4e468
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd4ef70a8fc9734f82b611eed07feb210639d9172538e77e0da2e70c2449f50380876680aea18a95fc9414f93f01eea5a04b0107318663e8b86184b062903664
|
7
|
+
data.tar.gz: 2fa8fb13d35d6df3be99ba52c818915afbfbec3dcfa6eb4b892fc60361cc6e36425a745cc2737a1241ab81ef442f9d2c36fa41132bd2d0bb275d310077c4ecff
|
data/lib/the_string_to_slug.rb
CHANGED
@@ -4,10 +4,6 @@ require "the_string_to_slug/version"
|
|
4
4
|
module TheStringToSlug; end
|
5
5
|
|
6
6
|
class String
|
7
|
-
def self.to_slug_param str
|
8
|
-
I18n::transliterate(str).gsub('_','-').parameterize('-').downcase
|
9
|
-
end
|
10
|
-
|
11
7
|
def to_slug_param
|
12
8
|
self.class.to_slug_param(self)
|
13
9
|
end
|
@@ -16,25 +12,40 @@ class String
|
|
16
12
|
self.class.slugged_filename(self)
|
17
13
|
end
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
# -----------------------------------
|
22
|
-
def self.file_ext file_name
|
23
|
-
File.extname(file_name)[1..-1].to_s.to_slug_param
|
15
|
+
def slugged_file
|
16
|
+
self.class.slugged_file(self)
|
24
17
|
end
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
19
|
+
# -----------------------------------
|
20
|
+
# Self methods
|
21
|
+
# -----------------------------------
|
22
|
+
class << self
|
23
|
+
def to_slug_param str
|
24
|
+
I18n::transliterate(str).gsub('_','-').parameterize('-').downcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_ext file_name
|
28
|
+
File.extname(file_name)[1..-1].to_s.to_slug_param
|
29
|
+
end
|
30
|
+
|
31
|
+
def file_name file_name
|
32
|
+
file_name = File.basename(file_name)
|
33
|
+
ext = File.extname(file_name)
|
34
|
+
File.basename(file_name, ext).to_s.to_slug_param
|
35
|
+
end
|
36
|
+
|
37
|
+
def slugged_filename file_name
|
38
|
+
file_name = File.basename(file_name)
|
39
|
+
fname = self.file_name(file_name)
|
40
|
+
ext = self.file_ext(file_name)
|
41
|
+
|
42
|
+
return fname if ext.blank?
|
43
|
+
[fname, ext].join('.')
|
44
|
+
end
|
45
|
+
|
46
|
+
def slugged_file file_full_path
|
47
|
+
file_name = slugged_filename file_full_path
|
48
|
+
file_full_path.split('/')[0...-1].push(file_name).join '/'
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 0) do
|
15
|
+
|
16
|
+
end
|
@@ -20,4 +20,15 @@ describe 'StringToSlug' do
|
|
20
20
|
String.slugged_filename("/доки/dir/тест/доку мент").should eq "doku-ment"
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
context 'Full path to file' do
|
25
|
+
it 'should be true' do
|
26
|
+
"/doc/dir/test/document.doc".slugged_file.should eq "/doc/dir/test/document.doc"
|
27
|
+
"/доки/dir/тест/документ.doc".slugged_file.should eq "/доки/dir/тест/dokument.doc"
|
28
|
+
"/доки/dir/тест/документ".slugged_file.should eq "/доки/dir/тест/dokument"
|
29
|
+
"/доки/dir/тест/доку мент".slugged_file.should eq "/доки/dir/тест/doku-ment"
|
30
|
+
|
31
|
+
String.slugged_file("/доки/dir/тест/доку мент").should eq "/доки/dir/тест/doku-ment"
|
32
|
+
end
|
33
|
+
end
|
23
34
|
end
|
metadata
CHANGED
@@ -1,49 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_string_to_slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ilya N. Zykin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails-i18n
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 4.0.0.pre
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0.pre
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: bundler
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '1.3'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rake
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ! '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
description: ! ' Convert text string to slug param '
|
48
56
|
email:
|
49
57
|
- zykin-ilya@ya.ru
|
@@ -61,7 +69,7 @@ files:
|
|
61
69
|
- spec/dummy_app/.gitignore
|
62
70
|
- spec/dummy_app/.rspec
|
63
71
|
- spec/dummy_app/Gemfile
|
64
|
-
- spec/dummy_app/README.
|
72
|
+
- spec/dummy_app/README.md
|
65
73
|
- spec/dummy_app/Rakefile
|
66
74
|
- spec/dummy_app/app/assets/images/.keep
|
67
75
|
- spec/dummy_app/app/assets/javascripts/application.js
|
@@ -93,6 +101,7 @@ files:
|
|
93
101
|
- spec/dummy_app/config/initializers/wrap_parameters.rb
|
94
102
|
- spec/dummy_app/config/locales/en.yml
|
95
103
|
- spec/dummy_app/config/routes.rb
|
104
|
+
- spec/dummy_app/db/schema.rb
|
96
105
|
- spec/dummy_app/db/seeds.rb
|
97
106
|
- spec/dummy_app/lib/assets/.keep
|
98
107
|
- spec/dummy_app/lib/tasks/.keep
|
@@ -117,33 +126,32 @@ files:
|
|
117
126
|
homepage: https://github.com/the-teacher/the_string_to_slug
|
118
127
|
licenses:
|
119
128
|
- MIT
|
129
|
+
metadata: {}
|
120
130
|
post_install_message:
|
121
131
|
rdoc_options: []
|
122
132
|
require_paths:
|
123
133
|
- lib
|
124
134
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
135
|
requirements:
|
127
136
|
- - ! '>='
|
128
137
|
- !ruby/object:Gem::Version
|
129
138
|
version: '0'
|
130
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
140
|
requirements:
|
133
141
|
- - ! '>='
|
134
142
|
- !ruby/object:Gem::Version
|
135
143
|
version: '0'
|
136
144
|
requirements: []
|
137
145
|
rubyforge_project:
|
138
|
-
rubygems_version:
|
146
|
+
rubygems_version: 2.0.5
|
139
147
|
signing_key:
|
140
|
-
specification_version:
|
148
|
+
specification_version: 4
|
141
149
|
summary: Translite, downcase, parameterize
|
142
150
|
test_files:
|
143
151
|
- spec/dummy_app/.gitignore
|
144
152
|
- spec/dummy_app/.rspec
|
145
153
|
- spec/dummy_app/Gemfile
|
146
|
-
- spec/dummy_app/README.
|
154
|
+
- spec/dummy_app/README.md
|
147
155
|
- spec/dummy_app/Rakefile
|
148
156
|
- spec/dummy_app/app/assets/images/.keep
|
149
157
|
- spec/dummy_app/app/assets/javascripts/application.js
|
@@ -175,6 +183,7 @@ test_files:
|
|
175
183
|
- spec/dummy_app/config/initializers/wrap_parameters.rb
|
176
184
|
- spec/dummy_app/config/locales/en.yml
|
177
185
|
- spec/dummy_app/config/routes.rb
|
186
|
+
- spec/dummy_app/db/schema.rb
|
178
187
|
- spec/dummy_app/db/seeds.rb
|
179
188
|
- spec/dummy_app/lib/assets/.keep
|
180
189
|
- spec/dummy_app/lib/tasks/.keep
|
data/spec/dummy_app/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|