currently 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  pkg/*
2
+ .rvmrc
3
+ tmp/*
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ currently (0.0.1)
5
+ catch
6
+ trollop
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ addressable (2.2.6)
12
+ aruba (0.4.6)
13
+ bcat (>= 0.6.1)
14
+ childprocess (>= 0.2.0)
15
+ cucumber (>= 1.0.2)
16
+ rdiscount (>= 1.6.8)
17
+ rspec (>= 2.6.0)
18
+ bcat (0.6.1)
19
+ rack (~> 1.0)
20
+ builder (3.0.0)
21
+ catch (0.0.7)
22
+ faraday_middleware (~> 0.6)
23
+ hashie (~> 1.0.0)
24
+ multi_json (~> 1.0.0)
25
+ childprocess (0.2.1)
26
+ ffi (~> 1.0.6)
27
+ cucumber (1.0.2)
28
+ builder (>= 2.1.2)
29
+ diff-lcs (>= 1.1.2)
30
+ gherkin (~> 2.4.5)
31
+ json (>= 1.4.6)
32
+ term-ansicolor (>= 1.0.5)
33
+ diff-lcs (1.1.2)
34
+ faraday (0.7.4)
35
+ addressable (~> 2.2.6)
36
+ multipart-post (~> 1.1.0)
37
+ rack (< 2, >= 1.1.0)
38
+ faraday_middleware (0.7.0)
39
+ faraday (~> 0.7.3)
40
+ ffi (1.0.9)
41
+ gherkin (2.4.14)
42
+ json (>= 1.4.6)
43
+ hashie (1.0.0)
44
+ json (1.5.3)
45
+ multi_json (1.0.3)
46
+ multipart-post (1.1.3)
47
+ rack (1.3.2)
48
+ rdiscount (1.6.8)
49
+ rspec (2.6.0)
50
+ rspec-core (~> 2.6.0)
51
+ rspec-expectations (~> 2.6.0)
52
+ rspec-mocks (~> 2.6.0)
53
+ rspec-core (2.6.4)
54
+ rspec-expectations (2.6.0)
55
+ diff-lcs (~> 1.1.2)
56
+ rspec-mocks (2.6.0)
57
+ term-ansicolor (1.0.6)
58
+ trollop (1.16.2)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ aruba
65
+ currently!
data/README.markdown CHANGED
@@ -26,12 +26,16 @@ You can add multiple tags (contexts) to `currently` by using the `-c` flag; you
26
26
 
27
27
  Of course, there are some fun uses for the data (plotting what times of the day you're most active, etc) so your old entries are stored. You can view the last *n* entries with the `-n` option: `currently -n 5`
28
28
 
29
+ To Install
30
+ ----------
31
+
32
+ gem install currently
29
33
 
30
34
  Todo
31
35
  ----
32
36
  * read/write configs from `~/.currentlyrc`
33
37
  * write to `~/.currentlog`
34
- * catch.com integration
38
+ * catch.com integration (including offline storage until connectivity is up?)
35
39
  * show awesomeWM wibox example
36
40
  * auto-infer location tags from geolocation API
37
41
  * color output
data/Rakefile CHANGED
@@ -12,6 +12,8 @@ task :default do
12
12
  puts " to run after installing, run `currently`"
13
13
  puts " to clean packages, run `rake clobber`"
14
14
  puts
15
+ puts " to test: rake build && rake install && cucumber"
16
+ puts
15
17
  puts " for more tasks run `rake -T`"
16
18
  puts
17
19
  end
data/bin/currently CHANGED
File without changes
data/currently.gemspec CHANGED
@@ -26,5 +26,7 @@ Gem::Specification.new do |s|
26
26
 
27
27
  # specify any dependencies here; for example:
28
28
  # s.add_development_dependency "rspec"
29
- # s.add_runtime_dependency "rest-client"
29
+ s.add_runtime_dependency "trollop"
30
+ s.add_runtime_dependency "catch"
31
+ s.add_development_dependency "aruba"
30
32
  end
@@ -0,0 +1,9 @@
1
+ # this is a silly language
2
+ # let's look into not using pseudo-english for everything
3
+ Feature: basic CLI commands
4
+
5
+ Scenario: getting help
6
+ When I run `currently --help`
7
+ Then the exit status should be 0
8
+ And the output should contain "usage"
9
+ And the output should contain "currently"
@@ -0,0 +1,25 @@
1
+ Feature: basic filestore usage
2
+
3
+ Scenario: no file
4
+ Given an empty file named "test/scratch/currentlog"
5
+ When I remove the file "test/scratch/currentlog"
6
+ And I run `currently -f test/scratch/currentlog`
7
+ Then the exit status should be 0
8
+ And the output should contain "entry log is empty"
9
+ And the file "~/.currentlog" should not exist
10
+
11
+ Scenario: empty file
12
+ Given an empty file named "test/scratch/currentlog"
13
+ When I run `currently -f test/scratch/currentlog`
14
+ Then the exit status should be 0
15
+ And the output should contain "entry log is empty"
16
+
17
+ Scenario: write one
18
+ Given an empty file named "test/scratch/currentlog"
19
+ When I remove the file "test/scratch/currentlog"
20
+ And I run `currently -f test/scratch/currentlog test data`
21
+ And I run `currently -f test/scratch/currentlog`
22
+ Then the exit status should be 0
23
+ And the output should contain exactly "test data\n"
24
+ And a file named "test/scratch/currentlog" should exist
25
+ And the file "test/scratch/currentlog" should contain "test data"
@@ -0,0 +1 @@
1
+ require 'aruba/cucumber'
data/lib/currently.rb CHANGED
@@ -1,4 +1,7 @@
1
- require "currently/version"
1
+ require 'currently/version'
2
+ require 'currently/filestore'
3
+ require 'currently/catchstore'
4
+ require 'trollop'
2
5
 
3
6
  module Currently
4
7
  class << self
@@ -9,7 +12,56 @@ module Currently
9
12
 
10
13
  class Application
11
14
  def run
12
- puts "currently hasn't been written yet!"
15
+ opts = Trollop::options do
16
+ version "currently v#{VERSION} (c) 2011 Mike Stipicevic"
17
+ banner <<-EOS
18
+ currently is a 'concentration log' designed to keep track of what you
19
+ are working or thinking about right at this moment.
20
+
21
+ usage:
22
+ currently [options] [entry]
23
+
24
+ leaving out an entry will display the last one entered
25
+
26
+ available [options] are:
27
+ EOS
28
+
29
+ opt :filestore, "use local filestore", :type => :string
30
+ opt :context, "select a context (work, home, etc)", :type => :string
31
+ opt :catch, "use catch, specify username:password", :type => :string
32
+ end
33
+
34
+ unless opts[:catch]
35
+ fname = ENV["HOME"] + "/.currentlog"
36
+ fname = opts[:filestore] if opts[:filestore]
37
+ backingstore = Filestore.new(fname)
38
+ else
39
+ user = opts[:catch].split(":")[0]
40
+ Trollop::die :catch, "must be in the format: username:password" if opts[:catch].split(":").length < 2
41
+ pw = opts[:catch].split(":")[1]
42
+ backingstore = Catchstore.new(user,pw)
43
+ end
44
+
45
+ if ARGV.count > 0
46
+ text = ARGV.join(" ")
47
+ if opts[:context]
48
+ ent = Entry.new(text,[opts[:context]])
49
+ else
50
+ ent = Entry.new(text)
51
+ end
52
+ backingstore.save(ent)
53
+ else
54
+ if opts[:context]
55
+ last = backingstore.last(1,opts[:context])
56
+ else
57
+ last = backingstore.last
58
+ end
59
+ if last.count > 0 then
60
+ puts last.first.to_s
61
+ else
62
+ puts "[ entry log is empty ]"
63
+ end
64
+ end
13
65
  end
14
66
  end
15
67
  end
@@ -0,0 +1,18 @@
1
+ module Currently
2
+ class Backingstore
3
+ # retrieves last n entries
4
+ def last(n = 1, context = nil)
5
+ raise "not implemented!"
6
+ end
7
+
8
+ # retrieves all entries (or as many as can be found)
9
+ def all
10
+ raise "not implemented!"
11
+ end
12
+
13
+ # saves the provided entry
14
+ def save(entry)
15
+ raise "not implemented!"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ require 'currently/backingstore'
2
+ require 'currently/entry'
3
+ require 'catch'
4
+
5
+ module Currently
6
+ class Catchstore < Backingstore
7
+ def initialize(user,pass)
8
+ @catch = Catch::Client.new(:username => user, :password => pass)
9
+ @context = "#iac"
10
+ end
11
+
12
+ # retrieves last n entries
13
+ def last(n = 1,context = nil)
14
+ context ||= @context
15
+ note_ids = @catch.search(context,:limit => n).map{|x| x["id"].to_i}
16
+ ents = note_ids.map{|x|
17
+ e = @catch.note(x)
18
+ # Entry.new(e["text"],e["tags"],e["created_at"])
19
+ # tags are already in the text, we don't want dupes
20
+ Entry.new(e["text"],[],e["created_at"])
21
+ }
22
+ ents
23
+ end
24
+
25
+ # retrieves all entries (or as many as can be found)
26
+ def all
27
+ super
28
+ end
29
+
30
+ # saves the provided entry
31
+ def save(entry)
32
+ @catch.add_note(:text => entry.to_s + " #{@context}")
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module Currently
2
+ class Entry
3
+ def initialize(text,contexts = [],ts = Time.now.to_s)
4
+ @text = text
5
+ @contexts = contexts
6
+ @timestamp = ts
7
+ end
8
+
9
+ def to_s
10
+ @text + @contexts.map{|x| "#" + x}.join(" ")
11
+ end
12
+
13
+ # put this into sep module?
14
+ def serialize_to_line
15
+ @timestamp.to_s + "| " + @text + " " + @contexts.map{|x| "#" + x}.join(" ")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,53 @@
1
+ require 'currently/backingstore'
2
+ require 'currently/entry'
3
+
4
+ module Currently
5
+ class Filestore < Backingstore
6
+ def initialize(filename)
7
+ # raise "log file #{filename} doesn't exist!" unless File.exists? filename
8
+ @filename = filename
9
+ end
10
+
11
+ # retrieves last n entries
12
+ def last(n = 1)
13
+ self.parse.last n
14
+ end
15
+
16
+ # retrieves all entries (or as many as can be found)
17
+ def all
18
+ self.parse
19
+ end
20
+
21
+ # saves the provided entry
22
+ def save(entry)
23
+ File.open(@filename,"a"){|f|
24
+ f.puts entry.serialize_to_line
25
+ }
26
+ end
27
+
28
+ def parse
29
+ # sloooooooow
30
+ entries = []
31
+ return entries unless File.exists? @filename
32
+ File.open(@filename) {|f|
33
+ f.readlines.each{|l|
34
+ chunks = l.split("|")
35
+ ts = chunks[0]
36
+ rest = chunks[1..-1].join("|").split(" ")
37
+ contexts = []
38
+ rest.reverse.each {|c|
39
+ if c =~ /^\#.+/
40
+ contexts << c[1..-1]
41
+ else
42
+ break
43
+ end
44
+ }
45
+ contexts = contexts.reverse
46
+ text = rest[0..-(contexts.length + 1)].join(" ")
47
+ entries << Entry.new(text,contexts,ts)
48
+ }
49
+ entries
50
+ }
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Currently
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currently
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,9 +9,41 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-20 00:00:00.000000000 -07:00
13
- default_executable:
14
- dependencies: []
12
+ date: 2011-08-21 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: trollop
16
+ requirement: &86045460 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *86045460
25
+ - !ruby/object:Gem::Dependency
26
+ name: catch
27
+ requirement: &86045250 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *86045250
36
+ - !ruby/object:Gem::Dependency
37
+ name: aruba
38
+ requirement: &86045040 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *86045040
15
47
  description: ! " 'currently' is a console application designed to keep a running
16
48
  'concentration log'\n of what you are currently doing in the moment. It is ideal
17
49
  for capturing your thoughts\n at work before the weekend so you're ready to go
@@ -27,14 +59,22 @@ files:
27
59
  - .gitignore
28
60
  - COPYING
29
61
  - Gemfile
62
+ - Gemfile.lock
30
63
  - README.markdown
31
64
  - Rakefile
32
65
  - bin/currently
33
66
  - currently.gemspec
67
+ - features/basic_cli_usage.feature
68
+ - features/basic_file_usage.feature
69
+ - features/support/env.rb
34
70
  - lib/currently.rb
71
+ - lib/currently/backingstore.rb
72
+ - lib/currently/catchstore.rb
73
+ - lib/currently/entry.rb
74
+ - lib/currently/filestore.rb
35
75
  - lib/currently/version.rb
36
76
  - pkg/.gitignore
37
- has_rdoc: true
77
+ - tmp/aruba/.gitignore
38
78
  homepage: https://github.com/wickedchicken/i_am_currently
39
79
  licenses: []
40
80
  post_install_message:
@@ -55,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
95
  version: '0'
56
96
  requirements: []
57
97
  rubyforge_project: currently
58
- rubygems_version: 1.6.2
98
+ rubygems_version: 1.8.6
59
99
  signing_key:
60
100
  specification_version: 3
61
101
  summary: the 'currently' concentration log application