epiphy 0.0.1

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.
@@ -0,0 +1,33 @@
1
+ module Epiphy
2
+ module Repository
3
+
4
+ # Configuration class for repository.
5
+ #
6
+ # Storing Epiphy::Adapter::RethinkDB instance, and RethinkDB run
7
+ # option.
8
+ #
9
+ # @example
10
+ # adapter = Epiphy::Adapter::Rethinkdb.new connection
11
+ # Epiphy::Repository.configure do |config|
12
+ # config.adapter = adapter
13
+ # end
14
+ # @api private
15
+ # @since 0.0.1
16
+ #
17
+ class Configuration
18
+ attr_accessor :adapter
19
+ attr_accessor :run_option
20
+
21
+ def initalize
22
+ @run_option = {
23
+ use_outdated: false,
24
+ time_format: 'native',
25
+ profile: false,
26
+ durability: 'hard',
27
+ group_format: 'native',
28
+ no_reply: false
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ module Epiphy
2
+ module Repository
3
+ # Custom enumetable on top of RethinkDB cursor so we can convert the hash
4
+ # to the Entity object.
5
+ #
6
+ # For the ReQL that returns a cursor, we won't grab the array and convet the
7
+ # hash into Entity object. Instead, we will use aan enumerable and the
8
+ # Repository leverage it to convert the hash to entity object.
9
+ #
10
+ # An cursor can be convert to an arrya with `.to_a` method
11
+ #
12
+ # @see Epiphy::Repository#all
13
+ # @see Epiphy::Adapter::Rethinkdb#all
14
+ #
15
+ # @example
16
+ # cursor = r.table()...
17
+ # all = Epiphy::Repository::Cursor.new(cursor) do |item|
18
+ # item = transform_item_with_something_if_need
19
+ # end
20
+ #
21
+ # @since 0.1.0
22
+ # @api public
23
+ #
24
+ class Cursor
25
+ include Enumerable
26
+ attr_reader :cursor, :transform
27
+
28
+ def initialize(cursor, &transform)
29
+ @cursor = cursor
30
+ @transform = transform
31
+ end
32
+
33
+ def each
34
+ raise ArgumentError, 'Missing a block to enumate cursor' unless block_given?
35
+ @cursor.each do |item|
36
+ item = @transform.call item
37
+ yield item
38
+ #if block_given?
39
+ #block.call person
40
+ #else
41
+ #yield person
42
+ #end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,6 @@
1
+ module Epiphy
2
+ # Defines the version
3
+ #
4
+ # @since 0.0.1
5
+ VERSION = '0.0.1'.freeze
6
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: epiphy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vinh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-04-28 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
55
+ description: A simple ORM for RethinkDB. Stealing Lotus::Model to learn how to write
56
+ an ORM and API design
57
+ email: kurei@axcoto.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.md
63
+ - lib/epiphy.rb
64
+ - lib/epiphy/adapter/error.rb
65
+ - lib/epiphy/adapter/helper.rb
66
+ - lib/epiphy/adapter/model.rb
67
+ - lib/epiphy/adapter/rethinkdb.rb
68
+ - lib/epiphy/connection.rb
69
+ - lib/epiphy/entity.rb
70
+ - lib/epiphy/model.rb
71
+ - lib/epiphy/repository.rb
72
+ - lib/epiphy/repository/configuration.rb
73
+ - lib/epiphy/repository/cursor.rb
74
+ - lib/epiphy/version.rb
75
+ homepage: http://rubygems.org/gems/hola
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 2.0.0
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.1
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: RethinkDB ORM
99
+ test_files: []
100
+ has_rdoc: