alpha-simprini-engine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/app/assets/javascripts/alpha_simprini.coffee +15 -0
  5. data/app/assets/javascripts/alpha_simprini/application.coffee +22 -0
  6. data/app/assets/javascripts/alpha_simprini/coffee_kup/binding.coffee +119 -0
  7. data/app/assets/javascripts/alpha_simprini/coffee_kup/helpers.coffee +17 -0
  8. data/app/assets/javascripts/alpha_simprini/coffee_kup/tags.coffee +7 -0
  9. data/app/assets/javascripts/alpha_simprini/collection.coffee +62 -0
  10. data/app/assets/javascripts/alpha_simprini/delegate.coffee +21 -0
  11. data/app/assets/javascripts/alpha_simprini/event.coffee +75 -0
  12. data/app/assets/javascripts/alpha_simprini/html.coffee +56 -0
  13. data/app/assets/javascripts/alpha_simprini/mixin.coffee +10 -0
  14. data/app/assets/javascripts/alpha_simprini/model.coffee +137 -0
  15. data/app/assets/javascripts/alpha_simprini/models/radio_selection_model.coffee +9 -0
  16. data/app/assets/javascripts/alpha_simprini/packer.coffee +93 -0
  17. data/app/assets/javascripts/alpha_simprini/template_helpers.coffee +8 -0
  18. data/app/assets/javascripts/alpha_simprini/view.coffee +182 -0
  19. data/app/assets/javascripts/alpha_simprini/views/canvas.coffee +2 -0
  20. data/app/assets/javascripts/alpha_simprini/views/horizontal_split.coffee +9 -0
  21. data/app/assets/javascripts/alpha_simprini/views/panel.coffee +2 -0
  22. data/app/assets/javascripts/alpha_simprini/views/splitter.coffee +2 -0
  23. data/app/assets/javascripts/alpha_simprini/views/stage.coffee +7 -0
  24. data/app/assets/javascripts/alpha_simprini/views/vertical_split.coffee +8 -0
  25. data/app/assets/javascripts/alpha_simprini/views/viewport.coffee +0 -0
  26. data/app/assets/javascripts/bundle.js +16416 -0
  27. data/app/assets/javascripts/lib/backbone.coffee +11 -0
  28. data/app/assets/javascripts/lib/koffeecup_backbone_databind.coffee +25 -0
  29. data/app/assets/javascripts/lib/module.coffee +15 -0
  30. data/app/assets/javascripts/lib/state_machine.coffee +33 -0
  31. data/app/assets/javascripts/lib/string.coffee +13 -0
  32. data/app/assets/javascripts/qunit.js +1513 -0
  33. data/app/assets/javascripts/test.coffee +4 -0
  34. data/app/assets/javascripts/test/alpha_simprini/coffee_kup/binding.coffee +118 -0
  35. data/app/assets/javascripts/test/alpha_simprini/coffee_kup/helpers.coffee +10 -0
  36. data/app/assets/javascripts/test/alpha_simprini/coffee_kup/tags.coffee +18 -0
  37. data/app/assets/javascripts/test/alpha_simprini/collection.coffee +7 -0
  38. data/app/assets/javascripts/test/alpha_simprini/event.coffee +43 -0
  39. data/app/assets/javascripts/test/alpha_simprini/model.coffee +63 -0
  40. data/app/assets/javascripts/test/alpha_simprini/view.coffee +72 -0
  41. data/app/assets/javascripts/test/alpha_simprini/views/canvas.coffee +8 -0
  42. data/app/assets/javascripts/test/alpha_simprini/views/horizontal_split.coffee +13 -0
  43. data/app/assets/javascripts/test/alpha_simprini/views/vertical_split.coffee +13 -0
  44. data/app/assets/javascripts/test/backbone/collection.js +345 -0
  45. data/app/assets/javascripts/test/backbone/events.js +86 -0
  46. data/app/assets/javascripts/test/backbone/model.js +426 -0
  47. data/app/assets/javascripts/test/backbone/view.js +137 -0
  48. data/app/assets/stylesheets/bootstrap.sass +6 -0
  49. data/app/assets/stylesheets/paneling.sass +2 -0
  50. data/app/assets/stylesheets/qunit.scss +228 -0
  51. data/app/assets/stylesheets/table.sass +10 -0
  52. data/app/assets/stylesheets/typography.sass +19 -0
  53. data/app/controllers/alpha_simprini/test_controller.rb +3 -0
  54. data/app/controllers/resources_controller.rb +7 -0
  55. data/app/views/alpha_simprini/test/root.rb +13 -0
  56. data/app/views/resources/base.rb +2 -0
  57. data/app/views/resources/edit.rb +9 -0
  58. data/app/views/resources/form.rb +26 -0
  59. data/app/views/resources/index.rb +41 -0
  60. data/app/views/resources/new.rb +9 -0
  61. data/app/views/resources/show.rb +42 -0
  62. data/app/views/resources/show_has_many.rb +28 -0
  63. data/config/locales/en.yml +4 -0
  64. data/config/routes.rb +3 -0
  65. data/lib/alpha-simprini-engine.rb +33 -0
  66. data/lib/alpha-simprini-engine/version.rb +3 -0
  67. data/lib/alpha_simprini/directive_processor.rb +77 -0
  68. data/lib/alpha_simprini/packer.rb +161 -0
  69. data/lib/alpha_simprini/page.rb +37 -0
  70. data/lib/tasks/alpha-simprini-engine_tasks.rake +4 -0
  71. data/test/alpha-simprini-engine_test.rb +7 -0
  72. data/test/dummy/Rakefile +7 -0
  73. data/test/dummy/app/assets/javascripts/application.js +9 -0
  74. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  75. data/test/dummy/app/controllers/application_controller.rb +3 -0
  76. data/test/dummy/app/helpers/application_helper.rb +2 -0
  77. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  78. data/test/dummy/config.ru +4 -0
  79. data/test/dummy/config/application.rb +42 -0
  80. data/test/dummy/config/boot.rb +10 -0
  81. data/test/dummy/config/database.yml +25 -0
  82. data/test/dummy/config/environment.rb +5 -0
  83. data/test/dummy/config/environments/development.rb +27 -0
  84. data/test/dummy/config/environments/production.rb +51 -0
  85. data/test/dummy/config/environments/test.rb +39 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/inflections.rb +10 -0
  88. data/test/dummy/config/initializers/mime_types.rb +5 -0
  89. data/test/dummy/config/initializers/secret_token.rb +7 -0
  90. data/test/dummy/config/initializers/session_store.rb +8 -0
  91. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  92. data/test/dummy/config/locales/en.yml +4 -0
  93. data/test/dummy/config/routes.rb +58 -0
  94. data/test/dummy/db/development.sqlite3 +0 -0
  95. data/test/dummy/log/development.log +800 -0
  96. data/test/dummy/public/404.html +26 -0
  97. data/test/dummy/public/422.html +26 -0
  98. data/test/dummy/public/500.html +26 -0
  99. data/test/dummy/public/favicon.ico +0 -0
  100. data/test/dummy/script/rails +6 -0
  101. data/test/dummy/tmp/cache/assets/C24/D70/sprockets%2F388a550030239f3784f207fa32954f64 +0 -0
  102. data/test/dummy/tmp/cache/assets/C34/620/sprockets%2F097ee8532856d48d70420c006f475889 +0 -0
  103. data/test/dummy/tmp/cache/assets/C6F/710/sprockets%2F908d18b0f21c18dad508851126164a41 +0 -0
  104. data/test/dummy/tmp/cache/assets/CA7/120/sprockets%2F35278a6c0150c40394fe02629c8b0eb9 +0 -0
  105. data/test/dummy/tmp/cache/assets/CDB/A80/sprockets%2F443b1c6e71b482fdd83b1833b7e27712 +0 -0
  106. data/test/dummy/tmp/cache/assets/CE3/FB0/sprockets%2F6d3f87a4232e0368bb86760780c5f1bd +0 -0
  107. data/test/dummy/tmp/cache/assets/D1C/160/sprockets%2F87876f7e55ebc78ae11c6c08a27f0605 +0 -0
  108. data/test/dummy/tmp/cache/assets/D26/6C0/sprockets%2F65bce2254bb3140a50326ea1654ea5df +0 -0
  109. data/test/dummy/tmp/cache/assets/D26/FA0/sprockets%2F1f50f59148df5f3e2ab889df381d9744 +0 -0
  110. data/test/dummy/tmp/cache/assets/D36/220/sprockets%2F841654b01d89eada195d7d1fe10b57b0 +0 -0
  111. data/test/dummy/tmp/cache/assets/D47/410/sprockets%2Ff1fe319eb4064bd5b861ac28f7d76555 +18122 -0
  112. data/test/dummy/tmp/cache/assets/D57/1E0/sprockets%2Fe267e3e1059799c429e4f5cfb95ec53c +0 -0
  113. data/test/dummy/tmp/cache/assets/D64/3E0/sprockets%2Fb49b7f8034b81ec601bc32fb127fbe08 +0 -0
  114. data/test/dummy/tmp/cache/assets/D65/850/sprockets%2F7a9b6a0e2d51adb43a1d3f859213e6b8 +15469 -0
  115. data/test/dummy/tmp/cache/assets/D6C/E30/sprockets%2Fcc7322b05ac2bef75e9f4f145d38117f +0 -0
  116. data/test/dummy/tmp/cache/assets/D7D/E00/sprockets%2Fce33b82451c73df1cfec69928b4f77b6 +0 -0
  117. data/test/dummy/tmp/cache/assets/D85/5D0/sprockets%2Fcf743946c378c148b19ce78eeaa9cc75 +0 -0
  118. data/test/dummy/tmp/cache/assets/DBB/560/sprockets%2F5a1d70cf7dd81a5ab5ce7a40a3a38d06 +0 -0
  119. data/test/dummy/tmp/cache/assets/DC1/670/sprockets%2Fefdfad0542298a1db90d24dc27ecc250 +0 -0
  120. data/test/dummy/tmp/cache/assets/DC5/1E0/sprockets%2F7517f22ad0f9dc13b8f0f6e0cc0e5de2 +0 -0
  121. data/test/dummy/tmp/cache/assets/DCC/220/sprockets%2F28d953c6ab9cc9a7db15600aabc6d77d +208 -0
  122. data/test/dummy/tmp/cache/assets/DCF/DF0/sprockets%2Ff0d3068f05825e1dfd9f5aaba946d3dc +0 -0
  123. data/test/dummy/tmp/cache/assets/DD3/0E0/sprockets%2F3e9e08a334bae7deadb5335f5e4f195f +0 -0
  124. data/test/dummy/tmp/cache/assets/DDB/980/sprockets%2Fbd2abc80a17c901e2f497f88f9be58cf +0 -0
  125. data/test/dummy/tmp/cache/assets/E00/ED0/sprockets%2Ffecf3bffeb200a47e96bd04cbc878076 +1535 -0
  126. data/test/dummy/tmp/cache/assets/EFB/560/sprockets%2Fbca0daf751c020cdeddabbefa51cb6ea +0 -0
  127. data/test/dummy/tmp/restart.txt +0 -0
  128. data/test/test_helper.rb +10 -0
  129. metadata +326 -0
