iu-test-factory 0.5.4.2 → 0.6.0.beta1

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
  SHA256:
3
- metadata.gz: f3ea4ae667f09f498f06cc42c864ce19f6b58889d06773003f6c7fff485df5c7
4
- data.tar.gz: 9b17a101a1912e39c194bb2b1f1308b1829ebf23353d4f717654bb1eeb4b496b
3
+ metadata.gz: a47aae2444f66ca3df346880ec19109a5980a9a6dd8c94691feddf848c47c525
4
+ data.tar.gz: 052d6b9d9a41afbfeb865b26925023e3ef41f678d3cd2a252670fa222e7468ad
5
5
  SHA512:
6
- metadata.gz: b246c41552684f183328d2727480118eb01959ee62105e1ba2d6bdd1b2af0167edc0f5a880b10e7126458dc7930cee83cee0364a66a015f0bcddc1014abd2015
7
- data.tar.gz: '009c47f65b12af13855013d6db260c90bd5705947399028ca6aec55f3ac4cd3ac07f9b972a258dbd902663913ec41e18151936989682637e7fe89548de8b03a0'
6
+ metadata.gz: 90a784cda93203a63b0cda6c6a55b1e33f0c0bd79e46647fe5ee78bfc081bd60536af6045c3b17634813f79a6077945a5c95bcd9bf7283399b1a772145f1a429
7
+ data.tar.gz: 8657ed5d48739d53d1a5af937c758eab122697a763a5939fd33bf7a133e5cbc50df49c5eb6fc0dd0dc7f79958cd0aef6c41f8b2700698839a5a9d029e0e67dff
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gem 'watir', '>=6.0.0'
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'watir', '~> 7.0'
4
6
 
5
7
  gemspec
