href-preview 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ # Copyright 2014 Bob Aman
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ # Used to prevent the class/module from being loaded more than once
17
+ unless defined? HRefPreview::VERSION
18
+ module HRefPreview
19
+ module VERSION
20
+ MAJOR = 0
21
+ MINOR = 1
22
+ TINY = 0
23
+
24
+ STRING = [MAJOR, MINOR, TINY].join('.')
25
+ end
26
+ end
27
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format specdoc
@@ -0,0 +1,7 @@
1
+ spec_dir = File.expand_path(File.dirname(__FILE__))
2
+ lib_dir = File.expand_path(File.join(spec_dir, '../lib'))
3
+
4
+ $:.unshift(lib_dir)
5
+ $:.uniq!
6
+
7
+ require 'href-preview'
@@ -0,0 +1,2 @@
1
+ desc 'Remove all build products'
2
+ task 'clobber'
data/tasks/gem.rake ADDED
@@ -0,0 +1,95 @@
1
+ require "rubygems/package_task"
2
+
3
+ namespace :gem do
4
+ GEM_SPEC = Gem::Specification.new do |s|
5
+ s.name = PKG_NAME
6
+ s.version = PKG_VERSION
7
+ s.summary = PKG_SUMMARY
8
+ s.description = PKG_DESCRIPTION
9
+
10
+ s.files = PKG_FILES.to_a
11
+
12
+ s.has_rdoc = false
13
+ s.extra_rdoc_files = %w( README.md )
14
+ s.rdoc_options.concat ["--main", "README.md"]
15
+
16
+ if !s.respond_to?(:add_development_dependency)
17
+ puts "Cannot build Gem with this version of RubyGems."
18
+ exit(1)
19
+ end
20
+
21
+ s.add_development_dependency("rake", ">= 0.7.3")
22
+ s.add_development_dependency("rspec", ">= 2.9.0")
23
+ s.add_development_dependency("launchy", ">= 0.3.2")
24
+ s.add_development_dependency("vcr", ">= 2.6.0")
25
+
26
+ s.add_runtime_dependency("addressable", ">= 2.5.0")
27
+ s.add_runtime_dependency("faraday", ">= 0.8.0")
28
+ s.add_runtime_dependency("faraday_middleware", ">= 0.8.0")
29
+ s.add_runtime_dependency("sanitize", ">= 2.0.0")
30
+ s.add_runtime_dependency("nokogiri", ">= 1.5.0")
31
+ s.add_runtime_dependency("mime-types", ">= 2.0")
32
+ s.add_runtime_dependency("httpclient", ">= 2.3")
33
+ s.add_runtime_dependency("fastimage", ">= 1.5.0")
34
+
35
+ s.require_path = "lib"
36
+
37
+ s.author = "Bob Aman"
38
+ s.email = "bob@sporkmonger.com"
39
+ s.homepage = PKG_HOMEPAGE
40
+ s.license = "Apache License 2.0"
41
+ end
42
+
43
+ Gem::PackageTask.new(GEM_SPEC) do |p|
44
+ p.gem_spec = GEM_SPEC
45
+ p.need_tar = true
46
+ p.need_zip = true
47
+ end
48
+
49
+ desc "Generates .gemspec file"
50
+ task :gemspec do
51
+ spec_string = GEM_SPEC.to_ruby
52
+
53
+ begin
54
+ Thread.new { eval("$SAFE = 3\n#{spec_string}", binding) }.join
55
+ rescue
56
+ abort "unsafe gemspec: #{$!}"
57
+ else
58
+ File.open("#{GEM_SPEC.name}.gemspec", 'w') do |file|
59
+ file.write spec_string
60
+ end
61
+ end
62
+ end
63
+
64
+ desc "Show information about the gem"
65
+ task :debug do
66
+ puts GEM_SPEC.to_ruby
67
+ end
68
+
69
+ desc "Install the gem"
70
+ task :install => ["clobber", "gem:package"] do
71
+ sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
72
+ end
73
+
74
+ desc "Uninstall the gem"
75
+ task :uninstall do
76
+ installed_list = Gem.source_index.find_name(PKG_NAME)
77
+ if installed_list &&
78
+ (installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
79
+ sh(
80
+ "#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
81
+ "--ignore-dependencies --executables #{PKG_NAME}"
82
+ )
83
+ end
84
+ end
85
+
86
+ desc "Reinstall the gem"
87
+ task :reinstall => [:uninstall, :install]
88
+ end
89
+
90
+ desc "Alias to gem:package"
91
+ task "gem" => "gem:package"
92
+
93
+ task "gem:release" => "gem:gemspec"
94
+
95
+ task "clobber" => ["gem:clobber_package"]
data/tasks/git.rake ADDED
@@ -0,0 +1,40 @@
1
+ namespace :git do
2
+ namespace :tag do
3
+ desc 'List tags from the Git repository'
4
+ task :list do
5
+ tags = `git tag -l`
6
+ tags.gsub!("\r", '')
7
+ tags = tags.split("\n").sort {|a, b| b <=> a }
8
+ puts tags.join("\n")
9
+ end
10
+
11
+ desc 'Create a new tag in the Git repository'
12
+ task :create do
13
+ changelog = File.open('CHANGELOG', 'r') { |file| file.read }
14
+ puts '-' * 80
15
+ puts changelog
16
+ puts '-' * 80
17
+ puts
18
+
19
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
20
+ abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
21
+
22
+ tag = "#{PKG_NAME}-#{PKG_VERSION}"
23
+ msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
24
+
25
+ existing_tags = `git tag -l #{PKG_NAME}-*`.split("\n")
26
+ if existing_tags.include?(tag)
27
+ warn('Tag already exists, deleting...')
28
+ unless system "git tag -d #{tag}"
29
+ abort 'Tag deletion failed.'
30
+ end
31
+ end
32
+ puts "Creating git tag '#{tag}'..."
33
+ unless system "git tag -a -m \"#{msg}\" #{tag}"
34
+ abort 'Tag creation failed.'
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ task 'gem:release' => 'git:tag:create'
@@ -0,0 +1,22 @@
1
+ namespace :metrics do
2
+ task :lines do
3
+ lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
4
+ for file_name in FileList['lib/**/*.rb']
5
+ f = File.open(file_name)
6
+ while line = f.gets
7
+ lines += 1
8
+ next if line =~ /^\s*$/
9
+ next if line =~ /^\s*#/
10
+ codelines += 1
11
+ end
12
+ puts "L: #{sprintf('%4d', lines)}, " +
13
+ "LOC #{sprintf('%4d', codelines)} | #{file_name}"
14
+ total_lines += lines
15
+ total_codelines += codelines
16
+
17
+ lines, codelines = 0, 0
18
+ end
19
+
20
+ puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
21
+ end
22
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,57 @@
1
+ require "rspec/core/rake_task"
2
+
3
+ namespace :spec do
4
+ RSpec::Core::RakeTask.new(:rcov) do |t|
5
+ t.pattern = FileList['spec/**/*_spec.rb']
6
+ t.rspec_opts = ['--color', '--format', 'documentation']
7
+
8
+ t.rcov = RCOV_ENABLED
9
+ t.rcov_opts = [
10
+ '--exclude', 'lib\\/compat',
11
+ '--exclude', 'spec',
12
+ '--exclude', '\\.rvm\\/gems',
13
+ '--exclude', '1\\.8\\/gems',
14
+ '--exclude', '1\\.9\\/gems',
15
+ '--exclude', '\\.rvm',
16
+ '--exclude', '\\/Library\\/Ruby',
17
+ ]
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:normal) do |t|
21
+ t.pattern = FileList['spec/**/*_spec.rb'].exclude(/compat/)
22
+ t.rspec_opts = ['--color', '--format', 'documentation']
23
+ t.rcov = false
24
+ end
25
+
26
+ RSpec::Core::RakeTask.new(:all) do |t|
27
+ t.pattern = FileList['spec/**/*_spec.rb']
28
+ t.rspec_opts = ['--color', '--format', 'documentation']
29
+ t.rcov = false
30
+ end
31
+
32
+ desc "Generate HTML Specdocs for all specs"
33
+ RSpec::Core::RakeTask.new(:specdoc) do |t|
34
+ specdoc_path = File.expand_path(
35
+ File.join(File.dirname(__FILE__), '..', 'documentation')
36
+ )
37
+ Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
38
+
39
+ output_file = File.join(specdoc_path, 'index.html')
40
+ t.pattern = FileList['spec/**/*_spec.rb']
41
+ t.rspec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
42
+ t.fail_on_error = false
43
+ end
44
+
45
+ namespace :rcov do
46
+ desc "Browse the code coverage report."
47
+ task :browse => "spec:rcov" do
48
+ require "launchy"
49
+ Launchy::Browser.run("coverage/index.html")
50
+ end
51
+ end
52
+ end
53
+
54
+ desc "Alias to spec:normal"
55
+ task "spec" => "spec:normal"
56
+
57
+ task "clobber" => ["spec:clobber_rcov"]
data/tasks/yard.rake ADDED
@@ -0,0 +1,26 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'yard'
5
+ require 'yard/rake/yardoc_task'
6
+
7
+ namespace :doc do
8
+ desc 'Generate Yardoc documentation'
9
+ YARD::Rake::YardocTask.new do |yardoc|
10
+ yardoc.name = 'yard'
11
+ yardoc.options = ['--verbose']
12
+ yardoc.files = [
13
+ 'lib/**/*.rb', 'ext/**/*.c', 'README', 'CHANGELOG', 'LICENSE'
14
+ ]
15
+ end
16
+ end
17
+
18
+ task 'clobber' => ['doc:clobber_yard']
19
+
20
+ desc 'Alias to doc:yard'
21
+ task 'doc' => 'doc:yard'
22
+ rescue LoadError
23
+ # If yard isn't available, it's not the end of the world
24
+ desc 'Alias to doc:rdoc'
25
+ task 'doc' => 'doc:rdoc'
26
+ end
metadata ADDED
@@ -0,0 +1,234 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: href-preview
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bob Aman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.3
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.9.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: launchy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: addressable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.5.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.5.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday_middleware
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: sanitize
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 2.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: nokogiri
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 1.5.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 1.5.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: mime-types
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: httpclient
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '2.3'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '2.3'
167
+ - !ruby/object:Gem::Dependency
168
+ name: fastimage
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.5.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: 1.5.0
181
+ description: |
182
+ A simple library for efficiently previewing links.
183
+ email: bob@sporkmonger.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files:
187
+ - README.md
188
+ files:
189
+ - CHANGELOG
190
+ - Gemfile
191
+ - LICENSE
192
+ - README.md
193
+ - Rakefile
194
+ - lib/href-preview.rb
195
+ - lib/href_preview.rb
196
+ - lib/href_preview/faraday_common_request.rb
197
+ - lib/href_preview/fastimage_uri.rb
198
+ - lib/href_preview/preview.rb
199
+ - lib/href_preview/version.rb
200
+ - spec/spec.opts
201
+ - spec/spec_helper.rb
202
+ - tasks/clobber.rake
203
+ - tasks/gem.rake
204
+ - tasks/git.rake
205
+ - tasks/metrics.rake
206
+ - tasks/spec.rake
207
+ - tasks/yard.rake
208
+ homepage: https://github.com/sporkmonger/href-preview
209
+ licenses:
210
+ - Apache License 2.0
211
+ metadata: {}
212
+ post_install_message:
213
+ rdoc_options:
214
+ - --main
215
+ - README.md
216
+ require_paths:
217
+ - lib
218
+ required_ruby_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ required_rubygems_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - '>='
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ requirements: []
229
+ rubyforge_project:
230
+ rubygems_version: 2.2.1
231
+ signing_key:
232
+ specification_version: 4
233
+ summary: Package Summary
234
+ test_files: []