@@ -0,0 +1,26 @@
1
+ class Views::Resources::Form < Views::Resources::Base
2
+ def body_content
3
+ form do |form|
4
+ fields(form)
5
+ buttons(form)
6
+ end
7
+ end
8
+
9
+ def fields(form)
10
+ available_fields.each do |key, value|
11
+ input(form, key, :text_field)
12
+ end
13
+ end
14
+
15
+ def buttons(form)
16
+ div class: 'buttons' do
17
+ form.submit
18
+ end
19
+ end
20
+
21
+ def available_fields
22
+ resource.fields.reject do |key, value|
23
+ key.starts_with?("_")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,41 @@
1
+ class Views::Resources::Index < Views::Resources::Base
2
+ def page_header
3
+ h1 "#{resource_name} Index"
4
+ end
5
+
6
+ def blank_slate
7
+ link_to "Create a #{resource_name}", new_resource_path
8
+ end
9
+
10
+ def body_content
11
+ page_header
12
+ item_list
13
+ end
14
+
15
+ def item_list
16
+ blank_slate
17
+ if collection.any?
18
+ ul do
19
+ collection.each do |item|
20
+ li do
21
+ links_for_item(item)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def links_for_item(item)
29
+ link_to list_representation(item), resource_path(item)
30
+ end
31
+
32
+ def list_representation(item)
33
+ if item.respond_to?(:name)
34
+ item.name
35
+ elsif item.respond_to?(:title)
36
+ item.title
37
+ else
38
+ item.to_s
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ class Views::Resources::New < Views::Resources::Form
2
+ def page_title
3
+ "New #{resource_name}"
4
+ end
5
+
6
+ def form &block
7
+ form_for resource, url: collection_url, &block
8
+ end
9
+ end
@@ -0,0 +1,42 @@
1
+ class Views::Resources::Show < Views::Resources::Base
2
+ cattr_accessor :has_manys
3
+
4
+ def self.has_manys
5
+ @has_manys ||= {}
6
+ end
7
+
8
+ def self.has_many(name, &config)
9
+ has_manys[name] = Views::Resources::ShowHasMany.new(&config)
10
+ end
11
+
12
+ def body_content
13
+ p link_to "back to #{resource_name.pluralize} index", collection_path
14
+ p resource.name
15
+ associations_content
16
+ p link_to "edit", edit_resource_path
17
+ end
18
+
19
+ def associations_content
20
+ self.class.has_manys.each do |name, has_many|
21
+ div do
22
+ h2 name
23
+ table do
24
+ thead do
25
+ has_many.columns.each do |column|
26
+ th { text column.name }
27
+ end
28
+ end
29
+ tbody do
30
+ resource.send(name).each do |item|
31
+ tr class: cycle(:odd, :even) do
32
+ has_many.columns.each do |column|
33
+ td { column.content_for(self, item) }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,28 @@
1
+ class Views::Resources::ShowHasMany
2
+ class Column
3
+ attr_accessor :name
4
+ def initialize(name, &content_for_block)
5
+ @name = name
6
+ @content_for_block = content_for_block
7
+ end
8
+
9
+ def content_for(context, item)
10
+ content = if @content_for_block
11
+ context.instance_exec(item, &@content_for_block)
12
+ else
13
+ item.send(name)
14
+ end
15
+
16
+ context.text content if content.is_a?(String)
17
+ end
18
+ end
19
+ attr_accessor :columns
20
+ def initialize(&config)
21
+ @columns = []
22
+ instance_eval(&config)
23
+ end
24
+
25
+ def column(name, &block)
26
+ self.columns << Column.new(name, &block)
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ blank: This page intentionally left blank.
3
+ doctype_html: <!DOCTYPE html>
4
+ application_title: AlphaSimprinEngine
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ match "/alpha_simprini/test" => "alpha_simprini/test#root" unless Rails.env.production?
3
+ end
@@ -0,0 +1,33 @@
1
+ module AlphaSimpriniEngine
2
+ require "inherited_resources"
3
+ require "alpha_simprini/page"
4
+ require "alpha_simprini/packer"
5
+
6
+ class Engine < Rails::Engine
7
+ config.autoload_paths += %w(#{config.root}/app)
8
+ # Does coool things like give us
9
+ initializer "alpha-simprini-engine.erector", before: :set_autoload_paths do |app|
10
+ app.config.autoload_paths += %W(#{app.root}/app #{AlphaSimpriniEngine::Engine.root}/app)
11
+ end
12
+
13
+ initializer "alpha-simprini-engine.extras", before: :set_autoload_paths do |app|
14
+ app.config.autoload_paths += %W(#{app.root}/extras #{AlphaSimpriniEngine::Engine.root}/extras)
15
+ end
16
+
17
+ initializer "alpha-simprini-engine.sprockets.engine_processor" do |app|
18
+ require "alpha_simprini/directive_processor"
19
+
20
+ app.assets.unregister_processor("text/javascript", Sprockets::DirectiveProcessor)
21
+ app.assets.register_processor("text/javascript", AlphaSimprini::DirectiveProcessor)
22
+
23
+ app.assets.unregister_processor("application/javascript", Sprockets::DirectiveProcessor)
24
+ app.assets.register_processor("application/javascript", AlphaSimprini::DirectiveProcessor)
25
+ end
26
+
27
+ # Set things up for erector
28
+ initializer "alpha-simprini-engine.controller" do |app|
29
+ # Layout nil required for erector integration`
30
+ ApplicationController.send :layout, nil
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module AlphaSimpriniEngine
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,77 @@
1
+ require "sprockets"
2
+ require "sprockets/directive_processor"
3
+
4
+ class AlphaSimprini::DirectiveProcessor < Sprockets::DirectiveProcessor
5
+ def glob_assets(path, globstring)
6
+ root = pathname.dirname.join(path).expand_path
7
+ root.to_s.match(/(javascripts|stylesheets|images)/)
8
+ asset_dir = $1
9
+
10
+ asset_dirs = (::Rails::Engine.subclasses << Rails.application).map do |engine|
11
+ engine.paths["app/assets"].map do |asset_path|
12
+ engine.root.join(asset_path).join(asset_dir).join(path)
13
+ end
14
+ end.flatten
15
+
16
+ Dir["{#{asset_dirs.join ','}}#{globstring}"]
17
+ end
18
+
19
+ # `require_directory` requires all the files inside a single
20
+ # directory. It's similar to `path/*` since it does not follow
21
+ # nested directories.
22
+ #
23
+ # //= require_directory "./javascripts"
24
+ #
25
+ def process_require_directory_directive(path = ".")
26
+ if relative?(path)
27
+
28
+ root = pathname.dirname.join(path).expand_path
29
+ unless root.directory?
30
+ raise ArgumentError, "require_tree argument must be a directory"
31
+ end
32
+ context.depend_on(root)
33
+
34
+ glob_assets(path, "/*").sort.each do |filename| #Dir["#{root}/*"].sort.each do |filename|
35
+ if filename == self.file
36
+ next
37
+ elsif context.asset_requirable?(filename)
38
+ context.require_asset(filename)
39
+ end
40
+ end
41
+ else
42
+ # The path must be relative and start with a `./`.
43
+ raise ArgumentError, "require_directory argument must be a relative path"
44
+ end
45
+ end
46
+
47
+ # `require_tree` requires all the nested files in a directory.
48
+ # Its glob equivalent is `path/**/*`.
49
+ #
50
+ # //= require_tree "./public"
51
+ #
52
+ def process_require_tree_directive(path = ".")
53
+ if relative?(path)
54
+ root = pathname.dirname.join(path).expand_path
55
+
56
+ unless root.directory?
57
+ raise ArgumentError, "require_tree argument must be a directory"
58
+ end
59
+
60
+ context.depend_on(root)
61
+
62
+
63
+ glob_assets(path, "/**/*").sort.each do |filename| #Dir["{#{root},#{relative_root}}/**/*"].sort.each do |filename|
64
+ if filename == self.file
65
+ next
66
+ elsif File.directory?(filename)
67
+ context.depend_on(filename)
68
+ elsif context.asset_requirable?(filename)
69
+ context.require_asset(filename)
70
+ end
71
+ end
72
+ else
73
+ # The path must be relative and start with a `./`.
74
+ raise ArgumentError, "require_tree argument must be a relative path"
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,161 @@
1
+ module AlphaSimprini
2
+ module Heap
3
+ CLASS = 0x11
4
+ ATTRIBUTES = 0x12
5
+ CLASSES = 0x13
6
+ OBJECTS = 0x14
7
+ NAMED_OBJECTS = 0x15
8
+ LITERALS = 0x16
9
+
10
+ class Packer
11
+ attr_reader :classes, :objects, :named_objects
12
+ def initialize
13
+ @classes = {}
14
+ @objects = {}
15
+ @named_objects = {}
16
+ @literals = []
17
+ end
18
+
19
+ def pack(object, named=nil)
20
+ pack_object(object, pack_class(object.class), named)
21
+ end
22
+
23
+ def pack_object(object, class_reference, named=nil)
24
+ return object.object_id if @objects[object.object_id]
25
+ @objects[object.object_id] = reference = {}
26
+ if object.is_a?(Hash)
27
+ reference.merge!\
28
+ CLASS => class_reference,
29
+ ATTRIBUTES => object.inject({}) {|hash, (name, object)| hash[pack(name)] = pack(object); hash }
30
+ elsif object.is_a?(Array)
31
+ reference.merge!\
32
+ CLASS => class_reference,
33
+ ATTRIBUTES => object.map{|item| pack(item) }
34
+ elsif object.is_a?(Numeric)
35
+ reference.merge!\
36
+ CLASS => pack_class(Numeric),
37
+ ATTRIBUTES => @literals.count
38
+ @literals << object
39
+ elsif object.is_a?(Symbol)
40
+ reference.merge!\
41
+ CLASS => pack_class(String),
42
+ ATTRIBUTES => @literals.count
43
+ @literals << object.to_s
44
+ elsif object.is_a?(String)
45
+ reference.merge!\
46
+ CLASS => class_reference,
47
+ ATTRIBUTES => @literals.count
48
+ @literals << object
49
+ else
50
+ reference.merge!\
51
+ CLASS => class_reference,
52
+ ATTRIBUTES => (object.instance_variables.inject({}) do |hash, name|
53
+ value_to_pack = object.instance_variable_get(name)
54
+ if value_to_pack == object
55
+ hash[pack(name)] = object.object_id
56
+ else
57
+ hash[pack(name)] = pack(value_to_pack)
58
+ end
59
+ hash
60
+ end)
61
+ end
62
+ @named_objects[pack(named)] = object.object_id if named
63
+ object.object_id
64
+ end
65
+
66
+ def pack_class(klass)
67
+ @classes[klass.name] ||= @classes.size
68
+ end
69
+
70
+ def to_h
71
+ {
72
+ CLASSES => @classes,
73
+ OBJECTS => @objects,
74
+ NAMED_OBJECTS => @named_objects,
75
+ LITERALS => @literals
76
+ }
77
+ end
78
+ end
79
+
80
+ class Unpacker
81
+ attr_reader :classes, :objects, :named_objects
82
+
83
+ def initialize(hash)
84
+ @literals = hash[LITERALS]
85
+ @classes = hash[CLASSES].inject({}) { |hash, (key, value)| hash[value] = key.constantize; hash }
86
+ @packed_objects = hash[OBJECTS]
87
+ @objects = {}
88
+ @named_objects = {}
89
+ @packed_objects.each do |key, value|
90
+ unpack_object(key)
91
+ end
92
+ hash[NAMED_OBJECTS].inject({}) do |hash, (key, value)|
93
+ @named_objects[key] = @objects[value]
94
+ end
95
+ end
96
+
97
+ def unpack_object(key)
98
+ return @objects[key] if @objects[key]
99
+ value = @packed_objects[key]
100
+ attributes = value[ATTRIBUTES]
101
+
102
+ klass = @classes[value[CLASS]]
103
+ if klass == Hash
104
+ @objects[key] = attributes.inject({}) do |hash, (key, value)|
105
+ hash[unpack_object(key)] = unpack_object(value)
106
+ hash
107
+ end
108
+ elsif klass == Array
109
+ @objects[key] = attributes.map{ |item| unpack_object(item) }
110
+ elsif klass == Numeric
111
+ @objects[key] = @literals[attributes]
112
+ elsif klass == String
113
+ @objects[key] = @literals[attributes]
114
+ elsif klass == NilClass
115
+ @objects[key] = attributes
116
+ else
117
+ object = @objects[key] = klass.allocate
118
+ attributes.each do |name, key|
119
+ object.instance_variable_set(unpack_object(name), unpack_object(key))
120
+ end
121
+ object
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ if __FILE__ == $0
129
+ require "active_support/all"
130
+ class Thing
131
+ attr_accessor :ace, :b, :c, :t
132
+
133
+ def initialize
134
+ @ace, @b, @c, @t = nil, nil, nil, nil
135
+ end
136
+
137
+ def inspect
138
+ "<#Thing:#{object_id} a:#{ace.size} things b:#{b.inspect} c:#{c.inspect} t:<#Thing:#{t.to_s}> >"
139
+ end
140
+ end
141
+
142
+ t = Thing.new
143
+ t.b = "OMGt,t,t,t,t,t,t,t,t,t,t,tt,t,t,t,t,t,t,t,t,t,t,tt,t,t,t,t,t,t,t,t,t,t,tt,t,t,t,t,t,t,t,t,t,t,tt,t,t,t,t,t,t,t,t,t,t,t"
144
+ t.ace = [Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new,Thing.new]
145
+ t.c = 123
146
+ t.t = t
147
+
148
+
149
+ include AlphaSimprini::Heap
150
+ p = Packer.new
151
+ p.pack(t, 'thing')
152
+ require "msgpack"
153
+
154
+ puts p.to_h.to_json
155
+ # puts p.to_h.to_msgpack.bytesize
156
+ # puts p.to_h.to_json.bytesize
157
+ # puts MessagePack.unpack(p.to_h.to_msgpack)
158
+ # MessagePack.unpack(p.to_h.to_msgpack)
159
+ # puts Unpacker.new(MessagePack.unpack(p.to_h.to_msgpack)).named_objects['thing'].t.inspect
160
+ # puts Unpacker.new(MessagePack.unpack(p.to_h.to_msgpack)).named_objects['thing'].ace.first.inspect
161
+ end
@@ -0,0 +1,37 @@
1
+ require "erector"
2
+ module AlphaSimprini
3
+ class Page < Erector::Widget
4
+ def content
5
+ text :doctype_html
6
+ html do
7
+ head do
8
+ csrf_meta_tag
9
+ title :application_title
10
+ assets
11
+ end
12
+ body do
13
+ body_content
14
+ end
15
+ end
16
+ end
17
+
18
+ def assets
19
+ end
20
+
21
+ def copy key
22
+ p t(key)
23
+ end
24
+
25
+ def text(value)
26
+ if value.is_a? Symbol
27
+ output << h(t(value))
28
+ else
29
+ super
30
+ end
31
+ end
32
+
33
+ def body_content
34
+ copy :blank
35
+ end
36
+ end
37
+ end