From 2a1ced6f608b8b368f58dfd3e3d090bcb83d477c Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 20 Sep 2011 14:24:42 +0100 Subject: [PATCH] Initial commit --- .gitignore | 4 ++++ Gemfile | 4 ++++ Rakefile | 1 + lib/readingtime.rb | 6 ++++++ lib/readingtime/core_ext.rb | 11 +++++++++++ lib/readingtime/version.rb | 3 +++ readingtime.gemspec | 20 ++++++++++++++++++++ 7 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Rakefile create mode 100644 lib/readingtime.rb create mode 100644 lib/readingtime/core_ext.rb create mode 100644 lib/readingtime/version.rb create mode 100644 readingtime.gemspec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4040c6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.gem +.bundle +Gemfile.lock +pkg/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..7404baa --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in readingtime.gemspec +gemspec diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..c702cfc --- /dev/null +++ b/Rakefile @@ -0,0 +1 @@ +require 'bundler/gem_tasks' diff --git a/lib/readingtime.rb b/lib/readingtime.rb new file mode 100644 index 0000000..47298af --- /dev/null +++ b/lib/readingtime.rb @@ -0,0 +1,6 @@ +require "readingtime/version" +require "readingtime/core_ext" + +module Readingtime + # Your code goes here... +end diff --git a/lib/readingtime/core_ext.rb b/lib/readingtime/core_ext.rb new file mode 100644 index 0000000..e8defa9 --- /dev/null +++ b/lib/readingtime/core_ext.rb @@ -0,0 +1,11 @@ +String.class_eval do + def reading_time + word = self.scan(/(\w|-)+/).size + + minutes = (word / 200).floor + seconds = (word % 200 / (200 / 60)).floor + + return minutes.to_s + ":" + seconds.to_s + + end +end \ No newline at end of file diff --git a/lib/readingtime/version.rb b/lib/readingtime/version.rb new file mode 100644 index 0000000..d83ef0d --- /dev/null +++ b/lib/readingtime/version.rb @@ -0,0 +1,3 @@ +module Readingtime + VERSION = "0.0.1" +end diff --git a/readingtime.gemspec b/readingtime.gemspec new file mode 100644 index 0000000..6eca759 --- /dev/null +++ b/readingtime.gemspec @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "readingtime/version" + +Gem::Specification.new do |s| + s.name = "readingtime" + s.version = Readingtime::VERSION + s.authors = ["Gareth Rees"] + s.email = ["reesG12@cardiff.ac.uk"] + s.homepage = "" + s.summary = %q{TODO: Write a gem summary} + s.description = %q{TODO: Write a gem description} + + s.rubyforge_project = "readingtime" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] +end