dynarex-daily 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/dynarex-daily.rb +44 -0
  2. metadata +56 -0
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: dynarex-daily.rb
4
+
5
+ require 'dynarex'
6
+ require 'fileutils'
7
+
8
+ class DynarexDaily < Dynarex
9
+
10
+ def initialize(stringx=nil)
11
+
12
+ @filename = 'dynarexdaily.xml'
13
+ super(stringx) if stringx
14
+
15
+ if File.exist?(@filename) then
16
+ super(@filename)
17
+ if !summary[:date].empty? and \
18
+ Time.parse(summary[:date]).day != Time.now.day then
19
+ archive_file
20
+ create_file
21
+ end
22
+ else
23
+ create_file
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def create_file()
30
+
31
+ FileUtils.touch @filename
32
+
33
+ initialize('entries[date]/entry(time, desc)')
34
+ summary[:date] = Time.now.to_s
35
+ save @filename
36
+ end
37
+
38
+ def archive_file()
39
+ dir = 'days'
40
+ FileUtils.mkdir dir unless File.exist? dir
41
+ FileUtils.mv(@filename, "%s/%s" % [dir, Time.now.strftime("d%d%m%y.xml")])
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dynarex-daily
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - James Robertson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-01-10 00:00:00 +00:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email:
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/dynarex-daily.rb
27
+ has_rdoc: true
28
+ homepage:
29
+ licenses: []
30
+
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.5.2
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: dynarex-daily
55
+ test_files: []
56
+