openstax_utilities 2.2.3 → 3.0.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzJlY2Q5YzY4NDE1MTYxY2RkOTg5OGQyZGFmMTkwZjFlNzQzMWE4NA==
4
+ NTE4ZjlhOTM0OTAxNzhhMTI2ZWU0ODhiNTIwZTAxZTk3ZGYyOTc0OA==
5
5
  data.tar.gz: !binary |-
6
- ODIyYzE0OGY1OWEyNzIwZmI3OGI3NTEwNmU5MzM2OWRkYmFiOWY4OQ==
6
+ MmE0MTg2ZWRhNWRlMDViMjZjODc5NTM2OGYzYjJmZDdlMDI4Y2QzZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDU2MTYzOWIzMWIzMWE2NzA5NTFmM2MyMTRiZGQ1MzFkOWRkNzg5OGIxMTA2
10
- ZmZhZTRmMWQyOTkyMWZjZjVlYzI5NTA4NjIxZWVhZGMxNzVmNTM0YWY2OWI5
11
- ZDk4ZjE2YjY1YzczNmEzN2UzNTQzNGRlYjE3NmE2ZmZhODQ0ZTE=
9
+ YjkxMmQ2MGJmMjAyMDczNWJmZmExNzk1ODBhZDRjODYyOTNmMmRiZDE5OWZh
10
+ ZDljYzY5OTkzMTJiZWVjZTBhYWYxODQ2YjQ1Mzc5N2ExNjg4NmIzOTU0YWI4
11
+ OGFkYTI4N2QyMjk1ZTBiNzk5ZmI3OGNiNTY2ZTQzY2VlOWU0NWI=
12
12
  data.tar.gz: !binary |-
13
- MjE3YTNjN2JjNTc2NzhlZTFiODRlZDk3M2I0ZGQ2YmQ5YTJjZWQ2YWU3MGRm
14
- YzA1ZTJiOTBmNzY2YWExMzQ3NzQ4MjdiZmIzNzUyNmIzOWJlNDhjZGZkYjBi
15
- NTQ1ZmMwNjI2YzY4YmJhNDhlNTY4MjAxMjMwOTRjYWViZTNiYjc=
13
+ YjliMzBmNTk3YjNmMWQyYTE4ZTM4OTc1YmRlZWYyMGZiZTIwMjhmNzFiY2Jh
14
+ ZjAzMGJhOTk3ODExNzY0NDliM2QxY2JkYjhmNTMyZmVhZDdhZDBmN2M1NmFh
15
+ OWMzYWY4OTkzY2YzYmY0MmRjZGQ2YTdjOWQyZTQyNjE0OTIzYTI=
@@ -4,7 +4,6 @@ module OpenStax::Utilities
4
4
  def osu
5
5
  @@osu_class ||= Class.new(ClassyHelper) do
6
6
  include OpenStax::Utilities::Helpers::Misc
7
- include OpenStax::Utilities::Helpers::Blocks
8
7
  include OpenStax::Utilities::Helpers::Partials
9
8
  include OpenStax::Utilities::Helpers::ActionList
10
9
  include OpenStax::Utilities::Helpers::Datetime
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Utilities
3
- VERSION = "2.2.3"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
@@ -22,17 +22,10 @@ require "openstax/utilities/access_policy"
22
22
 
23
23
  require "openstax/utilities/classy_helper"
24
24
  require "openstax/utilities/helpers/misc"
25
- require "openstax/utilities/helpers/blocks"
26
25
  require "openstax/utilities/helpers/partials"
27
26
  require "openstax/utilities/helpers/action_list"
28
27
  require "openstax/utilities/helpers/datetime"
29
28
 
30
- require 'openstax/utilities/blocks/block_base'
31
- require 'openstax/utilities/blocks/section_block'
32
- require 'openstax/utilities/blocks/table_block'
33
- require 'openstax/utilities/blocks/table_cell_block'
34
- require 'openstax/utilities/blocks/table_row_block'
35
-
36
29
  module OpenStax
37
30
  module Utilities
38
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
- - !ruby/object:Gem::Dependency
28
- name: attribeautiful
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: 0.0.7
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: 0.0.7
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: sqlite3
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,27 +66,17 @@ files:
80
66
  - app/assets/stylesheets/openstax_utilities.css
81
67
  - app/helpers/openstax/utilities/osu_helper.rb
82
68
  - app/views/osu/shared/_action_list.html.erb
83
- - app/views/osu/shared/_section.html.erb
84
- - app/views/osu/shared/_table.html.erb
85
- - app/views/osu/shared/_table_cell.html.erb
86
- - app/views/osu/shared/_table_row.html.erb
87
69
  - lib/openstax/utilities/access.rb
88
70
  - lib/openstax/utilities/access_policy.rb
89
71
  - lib/openstax/utilities/action_list.rb
90
72
  - lib/openstax/utilities/active_record_extensions.rb
91
73
  - lib/openstax/utilities/acts_as_numberable.rb
92
- - lib/openstax/utilities/blocks/block_base.rb
93
- - lib/openstax/utilities/blocks/section_block.rb
94
- - lib/openstax/utilities/blocks/table_block.rb
95
- - lib/openstax/utilities/blocks/table_cell_block.rb
96
- - lib/openstax/utilities/blocks/table_row_block.rb
97
74
  - lib/openstax/utilities/classy_helper.rb
98
75
  - lib/openstax/utilities/delegate_access_control.rb
99
76
  - lib/openstax/utilities/engine.rb
100
77
  - lib/openstax/utilities/enum.rb
101
78
  - lib/openstax/utilities/exceptions.rb
102
79
  - lib/openstax/utilities/helpers/action_list.rb
103
- - lib/openstax/utilities/helpers/blocks.rb
104
80
  - lib/openstax/utilities/helpers/datetime.rb
105
81
  - lib/openstax/utilities/helpers/misc.rb
106
82
  - lib/openstax/utilities/helpers/partials.rb
@@ -1,17 +0,0 @@
1
- <%# Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <div <%= block.section_id_attr %> <%= block.section_class_attr %> >
5
-
6
- <% if block.show_heading? %>
7
- <div <%= block.heading_class_attr %> >
8
- <%= block.heading %>
9
- </div>
10
- <% end %>
11
-
12
- <div <%= block.body_class_attr %> >
13
- <%= block.captured_block %>
14
- </div>
15
-
16
- </div>
17
-
@@ -1,22 +0,0 @@
1
- <%# Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <table <%= block.table_id_attr %> <%= block.table_class_attr %> >
5
- <% if block.show_caption? %>
6
- <caption <%= block.caption_class_attr %> >
7
- <%= block.title %>
8
- </caption>
9
- <% end %>
10
-
11
- <tr <%= block.heading_row_class_attr %> >
12
- <% block.column_names.each do |column_name| %>
13
- <th <%= block.heading_cell_class_attr %> >
14
- <%= column_name %>
15
- </th>
16
- <% end %>
17
- </tr>
18
-
19
- <% block.row_blocks.each do |row_block| %>
20
- <%= row_block %>
21
- <% end %>
22
- </table>
@@ -1,6 +0,0 @@
1
- <%# Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <td <%= block.td_id_attr %> <%= block.td_class_attr %> <%= block.td_colspan_attr %> >
5
- <%= block.captured_block %>
6
- </td>
@@ -1,8 +0,0 @@
1
- <%# Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <tr>
5
- <% block.cell_blocks.each do |cb| %>
6
- <%= cb %>
7
- <% end %>
8
- </tr>
@@ -1,38 +0,0 @@
1
- # Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- # License version 3 or later. See the COPYRIGHT file for details.
3
-
4
- require 'attribeautiful'
5
-
6
- module OpenStax::Utilities::Blocks
7
- class BlockBase
8
- include Attribeautiful
9
-
10
- attr_accessor :captured_block
11
-
12
- def initialize(template, partial, passed_block)
13
- self.h = template
14
- self.passed_block = passed_block
15
- self.partial = partial
16
- end
17
-
18
- def to_s
19
- render_passed_block
20
- render_partial
21
- end
22
-
23
- protected
24
-
25
- attr_accessor :h
26
- attr_accessor :passed_block
27
- attr_accessor :partial
28
-
29
- def render_passed_block
30
- self.captured_block ||= h.capture self, &passed_block
31
- end
32
-
33
- def render_partial
34
- h.render :partial => "osu/shared/#{partial}", :locals => { :block => self }
35
- end
36
-
37
- end
38
- end
@@ -1,60 +0,0 @@
1
- # Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- # License version 3 or later. See the COPYRIGHT file for details.
3
-
4
- module OpenStax::Utilities::Blocks
5
- class SectionBlock < BlockBase
6
-
7
- html_element :section
8
- html_element :heading
9
- html_element :body
10
-
11
- attr_accessor :heading
12
- attr_accessor :nesting
13
- attr_accessor :top_bar
14
-
15
- def initialize(template, heading, block)
16
- super(template, "section", block)
17
-
18
- set_heading(heading) if !heading.blank?
19
- section_class_add "section-block-section"
20
- heading_class_add "section-block-heading"
21
- body_class_add "section-block-body"
22
- end
23
-
24
- def set_heading(string)
25
- self.heading = string
26
- self
27
- end
28
-
29
- def set_nesting(depth)
30
- self.nesting = depth
31
- self
32
- end
33
-
34
- def set_top_bar
35
- raise "SectionBlock top bar cannot be changed once initialized" \
36
- if @top_bar
37
- section_class_add "bar-top"
38
- self.top_bar = true
39
- self
40
- end
41
-
42
- def heading=(string)
43
- raise "SectionBlock heading cannot be changed once initialized" \
44
- if @heading
45
- @heading = string
46
- end
47
-
48
- def nesting=(depth)
49
- raise "SectionBlock nesting cannot be changed once initialized" \
50
- if @nesting
51
- section_class_add "nesting-#{depth}"
52
- @nesting = depth
53
- end
54
-
55
- def show_heading?
56
- heading.present?
57
- end
58
-
59
- end
60
- end
@@ -1,74 +0,0 @@
1
- # Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- # License version 3 or later. See the COPYRIGHT file for details.
3
-
4
- module OpenStax::Utilities::Blocks
5
- class TableBlock < BlockBase
6
-
7
- html_element :table
8
- html_element :caption
9
- html_element :heading_row
10
- html_element :heading_cell
11
-
12
- attr_reader :column_names
13
- attr_reader :row_blocks
14
- attr_reader :title
15
-
16
- def initialize(template, block)
17
- super(template, "table", block)
18
- self.column_names = []
19
- self.row_blocks = []
20
-
21
- self.table_class_add "table-block-table"
22
-
23
- end
24
-
25
- def set_title(table_title)
26
- self.title = table_title
27
- self
28
- end
29
-
30
- def title=(table_title)
31
- raise "TableBlock title cannot be changed once initialized" \
32
- if @title
33
- @title = table_title
34
- end
35
-
36
- def add_column(column_name)
37
- self.column_names << column_name
38
- self
39
- end
40
-
41
- def add_row_block(&block)
42
- self.row_blocks << h.table_row_block(&block)
43
- self
44
- end
45
-
46
- def add_row(*args)
47
- trb = h.table_row_block do |rb|
48
- args.each do |arg|
49
- rb.add_cell(arg)
50
- end
51
- end
52
- self.row_blocks << trb
53
- self
54
- end
55
-
56
- def add_section_heading(heading)
57
- trb = h.table_row_block do |rb|
58
- rb.set_section_heading(heading, column_names.count)
59
- end
60
- self.row_blocks << trb
61
- self
62
- end
63
-
64
- def show_caption?
65
- title.present?
66
- end
67
-
68
- protected
69
-
70
- attr_writer :column_names
71
- attr_writer :row_blocks
72
-
73
- end
74
- end
@@ -1,26 +0,0 @@
1
- # Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- # License version 3 or later. See the COPYRIGHT file for details.
3
-
4
- module OpenStax::Utilities::Blocks
5
- class TableCellBlock < BlockBase
6
-
7
- html_element :td
8
-
9
- def initialize(template, block)
10
- super(template, "table_cell", block)
11
- end
12
-
13
- def self.from_value(template, value)
14
- tcb = TableCellBlock.new(template, Proc.new {})
15
- tcb.captured_block = value
16
- tcb
17
- end
18
-
19
- def set_section_heading(colspan)
20
- self.td_class_add "section-heading"
21
- self.td_colspan_add colspan
22
- self
23
- end
24
-
25
- end
26
- end
@@ -1,49 +0,0 @@
1
- # Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- # License version 3 or later. See the COPYRIGHT file for details.
3
-
4
- module OpenStax::Utilities::Blocks
5
- class TableRowBlock < BlockBase
6
-
7
- attr_reader :cell_blocks
8
- attr_reader :section_heading
9
-
10
- def initialize(template, block)
11
- super(template, "table_row", block)
12
- self.cell_blocks = []
13
- self.section_heading = false
14
- end
15
-
16
- def add_cell_block(&block)
17
- self.cell_blocks << h.table_cell_block(&block)
18
- self
19
- end
20
-
21
- def add_cell(value)
22
- self.cell_blocks << TableCellBlock.from_value(h, value)
23
- end
24
-
25
- def section_heading?
26
- section_heading
27
- end
28
-
29
- def set_section_heading(heading, colspan)
30
- raise "TableRowBlock cannot be a table section heading if it contains cells" \
31
- if cell_blocks.any?
32
- raise "TableRowBlock section heading cannot be changed once initialized" \
33
- if section_heading?
34
-
35
- tcb = TableCellBlock.from_value(h, heading)
36
- tcb.set_section_heading(colspan)
37
- self.cell_blocks << tcb
38
-
39
- self.section_heading = true
40
- self
41
- end
42
-
43
- protected
44
-
45
- attr_writer :cell_blocks
46
- attr_writer :section_heading
47
-
48
- end
49
- end
@@ -1,24 +0,0 @@
1
- # Copyright 2011-2013 Rice University. Licensed under the Affero General Public
2
- # License version 3 or later. See the COPYRIGHT file for details.
3
-
4
- module OpenStax::Utilities::Helpers
5
- module Blocks
6
-
7
- def section_block(heading=nil, &block)
8
- presenter = OpenStax::Utilities::Blocks::SectionBlock.new(true_self, heading, block)
9
- end
10
-
11
- def table_block(&block)
12
- presenter = TableBlock.new(true_self, block)
13
- end
14
-
15
- def table_row_block(&block)
16
- presenter = TableRowBlock.new(true_self, block)
17
- end
18
-
19
- def table_cell_block(&block)
20
- presenter = TableCellBlock.new(true_self, block)
21
- end
22
-
23
- end
24
- end