lewt 0.5.16 → 0.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c17788a1c74669a806a0a63c128a64b7494fb133
4
- data.tar.gz: d27f84a60f91bbe38ee03ee4bf02648c190be86a
3
+ metadata.gz: 414eb66e71d62400f6ea97b42eb78184e37eade6
4
+ data.tar.gz: f2c44dbc75b0b44bec33526536fd75f40d2cc891
5
5
  SHA512:
6
- metadata.gz: 0fb033c461635d67a52242416a0aa00466d3a56c29c3d936170206b340725534da3960418dfd12c9787102fab5b5384a775866a187d7493db50e08bfadf239ef
7
- data.tar.gz: cd7c1279b1db457d6fae2e346d9ad1dc78d8f1bc68123c92b8a32a7f5b8493e9b3eccb7d2ed9523dfe74aa6963ae946fccc177533e393d674ba054e6a208b50d
6
+ metadata.gz: 151f9ee0271f1f42185379d0b06cbbcc25ed3a3d6e755747067ed104110bd38be38af7e8da182b80b670845924fc00cb2a2266f609a1638a8a60f1ca8f211b18
7
+ data.tar.gz: ffc3f276180e435e06800d77b27b7f1786218e93629c6a66e737a7f823b06033c1934911bb633b88a9860ee2baa604c634f7fb7d560e2d3740c9bc59286660f8
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # LEWT v0.5.15
1
+ # LEWT v0.5.17
2
2
 
3
3
  LEWT is a command line program & library written in Ruby that can help you invoice customers, manage expenses, generate reports and much more. It is designed to encourage lazy accounting, to get more out of it, and to be extended with minimal friction.
4
4
 
@@ -188,7 +188,7 @@ lewt_invoice = LEWT::Lewt.new( options ).run
188
188
 
189
189
  LEWT by itself is basically just an extension system, all the EPR operations are performed by extensions making LEWT very customisable. Being a beta version of this software, I have shipped LEWT with some basic extension which I find useful in my day to day contracting operations but I'm hoping others will replace them with better versions in time :) these *core extensions* as I will call them for now are:
190
190
 
191
- 1. Calendar Timekeeping: Extract Time sheet data from iCal, OSX Calendar, and Google Calender sources and transform it for further processing.
191
+ 1. Calendar Timekeeping: Extract Time sheet data from iCal, and OSX Calendar sources and transform it for further processing.
192
192
  2. Simple Invoices: Process extract data as an invoice.
193
193
  3. Simple Reports: Process extract data as a report.
194
194
  4. Liquid Renderer: Liquid template rendering with support for text, html, and PDF tempting.
@@ -44,8 +44,8 @@ module CalendarExtractors
44
44
  if self.isTargetDate?(dstart) == true && target != false
45
45
  timeDiff = (dend - dstart) /60/60
