data_structure 0.0.1.rc0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d391f6993add35a4a2a8763c3074361b2230158c
4
+ data.tar.gz: c3e92bc82294309343d0c4706162624e07faf387
5
+ SHA512:
6
+ metadata.gz: d8742dc19f8abac18ea74f0daa469bda5366858bfc09de75c4407f2f63235e125833247fbec12edda5119571e606259eeb92dee4370d63b1d14a3767e621a39e
7
+ data.tar.gz: 171b2eafd7775991e2c59ad8c893fb3ff7fda6a89a78876c6c0f03eb6ab51518dac6237f82fa25215205a2a96d1cba2e725140effc00efc7680b59561e85bcb1
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in data_structure.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ ##########################################################################
2
+ #
3
+ # Copyright 2013 Notre Dame
4
+ # Additional copyright may be held by others, as reflected in the commit log
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # DataStructure
2
+
3
+ Programatically declare your data structures for various contexts.
4
+
5
+ Why DataStructure?
6
+ We are asked to model a breadth of topics: from Books, to Datasets, to Brains.
7
+ And for those topics, we are asked to render things in specific and rather arbitrary roles: editor, author, admin.
8
+ And for those topics, we also need to render things in a specific mode: discovery, show, edit.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'data_structure'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install data_structure
23
+
24
+ ## Usage
25
+
26
+ Bear with me as these are aspirations.
27
+ Ultimately, I want to model the data structure of an object in its various contexts.
28
+ I also want to be mindful that we could auto-build a data structure from a well-formed underlying model.
29
+
30
+ ```ruby
31
+ # app/models/book/edit.html.erb
32
+ class Book < ActiveRecord::Base
33
+ def to_data_structure(context, options)
34
+ Book::DataStructure.new(self, context, options)
35
+ end
36
+ end
37
+
38
+ # app/models/book/data_structure.rb
39
+ class Book::DataStructure
40
+ include DataStructure
41
+
42
+ attribute :title, mode: [:edit, :show], role: :editor, section: :required
43
+ attribute :description, mode: [:show], role: :editor, section: :optional
44
+ end
45
+
46
+ # app/controllers/books_controller.rb
47
+ class BooksController < ApplicationController
48
+
49
+ def show
50
+ book = Book.find(params[:id])
51
+ @book = book.to_data_structure(self, mode: :show, role: current_user_role)
52
+ end
53
+
54
+ def edit
55
+ book = Book.find(params[:id])
56
+ @book = book.to_data_structure(self, mode: :edit, role: current_user_role)
57
+ end
58
+
59
+ private
60
+ def current_user_role
61
+ current_user.is_admin? ? :editor : nil
62
+ end
63
+ end
64
+
65
+ # app/views/book/edit.html.erb
66
+ <%= form_for(@book) do |f| %>
67
+ <% @book.each_attribute_for_section(:required) do |attribute| %>
68
+ <%= attribute.render(f) %>
69
+ <% end %>
70
+ <% end %>
71
+
72
+ # app/views/book/show.html.erb
73
+ <% @book.each_section do |section| %>
74
+ <%= section.render(self) %>
75
+ <% end %>
76
+ ```
77
+
78
+ ## Contributing
79
+
80
+ 1. Fork it
81
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
82
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
83
+ 4. Push to the branch (`git push origin my-new-feature`)
84
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'data_structure/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "data_structure"
8
+ spec.version = DataStructure::VERSION
9
+ spec.authors = ["Jeremy Friesen"]
10
+ spec.email = ["jeremy.n.friesen@gmail.com"]
11
+ spec.description = %q{Programatically declare your data structures for various contexts.}
12
+ spec.summary = %q{Programatically declare your data structures for various contexts.}
13
+ spec.homepage = "https://github.com/jeremyf/data_structure"
14
+ spec.license = "APACHE2"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,5 @@
1
+ require "data_structure/version"
2
+
3
+ module DataStructure
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module DataStructure
2
+ VERSION = "0.0.1.rc0"
3
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: data_structure
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.rc0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Friesen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Programatically declare your data structures for various contexts.
42
+ email:
43
+ - jeremy.n.friesen@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - data_structure.gemspec
54
+ - lib/data_structure.rb
55
+ - lib/data_structure/version.rb
56
+ homepage: https://github.com/jeremyf/data_structure
57
+ licenses:
58
+ - APACHE2
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>'
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.1
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.0.3
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Programatically declare your data structures for various contexts.
80
+ test_files: []