frisky_mongo 0.7.2 → 0.7.7

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.
@@ -16,5 +16,5 @@ module Frisky
16
16
  end
17
17
  end
18
18
 
19
- def mongo; @@mongo; end
19
+ def self.mongo; @@mongo[@@mongo_database]; end
20
20
  end
@@ -15,7 +15,7 @@ module Frisky
15
15
  key :repository_id, ObjectId
16
16
  key :stats, Hash
17
17
  key :committer_id, ObjectId
18
- key :files, Array
18
+ key :file_ids, Array
19
19
  key :tree, String
20
20
  key :date, Time
21
21
  key :sha, String
@@ -25,20 +25,22 @@ module Frisky
25
25
  belongs_to :repository, class_name: 'Frisky::Model::Repository'
26
26
 
27
27
  many :parents, in: :parent_ids, class_name: 'Frisky::Model::Commit'
28
+ many :files, in: :file_ids, class_name: 'Frisky::Model::FileCommit'
28
29
 
29
- proxy_methods author: lambda { Person.find(author_id) }
30
- proxy_methods committer: lambda { Person.find(committer_id) }
30
+ proxy_methods author: lambda { Person.find(author_id) or raise NotFound }
31
+ proxy_methods committer: lambda { Person.find(committer_id) or raise NotFound }
31
32
  proxy_methods repository: lambda { Repository.find(repository_id) }
32
33
 
33
34
  def save(*args)
34
- self.author.save if self.author
35
- self.repository.save if self.repository
36
- self.committer.save if self.committer
35
+ self.author.save if self.no_proxy_author
36
+ self.repository.save
37
+ self.committer.save if self.no_proxy_committer
37
38
 
38
- self.author_id ||= self.author.id if self.author
39
+ self.author_id ||= self.author.id if self.no_proxy_author
39
40
  self.repository_id ||= self.repository.id
40
- self.committer_id ||= self.committer.id if self.committer
41
+ self.committer_id ||= self.committer.id if self.no_proxy_committer
41
42
  self.parent_ids |= self.parents.map(&:id) if self.no_proxy_parents
43
+ self.file_ids |= self.files.map(&:id) if self.no_proxy_files
42
44
  super(*args)
43
45
  end
44
46
  end
@@ -11,6 +11,7 @@ module Frisky
11
11
  key :commit_ids, Array, default: nil
12
12
  key :ref, String
13
13
  key :head, String
14
+ key :created_at, String
14
15
 
15
16
  belongs_to :actor, class_name: 'Frisky::Model::Person'
16
17
  belongs_to :repository, class_name: 'Frisky::Model::Repository'
@@ -18,7 +19,6 @@ module Frisky
18
19
  many :commits, in: :commit_ids, class_name: 'Frisky::Model::Commit'
19
20
 
20
21
  def self.load_from_hashie(hashie)
21
-
22
22
  e = Event.find(hashie.id)
23
23
  e.actor = Person.find(e.actor_id)
24
24
  e.repository = Repository.find(e.repository_id)
@@ -0,0 +1,40 @@
1
+ module Frisky
2
+ module Model
3
+ class FileCommit < ProxyBase
4
+ include MongoMapper::Document
5
+
6
+ primary_fetch do |args|
7
+ FileCommit.where(repository_id: args[:repository].id,
8
+ commit_id: args[:commit].id,
9
+ path: args[:path]).first or raise NotFound
10
+ end
11
+
12
+ key :changes, Integer
13
+ key :path, String
14
+ key :deletions, Integer
15
+ key :status, String
16
+ key :patch, String
17
+ key :additions, Integer
18
+ key :sha, String
19
+ key :type, String
20
+ key :repository_id, ObjectId
21
+ key :commit_id, ObjectId
22
+
23
+ belongs_to :commit, class_name: 'Frisky::Model::Commit'
24
+ belongs_to :repository, class_name: 'Frisky::Model::Repository'
25
+
26
+ proxy_methods commit: lambda { Commit.find(commit_id) }
27
+ proxy_methods repository: lambda { Repository.find(repository_id) }
28
+
29
+ def save(*args)
30
+ self.repository.save if self.repository
31
+ self.commit.save if self.commit
32
+
33
+ self.repository_id ||= self.repository.id
34
+ self.commit_id ||= self.commit.id if self.commit
35
+
36
+ super(*args)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -3,8 +3,11 @@ module Frisky
3
3
  class Person < ProxyBase
4
4
  include MongoMapper::Document
5
5
 
6
+ fetch_key :id
7
+
6
8
  primary_fetch do |args|
7
- p = Person.where(login: args[:login]).first if args[:login]
9
+ p = Person.where(_id: args[:id]).first if args[:id]
10
+ p ||= Person.where(login: args[:login]).first if args[:login]
8
11
  p ||= Person.where(email: args[:email]).first if args[:email]
9
12
  p or raise NotFound
10
13
  end
@@ -17,6 +20,15 @@ module Frisky
17
20
  key :blog, String
18
21
  key :company, String
19
22
  key :followers, Integer
23
+ key :gravatar_id, String
24
+ key :avatar_url, String
25
+ key :html_url, String
26
+
27
+ def self.load_from_raw(raw)
28
+ model = super(raw)
29
+ model.save if model.new?
30
+ model
31
+ end
20
32
  end
21
33
  end
22
34
  end
@@ -18,10 +18,22 @@ module Frisky
18
18
  key :full_name, String
19
19
  key :name, String
20
20
  key :url, String
21
+ key :contributors, Object
21
22
 
22
23
  timestamps!
23
24
 
24
25
  belongs_to :owner, class_name: 'Frisky::Model::Person'
26
+
27
+ def save(*args)
28
+ if self.no_proxy_contributors
29
+ cvalues = {}
30
+ self.no_proxy_contributors.each do |c, value|
31
+ cvalues[c.to_s] = value
32
+ end
33
+ self.contributors = cvalues
34
+ end
35
+ super(*args)
36
+ end
25
37
  end
26
38
  end
27
39
  end
@@ -1,3 +1,3 @@
1
1
  module FriskyMongo
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.7'
3
3
  end
@@ -7,6 +7,7 @@ module Frisky
7
7
  EXTENSIONS << 'frisky-mongo/models/event'
8
8
  EXTENSIONS << 'frisky-mongo/models/person'
9
9
  EXTENSIONS << 'frisky-mongo/models/commit'
10
+ EXTENSIONS << 'frisky-mongo/models/file_commit'
10
11
  EXTENSIONS << 'frisky-mongo/models/repository'
11
12
  end
12
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frisky_mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.7
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: 2012-12-18 00:00:00.000000000 Z
12
+ date: 2012-12-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongo_mapper
@@ -53,6 +53,7 @@ files:
53
53
  - lib/frisky-mongo/config.rb
54
54
  - lib/frisky-mongo/models/commit.rb
55
55
  - lib/frisky-mongo/models/event.rb
56
+ - lib/frisky-mongo/models/file_commit.rb
56
57
  - lib/frisky-mongo/models/person.rb
57
58
  - lib/frisky-mongo/models/repository.rb
58
59
  - lib/frisky-mongo/version.rb
@@ -74,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
75
  version: '0'
75
76
  segments:
76
77
  - 0
77
- hash: -465721437505510034
78
+ hash: 3428720357865536698
78
79
  required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  none: false
80
81
  requirements: