openstax_utilities 0.0.7 → 1.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.
data/README.md CHANGED
@@ -5,4 +5,8 @@ A set of common utilities for the various OpenStax projects.
5
5
 
6
6
  Documentation available on [rdoc.info](http://rdoc.info/github/openstax/openstax_utilities/master/frames).
7
7
 
8
- To use this utility engine, include it in your Gemfile.
8
+ To use this utility engine, include it in your Gemfile.
9
+
10
+ ## Helpers
11
+
12
+ This engine's helpers are available in the main application by preceding them with `osu.`, e.g. `osu.section_block('Heading') { "guts" }`
@@ -0,0 +1,13 @@
1
+ module OpenStax::Utilities
2
+ module OsuHelper
3
+
4
+ def osu
5
+ @@osu_class ||= Class.new(ClassyHelper) do
6
+ include OpenStax::Utilities::Helpers::Blocks
7
+ end
8
+
9
+ @@osu_class.new(self)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module OpenStax::Utilities
2
+
3
+ class ClassyHelper < SimpleDelegator
4
+
5
+ def initialize(helper_self)
6
+ @helper_self = helper_self
7
+ super(helper_self)
8
+ end
9
+
10
+ def true_self
11
+ @helper_self
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -2,10 +2,12 @@ ActiveSupport::Inflector.inflections do |inflect|
2
2
  inflect.acronym 'OpenStax'
3
3
  end
4
4
 
5
+ OSU = OpenStax::Utilities
6
+
5
7
  module OpenStax
6
8
  module Utilities
7
9
  class Engine < ::Rails::Engine
8
- # isolate_namespace OpenStax::Utilities
10
+ isolate_namespace OpenStax::Utilities
9
11
 
10
12
  initializer "openstax_utilities.assets.precompile" do |app|
11
13
  app.config.assets.precompile += %w(openstax_utilities.css openstax_utilities.js)
@@ -13,12 +15,11 @@ module OpenStax
13
15
 
14
16
  initializer 'openstax_utilities.action_controller' do |app|
15
17
  ActiveSupport.on_load :action_controller do
16
- helper BlockHelper
17
- helper PartialHelper
18
+ helper OSU::OsuHelper
18
19
  end
19
20
  end
20
21
  end
21
22
  end
22
23
  end
23
24
 
24
- OSU = OpenStax::Utilities
25
+
@@ -3,4 +3,5 @@ class AbstractMethodCalled < StandardError; end
3
3
  class NotYetImplemented < StandardError; end
4
4
  class IllegalArgument < StandardError; end
5
5
  class IllegalState < StandardError; end
6
- class IllegalOperation < StandardError; end
6
+ class IllegalOperation < StandardError; end
7
+ class Unexpected < StandardError; end
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,10 @@
1
+ module OpenStax::Utilities::Helpers
2
+ module Partials
3
+
4
+ def block_to_partial(partial_name, options={}, &block)
5
+ options.merge!(:body => capture(&block))
6
+ render(:partial => partial_name, :locals => options)
7
+ end
8
+
9
+ end
10
+ end
@@ -5,4 +5,8 @@ module Kernel
5
5
  self
6
6
  end
7
7
  end
8
+
9
+ def includes_module?(mod)
10
+ eigenclass.included_modules.include?(mod)
11
+ end
8
12
  end
@@ -0,0 +1,12 @@
1
+ module OpenStax
2
+ module Utilities
3
+ module Text
4
+
5
+ def self.copyright(start_year, holder)
6
+ year_range = "#{start_year}-#{Time.now.year}".sub(/\A(\d+)-\1\z/, '\1');
7
+ "Copyright &copy; #{year_range} #{holder}".html_safe
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Utilities
3
- VERSION = "0.0.7"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -5,6 +5,11 @@ require "openstax/utilities/settings"
5
5
  require "openstax/utilities/access"
6
6
  require "openstax/utilities/enum"
7
7
  require "openstax/utilities/ruby"
8
+ require "openstax/utilities/text"
9
+
10
+ require "openstax/utilities/classy_helper"
11
+ require "openstax/utilities/helpers/blocks"
12
+ require "openstax/utilities/helpers/partials"
8
13
 
9
14
  require 'openstax/utilities/blocks/block_base'
10
15
  require 'openstax/utilities/blocks/section_block'
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: 0.0.7
4
+ version: 1.0.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-09-18 00:00:00.000000000 Z
12
+ date: 2013-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -52,8 +52,7 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - app/assets/javascripts/openstax_utilities.js
54
54
  - app/assets/stylesheets/openstax_utilities.css
55
- - app/helpers/block_helper.rb
56
- - app/helpers/partial_helper.rb
55
+ - app/helpers/openstax/utilities/osu_helper.rb
57
56
  - app/views/osu/shared/_section.html.erb
58
57
  - app/views/osu/shared/_table.html.erb
59
58
  - app/views/osu/shared/_table_cell.html.erb
@@ -64,12 +63,16 @@ files:
64
63
  - lib/openstax/utilities/blocks/table_block.rb
65
64
  - lib/openstax/utilities/blocks/table_cell_block.rb
66
65
  - lib/openstax/utilities/blocks/table_row_block.rb
66
+ - lib/openstax/utilities/classy_helper.rb
67
67
  - lib/openstax/utilities/development.rb
68
68
  - lib/openstax/utilities/engine.rb
69
69
  - lib/openstax/utilities/enum.rb
70
70
  - lib/openstax/utilities/exceptions.rb
71
+ - lib/openstax/utilities/helpers/blocks.rb
72
+ - lib/openstax/utilities/helpers/partials.rb
71
73
  - lib/openstax/utilities/ruby.rb
72
74
  - lib/openstax/utilities/settings.rb
75
+ - lib/openstax/utilities/text.rb
73
76
  - lib/openstax/utilities/version.rb
74
77
  - lib/openstax_utilities.rb
75
78
  - MIT-LICENSE
@@ -105,7 +108,8 @@ files:
105
108
  - test/dummy/script/rails
106
109
  - test/integration/navigation_test.rb
107
110
  homepage: http://github.com/openstax/openstax_utilities
108
- licenses: []
111
+ licenses:
112
+ - MIT
109
113
  post_install_message:
110
114
  rdoc_options: []
111
115
  require_paths:
@@ -118,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
122
  version: '0'
119
123
  segments:
120
124
  - 0
121
- hash: -491942878868703970
125
+ hash: -335610188328766728
122
126
  required_rubygems_version: !ruby/object:Gem::Requirement
123
127
  none: false
124
128
  requirements:
@@ -127,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
131
  version: '0'
128
132
  segments:
129
133
  - 0
130
- hash: -491942878868703970
134
+ hash: -335610188328766728
131
135
  requirements: []
132
136
  rubyforge_project:
133
137
  rubygems_version: 1.8.24
@@ -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
- module BlockHelper
5
-
6
- def osu_section_block(heading=nil, &block)
7
- presenter = OpenStax::Utilities::Blocks::SectionBlock.new(self, heading, block)
8
- end
9
-
10
- def osu_table_block(&block)
11
- presenter = TableBlock.new(self, block)
12
- end
13
-
14
- def osu_table_row_block(&block)
15
- presenter = TableRowBlock.new(self, block)
16
- end
17
-
18
- def osu_table_cell_block(&block)
19
- presenter = TableCellBlock.new(self, block)
20
- end
21
-
22
- end
@@ -1,9 +0,0 @@
1
- module PartialHelper
2
-
3
- def osu_block_to_partial(partial_name, options={}, &block)
4
- options.merge!(:body => capture(&block))
5
- render(:partial => partial_name, :locals => options)
6
- end
7
-
8
-
9
- end