data/Gemfile.lock CHANGED
@@ -1,28 +1,32 @@
1
- PATH
2
- remote: .
3
- specs:
4
- test-factory (0.5.4)
5
- watir (>= 6.0.0)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- childprocess (0.8.0)
11
- ffi (~> 1.0, >= 1.0.11)
12
- ffi (1.9.18)
13
- rubyzip (1.2.1)
14
- selenium-webdriver (3.7.0)
15
- childprocess (~> 0.5)
16
- rubyzip (~> 1.0)
17
- watir (6.9.0)
18
- selenium-webdriver (~> 3.4, >= 3.4.1)
19
-
20
- PLATFORMS
21
- ruby
22
-
23
- DEPENDENCIES
24
- test-factory!
25
- watir (>= 6.0.0)
26
-
27
- BUNDLED WITH
28
- 1.15.4
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ iu-test-factory (0.6.0.beta1)
5
+ watir (~> 7.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ childprocess (4.1.0)
11
+ regexp_parser (2.7.0)
12
+ rexml (3.2.5)
13
+ rubyzip (2.3.2)
14
+ selenium-webdriver (4.3.0)
15
+ childprocess (>= 0.5, < 5.0)
16
+ rexml (~> 3.2, >= 3.2.5)
17
+ rubyzip (>= 1.2.2, < 3.0)
18
+ websocket (~> 1.0)
19
+ watir (7.2.2)
20
+ regexp_parser (>= 1.2, < 3)
21
+ selenium-webdriver (~> 4.2)
22
+ websocket (1.2.9)
23
+
24
+ PLATFORMS
25
+ x64-mingw-ucrt
26
+
27
+ DEPENDENCIES
28
+ iu-test-factory!
29
+ watir (~> 7.0)
30
+
31
+ BUNDLED WITH
32
+ 2.3.22
Binary file
@@ -1,13 +1,14 @@
1
- spec = Gem::Specification.new do |s|
1
+ Gem::Specification.new do |s|
2
2
  s.name = 'iu-test-factory'
3
- s.version = '0.5.4.2'
4
- s.summary = %q{framework for creating automated testing scripts}
5
- s.description = %q{This gem provides a set of modules and methods to help quickly and DRYly create a test automation framework using Ruby and Watir.}
6
- s.files = Dir.glob("**/**/**")
7
- s.test_files = Dir.glob("test/*test_rb")
8
- s.authors = ['Abraham Heward']
9
- s.email = %w{aheward@rsmart.com}
3
+ s.version = '0.6.0.beta1'
4
+ s.summary = 'framework for creating automated testing scripts'
5
+ s.description = 'This gem provides a set of modules and methods to help quickly and DRYly create a test \
6
+ automation framework using Ruby and Watir.'
7
+ s.files = Dir.glob('**/**/**')
8
+ s.test_files = Dir.glob('test/*test_rb')
9
+ s.authors = ['Abraham Heward', 'David Elyea', 'Megha Ramawat']
10
+ s.email = %w[aheward@rsmart.com]
10
11
  s.homepage = 'https://github.iu.edu/iu-uits-es'
11
- s.add_dependency 'watir', '>= 6.0.0'
12
- s.required_ruby_version = '>= 2.0.0'
12
+ s.add_dependency 'watir', '~> 7.0'
13
+ s.required_ruby_version = '~> 3.1'
13
14
  end
@@ -21,7 +21,7 @@ class PageFactory
21
21
  # As the PageFactory will be the superclass for all your page classes, having this initialize
22
22
  # method here means it's only written once.
23
23
  #
24
- def initialize browser, visit = false
24
+ def initialize(browser, visit = false)
25
25
  @browser = browser
26
26
  goto if visit
27
27
  expected_element if respond_to? :expected_element
@@ -32,7 +32,7 @@ class PageFactory
32
32
  # that Watir will take care of parsing them, so the assumption is that the method being
33
33
  # passed is a valid method for the browser object.
34
34
  #
35
- def method_missing sym, *args, &block
35
+ def method_missing(sym, *args, &block)
36
36
  @browser.send sym, *args, &block
37
37
  end
38
38
 
@@ -41,7 +41,7 @@ class PageFactory
41
41
  # Define this in a page class and when you use the "visit" method to instantiate the class
42
42
  # it will enter the URL in the browser's address bar.
43
43
  #
44
- def page_url url
44
+ def page_url(url)
45
45
  define_method 'goto' do
46
46
  @browser.goto url
47
47
  end
@@ -51,7 +51,7 @@ class PageFactory
51
51
  # element appears on the page before continuing with the script.
52
52
  # @param element_name [Symbol] The method name of the element that must be present on the page
53
53
  #
54
- def expected_element element_name, timeout=30
54
+ def expected_element(element_name, timeout = 30)
55
55
  define_method 'expected_element' do
56
56
  self.send(element_name).wait_until_present timeout: timeout
57
57
  end
@@ -62,7 +62,7 @@ class PageFactory
62
62
  # error and halts the script.
63
63
  # @param expected_title [String] The exact text that is expected to appear in the Browser title when the page loads
64
64
  #
65
- def expected_title expected_title
65
+ def expected_title(expected_title)
66
66
  define_method 'has_expected_title?' do
67
67
  has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title
68
68
  raise "Expected title '#{expected_title}' instead of '#{@browser.title}'" unless has_expected_title
@@ -81,7 +81,7 @@ class PageFactory
81
81
  # action(:continue) { |b| b.frm.button(:value=>"Continue").click } => Creates a #continue method that clicks the Continue button
82
82
  # p_element(:select_style) { |stylename, b| b.div(:text=>/#{Regexp.escape(stylename)}/).link(:text=>"Select").click } => #select_style(stylename)
83
83
  #
84
- def element name, &block
84
+ def element(name, &block)
85
85
  raise "#{name} is being defined twice in #{self}!" if self.instance_methods.include?(name.to_sym)
86
86
  define_method name.to_s do |*thing|
87
87
  Proc.new(&block).call *thing, self
@@ -116,7 +116,7 @@ class PageFactory
116
116
  # @example
117
117
  # link("Click Me For Fun!", :click_me) => Creates the methods #click_me and #click_me_link
118
118
  #
119
- def link link_text, *alias_name
119
+ def link(link_text, *alias_name)
120
120
  elementize(:link, link_text, *alias_name)
121
121
  end
122
122
 
@@ -143,7 +143,7 @@ class PageFactory
143
143
  # @example
144
144
  # link("Click Me For Fun!", :click_me) => Creates the methods #click_me and #click_me_link
145
145
  #
146
- def button button_text, *alias_name
146
+ def button(button_text, *alias_name)
147
147
  elementize(:button, button_text, *alias_name)
148
148
  end
149
149
 
@@ -168,11 +168,11 @@ class PageFactory
168
168
  # @example
169
169
  # undefine :status, :doc_id => Undefines the specified methods in the current class
170
170
  #
171
- def undefine *methods
171
+ def undefine(*methods)
172
172
  methods.each{ |m| undef_method m }
173
173
  end
174
174
 
175
- def inherited klass
175
+ def inherited(klass)
176
176
  klass.instance_eval {
177
177
 
178
178
  # Creates a method, #wait_for_ajax, usable in your Page Classes, that executes
@@ -181,7 +181,7 @@ class PageFactory
181
181
  # If timeout is exceeded, raises Watir::Wait::TimeoutError exception. The returned error
182
182
  # message is customizable.
183
183
  #
184
- define_method 'wait_for_ajax' do |timeout=10, message|
184
+ define_method 'wait_for_ajax' do |timeout = 10, message|
185
185
  timeout.times do
186
186
  sleep 0.3
187
187
  return true if @browser.execute_script('return jQuery.active').to_i == 0
@@ -197,11 +197,11 @@ class PageFactory
197
197
  # A helper method that converts the passed string into snake case. See the StringFactory
198
198
  # module for more info.
199
199
  #
200
- def damballa text
200
+ def damballa(text)
201
201
  StringFactory.damballa(text)
202
202
  end
203
203
 
204
- def elementize type, text, *alias_name
204
+ def elementize(type, text, *alias_name)
205
205
  hash={:link=>:text, :button=>:value}
206
206
  if alias_name.empty?
207
207
  el_name=damballa("#{text}_#{type}")
@@ -164,4 +164,4 @@ module StringFactory
164
164
  end
165
165
  module_function :damballa
166
166
 
167
- end
167
+ end
@@ -1,16 +1,19 @@
1
- module TestFactory
1
+ # frozen_string_literal: true
2
2
 
3
+ # Module to define full TestFactory binary tranform
4
+ module TestFactory
3
5
  def self.binary_transform(var)
4
- case(var)
5
- when nil
6
- nil
7
- when /yes/i, /on/i, :set, true
8
- :set
9
- when /no/i, /off/i, :clear, false
10
- :clear
11
- else
12
- raise "The value of your DataObject's checkbox/radio ('#{var}') instance variable is not supported.\nPlease make sure the value conforms to one of the following patterns:\n\n - :set or :clear (Symbol)\n - 'yes', 'no', 'on', or 'off' (String; case insensitive)\n - true or false (Boolean)"
6
+ case var
7
+ when nil
8
+ nil
9
+ when /yes/i, /on/i, :set, true
10
+ :set
11
+ when /no/i, /off/i, :clear, false
12
+ :clear
13
+ else
14
+ raise "The value of your DataObject's checkbox/radio ('#{var}') instance variable is not supported.\n /
15
+ Please make sure the value conforms to one of the following patterns:\n\n - :set or :clear (Symbol)\n /
16
+ - 'yes', 'no', 'on', or 'off' (String; case insensitive)\n - true or false (Boolean)"
13
17
  end
14
18
  end
15
-
16
- end
19
+ end
data/lib/test-factory.rb CHANGED
@@ -14,5 +14,5 @@
14
14
 
15
15
  require 'watir'
16
16
  require 'forwardable'
17
- %w{foundry.rb data_factory.rb}.each { |f| require "#{File.dirname(__FILE__)}/test-factory/#{f}" }
18
- Dir["#{File.dirname(__FILE__)}/test-factory/*.rb"].each {|f| require f }
17
+ %w[foundry.rb data_factory.rb].each { |f| require "#{File.dirname(__FILE__)}/test-factory/#{f}" }
18
+ Dir["#{File.dirname(__FILE__)}/test-factory/*.rb"].each { |f| require f }
metadata CHANGED
@@ -1,31 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iu-test-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4.2
4
+ version: 0.6.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abraham Heward
8
+ - David Elyea
9
+ - Megha Ramawat
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
13
+ date: 2023-03-21 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: watir
15
17
  requirement: !ruby/object:Gem::Requirement
16
18
  requirements:
17
- - - ">="
19
+ - - "~>"
18
20
  - !ruby/object:Gem::Version
19
- version: 6.0.0
21
+ version: '7.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
- - - ">="
26
+ - - "~>"
25
27
  - !ruby/object:Gem::Version
26
- version: 6.0.0
27
- description: This gem provides a set of modules and methods to help quickly and DRYly
28
- create a test automation framework using Ruby and Watir.
28
+ version: '7.0'
29
+ description: |-
30
+ This gem provides a set of modules and methods to help quickly and DRYly create a test \
31
+ automation framework using Ruby and Watir.
29
32
  email:
30
33
  - aheward@rsmart.com
31
34
  executables: []
@@ -37,12 +40,11 @@ files:
37
40
  - Gemfile.lock
38
41
  - LICENSE
39
42
  - README.md
43
+ - iu-test-factory-0.6.0.0.gem.old
40
44
  - iu-test-factory.gemspec
41
45
  - lib/test-factory.rb
42
46
  - lib/test-factory/collections_factory.rb
43
- - lib/test-factory/core_ext.rb
44
47
  - lib/test-factory/data_factory.rb
45
- - lib/test-factory/date_factory.rb
46
48
  - lib/test-factory/foundry.rb
47
49
  - lib/test-factory/gem_ext.rb
48
50
  - lib/test-factory/page_factory.rb
@@ -57,16 +59,16 @@ require_paths:
57
59
  - lib
58
60
  required_ruby_version: !ruby/object:Gem::Requirement
59
61
  requirements:
60
- - - ">="
62
+ - - "~>"
61
63
  - !ruby/object:Gem::Version
62
- version: 2.0.0
64
+ version: '3.1'
63
65
  required_rubygems_version: !ruby/object:Gem::Requirement
64
66
  requirements:
65
- - - ">="
67
+ - - ">"
66
68
  - !ruby/object:Gem::Version
67
- version: '0'
69
+ version: 1.3.1
68
70
  requirements: []
69
- rubygems_version: 3.0.3
71
+ rubygems_version: 3.3.7
70
72
  signing_key:
71
73
  specification_version: 4
72
74
  summary: framework for creating automated testing scripts
@@ -1,133 +0,0 @@
1
- # Copyright 2012-2014 The rSmart Group, Inc.
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
-
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- class Time
16
-
17
- # Using the :year_range option (or no option), this method creates a
18
- # Time object of a random value, within
19
- # the year range specified (default is 5 years in the past).
20
- #
21
- # Using the :series option, this method returns an array
22
- # containing a randomized Time object as its first element (limited by
23
- # the specified :year_range value). Subsequent elements will be Time objects
24
- # with values putting them later than the prior element, within the specified
25
- # range value (see examples).
26
- #
27
- # Usage Examples:
28
- # @example
29
- # a random date...
30
- # ?> Time.random
31
- # => Tue Aug 05 00:00:00 EDT 2007
32
- #
33
- # birthdays, anyone?...
34
- # 5.times { p Time.random(:year_range=>80) }
35
- # Wed Feb 06 00:00:00 EDT 1974
36
- # Tue Dec 22 00:00:00 EST 1992
37
- # Fri Apr 14 00:00:00 EWT 1944
38
- # Thu Jul 01 00:00:00 EDT 1993
39
- # Wed Oct 02 00:00:00 EDT 2002
40
- #
41
- # A series of dates are useful for account-related info...
42
- # ?> Time.random(:series=>[20.days, 3.years])
43
- # => [Sat Jan 22 00:00:00 EST 2005,
44
- # Sat Jan 29 12:58:45 EST 2005,
45
- # Fri Sep 08 09:34:58 EDT 2006]
46
- #
47
- # or maybe to simulate events during an hour?...
48
- # ?> Time.random(:series=>[1.hour,1.hour,1.hour])
49
- # => [Wed Apr 21 00:00:00 EDT 2004,
50
- # Wed Apr 21 00:45:59 EDT 2004,
51
- # Wed Apr 21 01:02:47 EDT 2004,
52
- # Wed Apr 21 01:31:00 EDT 2004]
53
- #
54
- def self.random(params={})
55
- years_back = params[:year_range] || 5
56
- year = (rand * (years_back)).ceil + (Time.now.year - years_back)
57
- month = (rand * 12).ceil
58
- day = (rand * 31).ceil
59
- series = [date = Time.local(year, month, day)]
60
- if params[:series]
61
- params[:series].each do |some_time_after|
62
- series << series.last + (rand * some_time_after).ceil
63
- end
64
- return series
65
- end
66
- date
67
- end
68
-
69
- end # Time
70
-
71
- module Enumerable
72
-
73
- # Use for getting a natural sort order instead of the ASCII
74
- # sort order.
75
- #
76
- def alphabetize
77
- sort { |a, b| grouped_compare(a, b) }
78
- end
79
-
80
- # Use for sorting an Enumerable object in place.
81
- #
82
- def alphabetize!
83
- sort! { |a, b| grouped_compare(a, b) }
84
- end
85
-
86
- private
87
-
88
- def grouped_compare(a, b)
89
- loop {
90
- a_chunk, a = extract_alpha_or_number_group(a)
91
- b_chunk, b = extract_alpha_or_number_group(b)
92
- ret = a_chunk <=> b_chunk
93
- return -1 if a_chunk == ''
94
- return ret if ret != 0
95
- }
96
- end
97
-
98
- def extract_alpha_or_number_group(item)
99
- test_item = item.downcase
100
- matchdata = /([a-z]+|[\d]+)/.match(test_item)
101
- if matchdata.nil?
102
- ["", ""]
103
- else
104
- [matchdata[0], test_item = test_item[matchdata.offset(0)[1] .. -1]]
105
- end
106
- end
107
-
108
- end # Enumerable
109
-
110
- class Numeric
111
-
112
- # Converts a number object to a string containing commas every 3rd digit. Adds
113
- # trailing zeroes if necessary to match round currency amounts.
114
- def commas
115
- self.to_s =~ /([^\.]*)(\..*)?/
116
- int, dec = $1.reverse, $2 ? ('%.2f' % $2).to_s[/.\d+$/] : ".00"
117
- while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3')
118
- end
119
- int.reverse + dec
120
- end
121
-
122
- end # Numeric
123
-
124
- class String
125
-
126
- # Used to remove commas and dollar signs from long number strings,
127
- # then converting the result to a Float so that it
128
- # can be used in calculations.
129
- def groom
130
- self.gsub(/[$,]/,'').to_f
131
- end
132
-
133
- end # String
@@ -1,158 +0,0 @@
1
- # Copyright 2012-2014 The rSmart Group, Inc.
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
-
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- # Some date and time helper functions....
16
- module DateFactory
17
-
18
- MONTHS = %w{JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC}
19
-
20
- # Takes a time object and returns a hash containing
21
- # various parts of the relevant date.
22
- # @param time_object [Time] the moment you want to convert
23
- # @returns [Hash] a hash object containing various parts of the date/time you passed to the method
24
- #
25
- def date_factory(time_object)
26
- {
27
- sakai: make_date(time_object),
28
- sakai_rounded: make_date(time_object).gsub!(/:\d+/, ":#{Time.at(time_object.to_i/(5*60)*(5*60)).strftime("%M")}"), # Date with time rounded to nearest 5-minute mark.
29
- short_date: time_object.strftime("%b %-d, %Y"), # => "Oct 18, 2013"
30
- samigo: time_object.strftime("%m/%d/%Y %I:%M:%S %p"), # => "10/30/2012 07:02:05 AM"
31
- MON: time_object.strftime("%^b"), # => "DEC"
32
- Mon: time_object.strftime("%b"), # => "Jan"
33
- Month: time_object.strftime("%B"), # => "February"
34
- month_int: time_object.month, # => 3
35
- day_of_month: time_object.day, # => 17 Note this is not zero-padded
36
- weekday: time_object.strftime("%A"), # => "Monday"
37
- wkdy: time_object.strftime("%a"), # => "Tue"
38
- year: time_object.year, # => 2013
39
- hour: time_object.strftime("%I").to_i, # => "07" Zero-padded, 12-hour clock
40
- minute: time_object.strftime("%M"), # => "02" Zero-padded
41
- minute_rounded: (Time.at(time_object.to_i/(5*60)*(5*60))).strftime("%M"), # => "05" Zero-padded, rounded to 5-minute increments
42
- meridian: time_object.strftime("%P"), # => "pm"
43
- MERIDIAN: time_object.strftime("%p"), # => "AM"
44
- date_w_slashes: time_object.strftime("%m/%d/%Y"), # => 02/08/2013
45
- custom: time_object # => Allows creation of a custom date string using the passed time value.
46
- }
47
- end
48
-
49
- def an_hour_ago
50
- date_factory(Time.now - 3600)
51
- end
52
- alias last_hour an_hour_ago
53
-
54
- def right_now
55
- date_factory(Time.now)
56
- end
57
-
58
- def in_an_hour
59
- date_factory(Time.now + 3600)
60
- end
61
- alias next_hour in_an_hour
62
-
63
- def last_year
64
- date_factory(Time.now - (3600*24*365))
65
- end
66
- alias a_year_ago last_year
67
-
68
- # Returns a randomly selected date/time from
69
- # within the last year.
70
- def in_the_last_year
71
- date_factory(Time.random(:year_range=>1))
72
- end
73
-
74
- def last_month
75
- index = MONTHS.index(current_month)
76
- return MONTHS[index-1]
77
- end
78
-
79
- def hours_ago(hours)
80
- date_factory(Time.now - hours*3600)
81
- end
82
-
83
- def hours_from_now(hours)
84
- date_factory(Time.now + hours*3600)
85
- end
86
-
87
- # Takes an integer representing
88
- # the count of minutes as the parameter, and
89
- # returns the date_factory hash for the
90
- # resulting Time value.
91
- #
92
- def minutes_ago(mins)
93
- date_factory(Time.now - mins*60)
94
- end
95
-
96
- def minutes_from_now(mins)
97
- date_factory(Time.now + mins*60)
98
- end
99
-
100
- # Returns the current month as an
101
- # upper-case 3-letter string.
102
- # example: "JUL"
103
- #
104
- def current_month
105
- Time.now.strftime("%^b")
106
- end
107
-
108
- def next_month
109
- index = MONTHS.index(current_month)
110
- if index < 11
111
- return MONTHS[index+1]
112
- else
113
- return MONTHS[0]
114
- end
115
- end
116
-
117
- def in_a_year
118
- date_factory(Time.now + (3600*24*365))
119
- end
120
- alias next_year in_a_year
121
-
122
- def yesterday
123
- date_factory(Time.now - (3600*24))
124
- end
125
-
126
- def tomorrow
127
- date_factory(Time.now + (3600*24))
128
- end
129
-
130
- def in_a_week
131
- date_factory(Time.now + (3600*24*7))
132
- end
133
- alias next_week in_a_week
134
-
135
- def a_week_ago
136
- date_factory(Time.now - (3600*24*7))
137
- end
138
-
139
- def next_monday
140
- date_factory(Time.at(Time.now+(8-Time.now.wday)*24*3600))
141
- end
142
-
143
- # Formats a date string Sakai-style.
144
- # Useful for verifying creation dates and such.
145
- #
146
- # @param time_object [Time] the moment that you want converted to the string
147
- # @returns [String] a date formatted to look like this: Jun 8, 2012 12:02 pm
148
- #
149
- def make_date(time_object)
150
- month = time_object.strftime("%b ")
151
- day = time_object.strftime("%-d")
152
- year = time_object.strftime(", %Y ")
153
- mins = time_object.strftime(":%M %P")
154
- hour = time_object.strftime("%l").to_i
155
- return month + day + year + hour.to_s + mins
156
- end
157
-
158
- end