httpify 0.1.0 → 0.1.2
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 +7 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -1
- data/README.md +6 -2
- data/Rakefile +8 -0
- data/httpify.gemspec +3 -3
- data/lib/httpify.rb +1 -3
- data/lib/httpify/version.rb +3 -0
- data/spec/httpify_spec.rb +52 -45
- data/spec/spec_helper.rb +10 -3
- metadata +29 -24
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5efb0445f62e9d8303d83a72aad2df3e4af285be
|
4
|
+
data.tar.gz: 7e3c8c0b4d9773cf452322b02d39a330ac397320
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b3247ae8b5ba2651cb85bc27e579275df8189a1d7378f53e92a5f1796beca6db78181055773481b3bb0f2d20a283a0817e972b6114b5bbf07866bbb912765d29
|
7
|
+
data.tar.gz: 7bc8cc6a142e0d244c427cb5f5db8e752c5916138eb6d68821f3ecd1d5c3ffc35aa52e8f2660ec326ed5c80071793f6ddcabb79ec94f0af197992e4592a6bee2
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
Httpify
|
2
2
|
=======
|
3
3
|
|
4
|
+
[](https://travis-ci.org/invisiblelines/httpify)
|
5
|
+
|
6
|
+
Adds a method on String to add the http(s) prefix
|
7
|
+
|
4
8
|
Usage
|
5
9
|
-----
|
6
10
|
|
7
|
-
|
8
|
-
automatically be prefixed with http://...
|
11
|
+
Use directly on any String object or include in your ActiveRecord model and
|
12
|
+
specify any attributes you wish to automatically be prefixed with http://...
|
9
13
|
|
10
14
|
Example
|
11
15
|
-------
|
data/Rakefile
ADDED
data/httpify.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
-
require 'httpify'
|
5
|
+
require 'httpify/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |gem|
|
8
8
|
gem.name = "httpify"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency "
|
21
|
+
gem.add_dependency "activesupport", ">= 3.0.0"
|
22
22
|
|
23
|
-
gem.add_development_dependency "rspec"
|
23
|
+
gem.add_development_dependency "rspec", "~> 2.8"
|
24
24
|
end
|
data/lib/httpify.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'active_support/core_ext/hash'
|
2
|
-
|
2
|
+
require 'httpify/version'
|
3
3
|
require 'httpify/httpifier'
|
4
4
|
require 'httpify/core_ext/string/httpify'
|
5
5
|
|
@@ -18,8 +18,6 @@ require 'httpify/core_ext/string/httpify'
|
|
18
18
|
|
19
19
|
module Httpify
|
20
20
|
|
21
|
-
VERSION = "0.1.0"
|
22
|
-
|
23
21
|
extend ActiveSupport::Concern
|
24
22
|
|
25
23
|
module ClassMethods
|
data/spec/httpify_spec.rb
CHANGED
@@ -2,30 +2,20 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module Httpify
|
4
4
|
|
5
|
-
class Link
|
6
|
-
|
7
|
-
include Httpify
|
8
|
-
|
9
|
-
attr_accessor :url, :source
|
10
|
-
|
11
|
-
httpify :url
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
5
|
describe "a String" do
|
16
6
|
|
17
7
|
it "should respond to httpify" do
|
18
|
-
"google.com".
|
8
|
+
expect("google.com").to respond_to(:httpify)
|
19
9
|
end
|
20
10
|
|
21
11
|
it "should return the string prefixed with http://" do
|
22
|
-
"www.google.com".httpify.
|
12
|
+
expect("www.google.com".httpify).to eql("http://www.google.com")
|
23
13
|
end
|
24
14
|
|
25
15
|
context "an httpified attribute starting http://" do
|
26
16
|
|
27
17
|
it "should not alter the string" do
|
28
|
-
"http://www.google.com".httpify.
|
18
|
+
expect("http://www.google.com".httpify).to eql("http://www.google.com")
|
29
19
|
end
|
30
20
|
|
31
21
|
end
|
@@ -33,7 +23,7 @@ module Httpify
|
|
33
23
|
context "an httpified attribute starting https://" do
|
34
24
|
|
35
25
|
it "should not alter the string" do
|
36
|
-
"https://www.google.com".httpify.
|
26
|
+
expect("https://www.google.com".httpify).to eql("https://www.google.com")
|
37
27
|
end
|
38
28
|
|
39
29
|
end
|
@@ -41,11 +31,11 @@ module Httpify
|
|
41
31
|
context "options" do
|
42
32
|
|
43
33
|
it "should prefix the string with https" do
|
44
|
-
"www.google.com".httpify(:https => true).
|
34
|
+
expect("www.google.com".httpify(:https => true)).to eql("https://www.google.com")
|
45
35
|
end
|
46
36
|
|
47
37
|
it "should add a trailing slash" do
|
48
|
-
"www.google.com".httpify("trailing_slash" => true).
|
38
|
+
expect("www.google.com".httpify("trailing_slash" => true)).to eql("http://www.google.com/")
|
49
39
|
end
|
50
40
|
|
51
41
|
end
|
@@ -54,47 +44,62 @@ module Httpify
|
|
54
44
|
|
55
45
|
describe "A class with Httpify included" do
|
56
46
|
|
57
|
-
|
58
|
-
|
47
|
+
subject { Link.new }
|
48
|
+
|
49
|
+
it "has a class method #httpify" do
|
50
|
+
expect(Link).to respond_to(:httpify)
|
59
51
|
end
|
60
52
|
|
61
53
|
context "an httpified attribute that is nil" do
|
62
|
-
|
63
|
-
it "should return nil" do
|
64
|
-
@link.url = nil
|
65
|
-
@link.url.should be_nil
|
66
|
-
end
|
67
|
-
|
54
|
+
its(:url) { should be_nil }
|
68
55
|
end
|
69
56
|
|
70
57
|
context "an httpified attribute that is blank" do
|
71
|
-
|
72
|
-
|
73
|
-
@link.url = ""
|
74
|
-
@link.url.should == ""
|
58
|
+
before do
|
59
|
+
subject.url = ''
|
75
60
|
end
|
76
|
-
|
61
|
+
|
62
|
+
its(:url) { should be_blank }
|
77
63
|
end
|
78
64
|
|
79
65
|
context "a httpified attribute that is a String" do
|
80
|
-
|
81
|
-
|
82
|
-
@link.url = "www.google.com"
|
83
|
-
@link.url.should == "http://www.google.com"
|
66
|
+
before do
|
67
|
+
subject.url = 'www.google.com'
|
84
68
|
end
|
85
69
|
|
70
|
+
its(:url) { should eql("http://www.google.com") }
|
86
71
|
end
|
87
72
|
|
88
73
|
context "options" do
|
89
74
|
|
90
|
-
|
91
|
-
|
75
|
+
context "accepts options for :https" do
|
76
|
+
before do
|
77
|
+
Link.httpify :url, :https => true
|
78
|
+
end
|
79
|
+
|
80
|
+
subject do
|
81
|
+
link = Link.new
|
82
|
+
link.url = "www.google.com"
|
83
|
+
|
84
|
+
link
|
85
|
+
end
|
86
|
+
|
87
|
+
its(:url) { should eql("https://www.google.com") }
|
92
88
|
end
|
93
89
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
context "accepts options for :trailing_slash" do
|
91
|
+
before do
|
92
|
+
Link.httpify :url, :trailing_slash => true
|
93
|
+
end
|
94
|
+
|
95
|
+
subject do
|
96
|
+
link = Link.new
|
97
|
+
link.url = "www.google.com"
|
98
|
+
|
99
|
+
link
|
100
|
+
end
|
101
|
+
|
102
|
+
its(:url) { should eql("http://www.google.com/") }
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
@@ -104,14 +109,16 @@ module Httpify
|
|
104
109
|
Link.httpify :url, :source
|
105
110
|
end
|
106
111
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
112
|
+
subject do
|
113
|
+
link = Link.new
|
114
|
+
link.url = "www.google.com"
|
115
|
+
link.source = "news.ycombinator.com"
|
116
|
+
|
117
|
+
link
|
113
118
|
end
|
114
119
|
|
120
|
+
its(:url) { should eql("http://www.google.com") }
|
121
|
+
its(:source) { should eql("http://news.ycombinator.com") }
|
115
122
|
end
|
116
123
|
|
117
124
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,38 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kieran Johnson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
17
|
-
none: false
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 3.0.0
|
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: 3.0.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rspec
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
+
version: '2.8'
|
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: '2.8'
|
36
41
|
description: Prefixes any httpified elements with http:// should they be missing this
|
37
42
|
email:
|
38
43
|
- kieran@invisiblelines.com
|
@@ -40,44 +45,44 @@ executables: []
|
|
40
45
|
extensions: []
|
41
46
|
extra_rdoc_files: []
|
42
47
|
files:
|
43
|
-
- .DS_Store
|
44
48
|
- .gitignore
|
49
|
+
- .rspec
|
50
|
+
- .travis.yml
|
45
51
|
- Gemfile
|
46
52
|
- LICENSE
|
47
53
|
- README.md
|
54
|
+
- Rakefile
|
48
55
|
- httpify.gemspec
|
49
|
-
- lib/.DS_Store
|
50
56
|
- lib/httpify.rb
|
51
|
-
- lib/httpify/.DS_Store
|
52
|
-
- lib/httpify/core_ext/.DS_Store
|
53
57
|
- lib/httpify/core_ext/string/httpify.rb
|
54
58
|
- lib/httpify/httpifier.rb
|
59
|
+
- lib/httpify/version.rb
|
55
60
|
- spec/httpify_spec.rb
|
56
61
|
- spec/spec_helper.rb
|
57
62
|
homepage: http://github.com/invisiblelines/httpify
|
58
63
|
licenses: []
|
64
|
+
metadata: {}
|
59
65
|
post_install_message:
|
60
66
|
rdoc_options: []
|
61
67
|
require_paths:
|
62
68
|
- lib
|
63
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
70
|
requirements:
|
66
|
-
- -
|
71
|
+
- - '>='
|
67
72
|
- !ruby/object:Gem::Version
|
68
73
|
version: '0'
|
69
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
75
|
requirements:
|
72
|
-
- -
|
76
|
+
- - '>='
|
73
77
|
- !ruby/object:Gem::Version
|
74
78
|
version: '0'
|
75
79
|
requirements: []
|
76
80
|
rubyforge_project:
|
77
|
-
rubygems_version:
|
81
|
+
rubygems_version: 2.0.3
|
78
82
|
signing_key:
|
79
|
-
specification_version:
|
83
|
+
specification_version: 4
|
80
84
|
summary: Prefixes any httpified elements with http://
|
81
85
|
test_files:
|
82
86
|
- spec/httpify_spec.rb
|
83
87
|
- spec/spec_helper.rb
|
88
|
+
has_rdoc:
|