openstax_utilities 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,9 @@ module OpenStax::Utilities
4
4
  def osu
5
5
  @@osu_class ||= Class.new(ClassyHelper) do
6
6
  include OpenStax::Utilities::Helpers::Blocks
7
+ include OpenStax::Utilities::Helpers::Partials
7
8
  include OpenStax::Utilities::Helpers::ActionList
9
+ include OpenStax::Utilities::Helpers::Datetime
8
10
  end
9
11
 
10
12
  @@osu_class.new(self)
@@ -0,0 +1,33 @@
1
+ module OpenStax::Utilities::Helpers
2
+ module Datetime
3
+
4
+ def standard_date(datetime)
5
+ datetime.nil? ?
6
+ "" :
7
+ datetime.strftime(OSU.configuration.standard_date_format)
8
+ end
9
+
10
+ def standard_datetime(datetime)
11
+ datetime.nil? ?
12
+ "" :
13
+ datetime.strftime(OSU.configuration.standard_datetime_format)
14
+ end
15
+
16
+ def standard_time(datetime)
17
+ datetime.nil? ?
18
+ "" :
19
+ datetime.strftime(OSU.configuration.standard_time_format)
20
+ end
21
+
22
+ def standard_datetime_zone(datetime, zone)
23
+ datetime.nil? ?
24
+ "" :
25
+ datetime.in_time_zone(zone).strftime(OSU.configuration.standard_datetime_format)
26
+ end
27
+
28
+ def month_year(datetime)
29
+ datetime.nil? ? "" : datetime.strftime("%B %Y")
30
+ end
31
+
32
+ end
33
+ end
@@ -2,7 +2,7 @@ module OpenStax::Utilities::Helpers
2
2
  module Partials
3
3
 
4
4
  def block_to_partial(partial_name, options={}, &block)
5
- options.merge!(:body => capture(&block))
5
+ options.merge!(:body => true_self.capture(&block))
6
6
  render(:partial => partial_name, :locals => options)
7
7
  end
8
8
 
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Utilities
3
- VERSION = "1.0.2"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -20,6 +20,7 @@ require "openstax/utilities/classy_helper"
20
20
  require "openstax/utilities/helpers/blocks"
21
21
  require "openstax/utilities/helpers/partials"
22
22
  require "openstax/utilities/helpers/action_list"
23
+ require "openstax/utilities/helpers/datetime"
23
24
 
24
25
  require 'openstax/utilities/blocks/block_base'
25
26
  require 'openstax/utilities/blocks/section_block'
@@ -60,10 +61,14 @@ module OpenStax
60
61
  end
61
62
 
62
63
  class Configuration
63
- # attr_accessor :some_parameter_name_here
64
+ attr_accessor :standard_date_format
65
+ attr_accessor :standard_datetime_format
66
+ attr_accessor :standard_time_format
64
67
 
65
68
  def initialize
66
- # @some_parameter_name_here = some value here
69
+ @standard_date_format = "%b %d, %Y"
70
+ @standard_datetime_format = "%b %d, %Y %l:%M %p %Z"
71
+ @standard_time_format = "%l:%M %p %Z"
67
72
  super
68
73
  end
69
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-11 00:00:00.000000000 Z
12
+ date: 2013-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -72,6 +72,7 @@ files:
72
72
  - lib/openstax/utilities/exceptions.rb
73
73
  - lib/openstax/utilities/helpers/action_list.rb
74
74
  - lib/openstax/utilities/helpers/blocks.rb
75
+ - lib/openstax/utilities/helpers/datetime.rb
75
76
  - lib/openstax/utilities/helpers/partials.rb
76
77
  - lib/openstax/utilities/network.rb
77
78
  - lib/openstax/utilities/ruby.rb
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  segments:
128
129
  - 0
129
- hash: -237788097343637860
130
+ hash: -1961078437370851561
130
131
  required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  none: false
132
133
  requirements:
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  segments:
137
138
  - 0
138
- hash: -237788097343637860
139
+ hash: -1961078437370851561
139
140
  requirements: []
140
141
  rubyforge_project:
141
142
  rubygems_version: 1.8.24