Skip to content

Commit

Permalink
init with new name
Browse files Browse the repository at this point in the history
  • Loading branch information
ip2k committed Sep 7, 2011
1 parent a53a851 commit 0e45e6f
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 84 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Expand Up @@ -3,11 +3,10 @@ source "http://rubygems.org"
# Example:
# gem "activesupport", ">= 2.3.5"

gem "sqlite3"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.4"
gem "rcov", ">= 0"
end
18 changes: 18 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,18 @@
GEM
remote: http://rubygems.org/
specs:
git (1.2.5)
jeweler (1.6.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rake (0.9.2)
sqlite3 (1.3.4)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.0.0)
jeweler (~> 1.6.4)
sqlite3
84 changes: 64 additions & 20 deletions LICENSE.txt

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions README.rdoc
@@ -1,8 +1,17 @@
= todayilearned
= til

Description goes here.
'til' stands for 'Today I Learned...' and the point of the application is:
- You do whatever it is that you do all day
- You sit down and type 'til' into your terminal
- You write a short diddy about what you learned
- It gets saved
- You see what you learned before to remind yourself how awesome you are

== Contributing to todayilearned
The data is stored in a nice little SQLite file inside of ~/.til/til.sqlite by default, so you can do all manner of funsey SQL things to it if you'd like.

We're using prepared statements for INSERTs, so it *should* handle whatever cockamamie input you can think up...but if it doesn't, feel free to yell at me (@ip2k on Twitter) and I'll try to fix it!

== Contributing to til

* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
Expand All @@ -14,6 +23,4 @@ Description goes here.

== Copyright

Copyright (c) 2011 ip2k. See LICENSE.txt for
further details.

til by ip2k is licensed under a Creative Commons-Attribution-NonCommercial-ShareAlike 3.0 Unported License.
35 changes: 4 additions & 31 deletions Rakefile
Expand Up @@ -15,39 +15,12 @@ require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "todayilearned"
gem.executables = ['til']
gem.homepage = "http://github.com/ip2k/todayilearned"
gem.license = "MIT"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
gem.license = "Creative Commons by-nc-sa"
gem.summary = 'TIL is a "Today, I learned..." tool to record things you found interesting and show them to you later'
gem.description = 'TIL stands for "Today, I learned..." and helps you keep track of things you\'ve learned and stores them in a SQLite file. It\'ll also reward you for making new entries by showing you things you\'ve learned in the past.'
gem.email = "github@seanp2k.endjunk.com"
gem.authors = ["ip2k"]
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new

require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end

require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
test.rcov_opts << '--exclude "gems/*"'
end

task :default => :test

require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "todayilearned #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
0.1.1
37 changes: 37 additions & 0 deletions bin/til
@@ -0,0 +1,37 @@
#!/usr/bin/env ruby
require 'sqlite3'

# set our filename and path names up
DBNAME = 'til.sqlite' # filename for SQLite DB
DBPATH = '~/.til/' # with trailing slash

# computed paths
FULL_PATH = File.expand_path( DBPATH )
FULL_NAME = File.expand_path( DBPATH + DBNAME )

# sort our our directory
begin
Dir.mkdir( FULL_PATH ) unless File::directory?( FULL_PATH )
rescue
abort "Can't create directory: #{FULL_PATH}. Maybe it's already a file or exists but isn't writable by you?"
end

db = SQLite3::Database.new( FULL_NAME )

puts 'What did you learn today? Press ^d (ctrl+d) when done.'
til = STDIN.read # let the user type and insert \n or whatever. We only stop on ^d
db.transaction do |db| # wrap it in a nice clean transaction that rolls back upon failure
db.execute( 'CREATE TABLE IF NOT EXISTS til (id INTEGER PRIMARY KEY, time INTEGER, data TEXT)' ) # set up the table if it isn't there
db.execute( 'INSERT INTO til (time,data) VALUES (?,?)', Time.now.to_i, til ) # store the entry
puts "=> Saved!\n" # tell the user that we stored the entry if nothing failed
end

# show 3 random past entries
3.times do
db.transaction do |db|
max = db.get_first_value( 'SELECT MAX(id) from til' ) # find out how many entries are in the db
max = Random.rand(1..max) # pick a random one between 1 and the highest ID
past = db.execute( 'SELECT time,data FROM til WHERE id=?', max.to_i).flatten # get the entry (as an array, but flatten it)
puts "On #{Time.at(past[0])} you learned #{past[1]}\n" # print out what you learned in the past :)
end
end
Empty file removed lib/todayilearned.rb
Empty file.
18 changes: 0 additions & 18 deletions test/helper.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/test_todayilearned.rb

This file was deleted.

55 changes: 55 additions & 0 deletions todayilearned.gemspec
@@ -0,0 +1,55 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{todayilearned}
s.version = "0.1.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = [%q{ip2k}]
s.date = %q{2011-09-07}
s.description = %q{TIL stands for "Today, I learned..." and helps you keep track of things you've learned and stores them in a SQLite file. It'll also reward you for making new entries by showing you things you've learned in the past.}
s.email = %q{github@seanp2k.endjunk.com}
s.executables = [%q{til}]
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
s.files = [
".document",
"Gemfile",
"Gemfile.lock",
"LICENSE.txt",
"README.rdoc",
"Rakefile",
"VERSION",
"bin/til",
"til.gemspec"
]
s.homepage = %q{http://github.com/ip2k/todayilearned}
s.licenses = [%q{Creative Commons by-nc-sa}]
s.require_paths = [%q{lib}]
s.rubygems_version = %q{1.8.5}
s.summary = %q{TIL is a "Today, I learned..." tool to record things you found interesting and show them to you later}

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
else
s.add_dependency(%q<sqlite3>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
end
else
s.add_dependency(%q<sqlite3>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
end
end

0 comments on commit 0e45e6f

Please sign in to comment.