reading_time 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.DS_Store ADDED
Binary file
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2.2)
10
+ rcov (0.9.11)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.6.4)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Mark Provan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ ##reading_time
2
+
3
+ Super simple gem that allows you to output a reading time for a blog post etc.
4
+
5
+ ###Install
6
+ `$ gem install readingtime`
7
+
8
+ ###Run
9
+
10
+ `time_to_read(string)`
11
+ `=> "about 2 minutes"`
12
+
13
+ #### Contributing to readingtime
14
+
15
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
16
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
17
+ * Fork the project
18
+ * Start a feature/bugfix branch
19
+ * Commit and push until you are happy with your contribution
20
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
21
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
22
+
23
+ #### Copyright
24
+
25
+ Copyright (c) 2011 Mark Provan. See LICENSE.txt for
26
+ further details.
27
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "reading_time"
18
+ gem.homepage = "http://github.com/markprovan/readingtime"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Simple gem to tell readers how long a post will take to read.}
21
+ gem.description = %Q{Feed it a string, it will spit out a time.}
22
+ gem.email = "markgprovan@gmail.com"
23
+ gem.authors = ["Mark Provan"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "readingtime #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,9 @@
1
+ def time_to_read(string)
2
+ words = string.scan(/\w+/).size
3
+ time = (words.to_f/180).ceil
4
+ if time == 1
5
+ "less than a minute"
6
+ else
7
+ "about #{time} minutes"
8
+ end
9
+ end
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "reading_time"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mark Provan"]
12
+ s.date = "2011-10-31"
13
+ s.description = "Feed it a string, it will spit out a time."
14
+ s.email = "markgprovan@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".DS_Store",
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/.DS_Store",
29
+ "lib/readingtime.rb",
30
+ "readingtime.gemspec",
31
+ "test/helper.rb",
32
+ "test/test_readingtime.rb",
33
+ "test/text.txt"
34
+ ]
35
+ s.homepage = "http://github.com/markprovan/readingtime"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "1.8.10"
39
+ s.summary = "Simple gem to tell readers how long a post will take to read."
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
48
+ s.add_development_dependency(%q<rcov>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<shoulda>, [">= 0"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
53
+ s.add_dependency(%q<rcov>, [">= 0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<shoulda>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ end
61
+ end
62
+
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'readingtime'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,9 @@
1
+ require './helper.rb'
2
+
3
+ class TestReadingtime < Test::Unit::TestCase
4
+ should "give accurate time for reading based on 180 wpm" do
5
+ file = File.open("./text.txt")
6
+ string = file.read
7
+ assert_equal time_to_read(string), "about 2 minutes"
8
+ end
9
+ end
data/test/text.txt ADDED
@@ -0,0 +1,7 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. In at quam eu sapien ornare ultricies. Etiam dignissim, purus non ornare egestas, justo arcu volutpat augue, porttitor iaculis erat ante at dolor. Fusce aliquam nulla et lectus hendrerit nec iaculis nulla sagittis. Suspendisse tempor dolor quis eros venenatis ornare. Praesent sed massa id diam rhoncus blandit a vitae neque. Quisque enim massa, posuere ac ultricies at, condimentum eget diam. Vestibulum non nisl vitae felis vestibulum sollicitudin. In ac nisl lacus. Curabitur laoreet tristique sem tincidunt luctus. Ut quis erat lorem. Duis non mauris ut tellus pretium ultrices. Nullam vitae urna vitae eros pharetra dignissim eget sit amet ipsum. Vivamus nec erat quis mi varius volutpat.
2
+
3
+ Cras blandit metus vitae augue hendrerit placerat. Fusce vulputate euismod leo, eu interdum risus semper sed. Donec feugiat elementum nunc, et semper magna pretium ut. Proin tortor magna, varius nec ultrices a, scelerisque eu odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi dictum dui sodales massa consequat congue. Vivamus et dui erat. Duis gravida nunc nec lorem blandit at tincidunt leo commodo. Morbi nulla urna, placerat sed venenatis tincidunt, condimentum vel purus. Aenean ultricies purus eu mauris fringilla id hendrerit leo sollicitudin.
4
+
5
+ Aliquam vel imperdiet eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras eget nisl ac ligula tincidunt tincidunt. Donec at tincidunt tortor. Integer ligula arcu, elementum eu vestibulum ut, porta at justo. Suspendisse bibendum auctor dui. Sed ligula mauris, faucibus eget ultricies eu, rutrum pharetra ante. Mauris luctus neque sit amet velit mattis eget eleifend leo semper. Aenean vel risus metus. Integer non odio dui. Fusce tincidunt mattis odio non elementum. Proin ut vulputate diam. Proin scelerisque posuere erat, non sodales dui gravida ac.
6
+
7
+ Nam placerat augue sed augue facilisis sit amet commodo orci tristique. Vivamus tempus metus vitae magna bibendum tempus ut vitae libero. Aenean sit amet ante felis, vel posuere est. Fusce euismod ultricies purus, sit amet egestas augue sagittis quis. Etiam pulvinar interdum purus sed sollicitudin. Praesent fermentum nibh eget libero sodales ac facilisis diam pharetra. Integer dignissim lacus id magna mattis in ullamcorper metus condimentum. Suspendisse sit amet.
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reading_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Provan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: &70157372973820 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70157372973820
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70157372973200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70157372973200
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &70157372972600 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70157372972600
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &70157372972000 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70157372972000
58
+ description: Feed it a string, it will spit out a time.
59
+ email: markgprovan@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - LICENSE.txt
64
+ - README.md
65
+ files:
66
+ - .DS_Store
67
+ - .document
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - VERSION
74
+ - lib/.DS_Store
75
+ - lib/readingtime.rb
76
+ - readingtime.gemspec
77
+ - test/helper.rb
78
+ - test/test_readingtime.rb
79
+ - test/text.txt
80
+ homepage: http://github.com/markprovan/readingtime
81
+ licenses:
82
+ - MIT
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.10
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Simple gem to tell readers how long a post will take to read.
105
+ test_files: []