metadata 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -17,21 +17,7 @@ email:
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
- files:
21
- - .gitignore
22
- - Gemfile
23
- - LICENSE
24
- - README.md
25
- - Rakefile
26
- - lib/metadata.rb
27
- - lib/metadata/formats.rb
28
- - lib/metadata/formats/base.rb
29
- - lib/metadata/formats/json.rb
30
- - lib/metadata/formats/string.rb
31
- - lib/metadata/hook.rb
32
- - lib/metadata/rails/model/active_record.rb
33
- - lib/metadata/version.rb
34
- - metadata.gemspec
20
+ files: []
35
21
  homepage: https://github.com/colinyoung/metadata
36
22
  licenses: []
37
23
  post_install_message:
data/.gitignore DELETED
@@ -1,17 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in metadata.gemspec
4
- gemspec
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Colin Young
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,41 +0,0 @@
1
- # Metadata
2
-
3
- ## Usage
4
-
5
- class User < ActiveRecord::Base
6
- metadata do |obj|
7
- puts obj.name
8
- is a: 'user'
9
- with friends: obj.friends.count
10
- stop
11
- end
12
-
13
- Results in
14
-
15
- Joe is a user with 37 friends.
16
-
17
- ## Installation
18
-
19
- Add this line to your application's Gemfile:
20
-
21
- gem 'metadata'
22
-
23
- And then execute:
24
-
25
- $ bundle
26
-
27
- Or install it yourself as:
28
-
29
- $ gem install metadata
30
-
31
- ## Usage
32
-
33
- TODO: Write usage instructions here
34
-
35
- ## Contributing
36
-
37
- 1. Fork it
38
- 2. Create your feature branch (`git checkout -b my-new-feature`)
39
- 3. Commit your changes (`git commit -am 'Added some feature'`)
40
- 4. Push to the branch (`git push origin my-new-feature`)
41
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
@@ -1,48 +0,0 @@
1
- module Metadata
2
- module Formats
3
- class Base
4
- attr_accessor :output
5
- attr_accessor :object
6
-
7
- def initialize(object, &block)
8
- @output = []
9
- @object = object
10
-
11
- instance_exec(@object, &block)
12
- end
13
-
14
- def puts(str)
15
- str = str.capitalize if @output.empty?
16
- @output << str
17
- end
18
-
19
- def is(*args)
20
- end
21
-
22
- def was(*args)
23
- end
24
-
25
- def it(*args)
26
- end
27
-
28
- def around(*args)
29
- end
30
-
31
- def about(*args)
32
- end
33
-
34
- def with(*args)
35
- end
36
-
37
- def stop
38
- end
39
-
40
- protected
41
-
42
- def word(word)
43
- word.to_s # @todo Translate
44
- end
45
-
46
- end
47
- end
48
- end
@@ -1,9 +0,0 @@
1
- module Metadata
2
- module Formats
3
- class JSON < Base
4
- def self.output(*args, &block)
5
- raise "JSON Not Implemented yet."
6
- end
7
- end
8
- end
9
- end
@@ -1,79 +0,0 @@
1
- module Metadata
2
- module Formats
3
- class String < Base
4
-
5
- DICTIONARY = {
6
- 'is' => {
7
- present: 'is',
8
- past: 'was'
9
- }
10
- }
11
-
12
- def initialize(object, &block)
13
- @next = {}
14
- super(object, &block)
15
- end
16
-
17
- def is(something, tense=:present)
18
- something = pairs(something) if something.is_a?(Hash)
19
-
20
- @output << statement(change_tense(word(:is), tense), something)
21
- end
22
-
23
- def was(something)
24
- is(something, :past)
25
- end
26
-
27
- def it(something)
28
- something = pairs(something) if something.is_a?(Hash)
29
-
30
- @output << statement(word(:it), something)
31
- end
32
-
33
- def with(hash)
34
- @output << ::String.new.tap do |s|
35
- hash.map do |k,v|
36
- k = k.to_s
37
- k = k.singularize if k.respond_to? :singularize and v == 1
38
- s << statement(word(:with), v, k)
39
- end
40
- end
41
- end
42
-
43
- def stop
44
- @output << "."
45
- @next[:capitalize] = true
46
- end
47
-
48
- def around(*args)
49
- @output << statement(word(:around), args.first)
50
- end
51
-
52
- def and_
53
- @output << word(:and)
54
- end
55
-
56
- def to_s
57
- statement(*@output)
58
- end
59
-
60
- private
61
-
62
- def statement(*args)
63
- if @next[:capitalize]
64
- args[0] = args[0].to_s.capitalize
65
- @next.delete :capitalize
66
- end
67
- args.join(' ').strip.gsub(' .', '.')
68
- end
69
-
70
- def pairs(something)
71
- statement(something.keys.first, something.values.first)
72
- end
73
-
74
- def change_tense(verb, tense)
75
- DICTIONARY[verb][tense]
76
- end
77
- end
78
- end
79
- end
@@ -1,13 +0,0 @@
1
- require 'metadata/formats/base'
2
- require 'metadata/formats/json'
3
- require 'metadata/formats/string'
4
-
5
- module Metadata
6
- module Format
7
-
8
- def self.named(name, &block)
9
- Metadata::Formats.const_get(name.to_s.classify)
10
- end
11
-
12
- end
13
- end
data/lib/metadata/hook.rb DELETED
@@ -1,20 +0,0 @@
1
- module Metadata
2
- module Hook
3
-
4
- def metadata(args={})
5
- # Self right now is the object that has metadata on it
6
- options = self.class._metadata.merge(args)
7
- format = Metadata::Format.named(options[:format])
8
- format.new(self, &options[:block])
9
- end
10
-
11
- module ClassMethods
12
- attr_accessor :_metadata
13
-
14
- def metadata(*args, &block)
15
- options = args.first.is_a?(Hash) ? args.first : {}
16
- self._metadata = {format: options[:format] || :string, block: block}
17
- end
18
- end
19
- end
20
- end
@@ -1,3 +0,0 @@
1
- class ActiveRecord::Base
2
- include Metadata
3
- end
@@ -1,3 +0,0 @@
1
- module Metadata
2
- VERSION = "0.0.1"
3
- end
data/lib/metadata.rb DELETED
@@ -1,13 +0,0 @@
1
- require "metadata/version"
2
- require "metadata/hook"
3
- require "metadata/formats"
4
-
5
- module Metadata
6
- include Hook
7
-
8
- def self.included(base)
9
- base.extend Hook::ClassMethods
10
- end
11
- end
12
-
13
- require "metadata/rails/model/active_record" if Rails
data/metadata.gemspec DELETED
@@ -1,17 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/metadata/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Colin Young"]
6
- gem.email = ["me@colinyoung.com"]
7
- gem.description = %q{Generate metadata from any ruby object (works great with rails.)}
8
- gem.summary = %q{Metadata is an easy way to represent an object in a human or machine readable format.}
9
- gem.homepage = "https://github.com/colinyoung/metadata"
10
-
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "metadata"
15
- gem.require_paths = ["lib"]
16
- gem.version = Metadata::VERSION
17
- end