46
46
  row = LEWT::LEWTLedger.new({
47
- :date_start => e.dtstart,
48
- :date_end => e.dtend,
47
+ :date_start => e.dtstart.to_time,
48
+ :date_end => e.dtend.to_time,
49
49
  :category => @category,
50
50
  :entity => target["name"],
51
51
  :description => e.description.to_s,
@@ -1,5 +1,4 @@
1
1
  load File.expand_path('../extractor.rb', __FILE__)
2
- load File.expand_path('../gcal_extractor.rb', __FILE__)
3
2
  load File.expand_path('../ical_extractor.rb', __FILE__)
4
3
  load File.expand_path('../apple_extractor.rb', __FILE__)
5
4
 
@@ -31,7 +30,7 @@ module LEWT
31
30
  options = {
32
31
  :calendar => {
33
32
  :default => "ical",
34
- :definition => "The calender extraction method to use, supports 'gcal', 'ical', 'osx' calender extraction. Defaults to ical.",
33
+ :definition => "The calender extraction method to use, supports 'ical', 'osx' calender extraction. Defaults to ical.",
35
34
  :type => String,
36
35
  },
37
36
  :suppress => {
@@ -52,8 +51,6 @@ module LEWT
52
51
  suppressTargets = options[:suppress] == nil ? nil : self.get_matched_customers(options[:suppress])
53
52
  if options[:calendar] == "ical"
54
53
  extract = CalendarExtractors::ICalExtractor.new( dStart, dEnd, targetCustomers, lewt_settings, suppressTargets )
55
- elsif options[:calendar] == "gcal"
56
- extract = CalendarExtractors::GCalExtractor.new(dStart, dEnd, targetCustomers, lewt_settings, suppressTargets )
57
54
  elsif options[:calendar] == "osx"
58
55
  extract = CalendarExtractors::AppleExtractor.new(dStart, dEnd, targetCustomers, lewt_settings, suppressTargets )
59
56
  end
@@ -34,10 +34,8 @@ module LEWT
34
34
  :type => String
35
35
  }
36
36
  }
37
-
38
37
  super({:cmd => "liquid_render", :options => options })
39
38
  end
40
-
41
39
 
42
40
  # Loads the plaint-text, html, & (optionally) pdf template files of the given template name and parses it with the Liquid class
43
41
  # template [String]:: The name of the template to load.
@@ -1,5 +1,5 @@
1
1
  require "yaml"
2
- require "securerandom"
2
+ require 'digest/sha1'
3
3
 
4
4
  # Author:: Jason Wijegooneratne (mailto:code@jwije.com)
5
5
  # Copyright:: Copyright (c) 2014 Jason Wijegooneratne
@@ -35,13 +35,15 @@ module LEWT
35
35
  protected
36
36
 
37
37
  # Generates a UID for this invoice based of the customer it is being sent to
38
- def generate_id
38
+ def generate_id(client)
39
39
  if !lewt_settings.has_key?("invoice_id_counter")
40
40
  self.write_settings("settings.yml", "invoice_id_counter", 0)
41
41
  end
42
42
  id = lewt_settings["invoice_id_counter"].to_i + 1
43
+ seed = "--#{rand(10000)}--#{Time.now}--"
44
+ uid = Digest::SHA1.hexdigest(seed)[0,4]
43
45
  self.write_settings("settings.yml", "invoice_id_counter", id)
44
- return "#{id.to_s}-" + SecureRandom.hex(4)
46
+ return "#{id.to_s}#{uid}"
45
47
  end
46
48
 
47
49
  # Generates a bill for the given client.
@@ -51,7 +53,7 @@ module LEWT
51
53
  def generateBill(client, data)
52
54
  bill = {
53
55
  "date_created" => DateTime.now.strftime("%d/%m/%y"),
54
- "id" => generate_id,
56
+ "id" => generate_id(client),
55
57
  # "date_begin"=> @events.dateBegin.strftime("%d/%m/%y"),
56
58
  # "date_end"=> @events.dateEnd.strftime("%d/%m/%y"),
57
59
  "billed_to" => client,
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
+ require 'bundler/setup'
3
4
  require 'date'
4
5
  require 'yaml'
5
6
  require 'optparse'
@@ -16,7 +17,7 @@ require_relative 'lewt_ledger.rb'
16
17
  # This module acts as a container for the LEWT namespace
17
18
  module LEWT
18
19
 
19
- VERSION = "0.5.16"
20
+ VERSION = "0.5.17"
20
21
 
21
22
  # The Lewt class contains the major functionality of this program.
22
23
  # It handles loading all extensions, gathering the results and passing options ariound the place.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lewt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.16
4
+ version: 0.5.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Wijegooneratne
@@ -9,77 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-09-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: safe_yaml
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.0.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: icalendar
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 2.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 2.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: google_calendar
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.3.1
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.3.1
55
- - !ruby/object:Gem::Dependency
56
- name: liquid
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 2.5.0
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 2.5.0
69
- - !ruby/object:Gem::Dependency
70
- name: pdfkit
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.6.2
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.6.2
12
+ dependencies: []
83
13
  description: A simple command line tool and library for enterprise management. It
84
14
  can currently handle invoicing, expenses, reporting, and is very extensible.
85
15
  email: code@jwije.com
@@ -107,7 +37,6 @@ files:
107
37
  - lib/extensions/calendar-timekeeping/apple_extractor.rb
108
38
  - lib/extensions/calendar-timekeeping/calendar-timekeeping.rb
109
39
  - lib/extensions/calendar-timekeeping/extractor.rb
110
- - lib/extensions/calendar-timekeeping/gcal_extractor.rb
111
40
  - lib/extensions/calendar-timekeeping/ical_extractor.rb
112
41
  - lib/extensions/liquid-renderer.rb
113
42
  - lib/extensions/metastat/metamath.rb
@@ -126,7 +55,6 @@ files:
126
55
  - tests/milestones.csv
127
56
  - tests/run_tests.rb
128
57
  - tests/tc_Billing.rb
129
- - tests/tc_CalExt.rb
130
58
  - tests/tc_Lewt.rb
131
59
  - tests/tc_LewtExtension.rb
132
60
  - tests/tc_LewtLedger.rb
@@ -1,61 +0,0 @@
1
- require 'google_calendar'
2
-
3
- # Author:: Jason Wijegooneratne (mailto:code@jwije.com)
4
- # Copyright:: Copyright (c) 2014 Jason Wijegooneratne
5
- # License:: MIT. See LICENSE.md distributed with the source code for more information.
6
-
7
-
8
- module CalendarExtractors
9
-
10
- # Extracts data from a Google Calender source.
11
- #
12
- # === Setup
13
- # It is required that you have a Google App setup with your account to allow for API access to your data. Then
14
- # add the following keys to your settings file.
15
- #
16
- # gmail_username:: The username for your google application.
17
- # gmail_password:: The password associated with this username.
18
- # gmail_app_name:: The name of the application you created.
19
- #
20
- class GCalExtractor < CalExtractor
21
-
22
- # Sets up this extension
23
- def initialize ( dStart, dEnd, targetCustomers, lewt_settings, suppressTargets )
24
- uname = lewt_settings["gmail_username"]
25
- pass = lewt_settings["gmail_password"]
26
- app = lewt_settings["google_app_name"]
27
- @googleCalender = Google::Calendar.new(
28
- :username => uname,
29
- :password => pass,
30
- :app_name => app
31
- )
32
- super( dStart, dEnd, targetCustomers )
33
- end
34
-
35
- # This method does the actual google calender extract, comparing events to the requested paramters.
36
- # It manipulates the @data property of this object which is used by LEWT to gather the extracted data.
37
- def extractCalendarData
38
- gConf = { :max_results => 2500, :order_by => 'starttime', :single_events => true }
39
- @googleCalender.find_events_in_range(@dateStart, @dateEnd + 1, gConf).each do |e|
40
- eStart = Time.parse( e.start_time )
41
- eEnd = Time.parse( e.end_time )
42
- timeDiff = (eEnd - eStart)/60/60
43
- target = self.isTargetCustomer?(e.title)
44
- if self.isTargetDate?( eStart ) == true && target != false
45
- row = LEWT::LEWTLedger.new({
46
- :date_start => eStart,
47
- :date_end => eEnd,
48
- :category => @category,
49
- :entity => target["name"],
50
- :description => e.content,
51
- :quantity => timeDiff,
52
- :unit_cost => target["rate"]
53
- })
54
- @data.push(row)
55
- end
56
- end
57
- end
58
-
59
- end
60
-
61
- end
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Test Cases for the Billing core extension.
4
- # ./lib/extension.rb
5
- #
6
- # Written by: jdw <4 July 2014>
7
- #
8
- # ********************************************
9
-
10
- require "test/unit"
11
-
12
- require_relative "../lib/extension.rb"
13
- require_relative "../lib/extensions/calendar-timekeeping/calendar-timekeeping.rb"
14
-
15
- class TestCalendarTimekeeping < Test::Unit::TestCase
16
-
17
- def test_initialize
18
- caltime = LEWT::CalendarTimekeeping.new
19
- assert_instance_of( LEWT::CalendarTimekeeping, caltime, "Extension CalandarTimekeeping not initialising properly." )
20
- calext = CalendarExtractors::CalExtractor.new( (DateTime.now - 8).to_s, DateTime.now.to_s, "ACME" )
21
- assert_instance_of( CalendarExtractors::CalExtractor, calext, "Extension CalandarTimekeeping sub-module CalExtractor not initialising properly." )
22
- end
23
-
24
- def test_filtering_methods
25
- calext = CalendarExtractors::CalExtractor.new( (DateTime.now - 8)::to_s, DateTime.now::to_s, LEWT::Extension.new::get_matched_customers("ACME") )
26
- assert_instance_of(Hash, calext.isTargetCustomer?("ACME"), "#{calext.class.name} not matching customer names properly.")
27
- assert_instance_of(Hash, calext.isTargetCustomer?("ACME doing some stuff"), "#{calext.class.name} not matching customer names properly.")
28
- assert_instance_of(Hash, calext.isTargetCustomer?("making thing! ACME"), "#{calext.class.name} not matching customer names properly.")
29
- assert_instance_of(Hash, calext.isTargetCustomer?("AC"), "#{calext.class.name} not matching customer alias' properly.")
30
- assert_instance_of(Hash, calext.isTargetCustomer?("AC: building stuff"), "#{calext.class.name} not matching customer alias' properly.")
31
- assert_instance_of(Hash, calext.isTargetCustomer?("creating features AC"), "#{calext.class.name} not matching customer alias' properly.")
32
- assert_equal(true, calext.isTargetDate?( DateTime.now - 2 ), "#{calext.class.name} not matching targeted dates properly.")
33
- assert_equal(false, calext.isTargetDate?( DateTime.now - 50 ), "#{calext.class.name} not ignoring un-targeted dates properly.")
34
- end
35
-
36
-
37
-
38
- end
39
-
40
-
41
-
42
-
43
-
44
-