ambry 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e2b7327c7d7de90b929bc2a992ae5b5cab7041c2
4
+ data.tar.gz: 757b57a007b9158397cb4977ae0273f0d6266efc
5
+ SHA512:
6
+ metadata.gz: 3a7a675b2df9b66280fda61a5d02799a9dc74beb01255b201cc57966f74e56acaf9d6315bdd42d573e7d61fb109dd11ef6f1d4b0c88a742181319b61d21f86c1
7
+ data.tar.gz: 55d7932094033b8200045816919ba27868767e01c54fc23a2cdd6595aa54bd346206791ccd0202eee2a40f9e303a627d7bd8572807413ea3d591b4f5a0ec44ff
@@ -1,5 +1,10 @@
1
1
  # Ambry Changelog
2
2
 
3
+ ## [1.0.0](https://github.com/norman/ambry/tree/1.0.0) - 2016-07-22 ([diff](https://github.com/norman/ambry/compare/0.3.1...1.0.0))
4
+
5
+ * Make ambry compatible with Rails 5
6
+ * Drop `ActiveModel::Serializers::Xml` support
7
+
3
8
  ## [0.3.1](https://github.com/norman/ambry/tree/0.3.1) - 2012-06-20 ([diff](https://github.com/norman/ambry/compare/0.3.0...0.3.1))
4
9
 
5
10
  ### [Norman Clarke](https://github.com/norman)
data/Gemfile CHANGED
@@ -1,2 +1,3 @@
1
- source :rubygems
2
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/README.md CHANGED
@@ -14,49 +14,51 @@ quick samples.
14
14
 
15
15
  ## A quick tour
16
16
 
17
- # Create a model.
18
- class Country
19
- # Turn any Ruby object into a Ambry model by extending this module.
20
- extend Ambry::Model
21
-
22
- # The first field listed here will be the "primary key."
23
- field :tld, :name
24
-
25
- # Chainable filters, sort of like Active Record scopes.
26
- filters do
27
- def big
28
- find {|c| c.population > 100_000_000}
29
- end
30
-
31
- def in_region(region)
32
- find {|c| c.region == region)
33
- end
34
-
35
- def alphabetical
36
- sort_by {|c| c.name}
37
- end
38
- end
39
-
40
- # Root filter, can be used to setup relations.
41
- def regions
42
- Region.find {|r| r.id == region}
43
- end
17
+ ```ruby
18
+ # Create a model.
19
+ class Country
20
+ # Turn any Ruby object into a Ambry model by extending this module.
21
+ extend Ambry::Model
22
+
23
+ # The first field listed here will be the "primary key."
24
+ field :tld, :name
25
+
26
+ # Chainable filters, sort of like Active Record scopes.
27
+ filters do
28
+ def big
29
+ find {|c| c.population > 100_000_000 }
30
+ end
44
31
 
32
+ def in_region(region)
33
+ find {|c| c.region == region }
45
34
  end
46
35
 
47
- # create some contries
48
- Country.create :tld => "AR", :name => "Argentina", :region => :america, :population => 40_000_000
49
- Country.create :tld => "CA", :name => "Canada", :region => :america, :population => 34_000_000
50
- Country.create :tld => "JP", :name => "Japan", :region => :asia, :population => 127_000_000
51
- Country.create :tld => "CN", :name => "China", :region => :asia, :population => 1_300_000_000
52
- # etc.
53
-
54
- # Do some searches
55
- big_asian_countries = Country.big.in_region(:asia)
56
- countries_that_start_with_c = Country.find {|c| c.name =~ /^C/}
57
- # #first and #last only make sense if you run Ruby 1.9 (creation order) or explicitly specified an order
58
- first_alphabetical = Country.alphabetical.first
59
- last_alphabetical = Country.alphabetical.last
36
+ def alphabetical
37
+ sort_by {|c| c.name }
38
+ end
39
+ end
40
+
41
+ # Root filter, can be used to setup relations.
42
+ def regions
43
+ Region.find {|r| r.id == region }
44
+ end
45
+
46
+ end
47
+
48
+ # create some contries
49
+ Country.create :tld => "AR", :name => "Argentina", :region => :america, :population => 40_000_000
50
+ Country.create :tld => "CA", :name => "Canada", :region => :america, :population => 34_000_000
51
+ Country.create :tld => "JP", :name => "Japan", :region => :asia, :population => 127_000_000
52
+ Country.create :tld => "CN", :name => "China", :region => :asia, :population => 1_300_000_000
53
+ # etc.
54
+
55
+ # Do some searches
56
+ big_asian_countries = Country.big.in_region(:asia)
57
+ countries_that_start_with_c = Country.find {|c| c.name =~ /^C/ }
58
+ # #first and #last only make sense if you run Ruby 1.9 (creation order) or explicitly specified an order
59
+ first_alphabetical = Country.alphabetical.first
60
+ last_alphabetical = Country.alphabetical.last
61
+ ```
60
62
 
61
63
  ## When should I use Ambry?
62
64
 
@@ -17,9 +17,8 @@ Gem::Specification.new do |s|
17
17
  flexible searching and storage.
18
18
  EOD
19
19
  s.add_development_dependency "ffaker"
20
- s.add_development_dependency "minitest", "~> 2.2.2"
21
- s.add_development_dependency "mocha"
22
- s.add_development_dependency "activesupport", "~> 3.0"
23
- s.add_development_dependency "activemodel", "~> 3.0"
20
+ s.add_development_dependency "minitest", "~> 5.1"
21
+ s.add_development_dependency "activesupport", "~> 5.0"
22
+ s.add_development_dependency "activemodel", "~> 5.0"
24
23
  s.add_development_dependency "rake"
25
24
  end
@@ -14,7 +14,6 @@ module Ambry
14
14
  extend ::ActiveModel::Translation
15
15
  include ::ActiveModel::Validations
16
16
  include ::ActiveModel::Serializers::JSON
17
- include ::ActiveModel::Serializers::Xml
18
17
  extend ::ActiveModel::Callbacks
19
18
  define_model_callbacks :save, :destroy
20
19
  end
@@ -6,7 +6,7 @@ module Ambry
6
6
  class YAML < File
7
7
 
8
8
  def import_data
9
- data = ::YAML.load(::File.read(file_path))
9
+ ::YAML.load(::File.read(file_path))
10
10
  end
11
11
 
12
12
  def export_data
@@ -1,8 +1,8 @@
1
1
  module Ambry
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 3
5
- TINY = 1
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ TINY = 0
6
6
  BUILD = nil
7
7
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
8
8
  end
@@ -81,15 +81,7 @@ describe Ambry::ActiveModel do
81
81
  it "should serialize" do
82
82
  json = @model.to_json
83
83
  refute_nil @model.to_json
84
- assert_match /"author":"Leo Tolstoy"/, json
85
- end
86
- end
87
-
88
- describe "#to_xml" do
89
- it "should serialize to XML" do
90
- xml = @model.to_xml
91
- refute_nil xml
92
- assert_match /<author>Leo Tolstoy<\/author>/, xml
84
+ assert_match(/"author":"Leo Tolstoy"/, json)
93
85
  end
94
86
  end
95
87
 
@@ -33,7 +33,7 @@ classes.each do |klass|
33
33
  describe "#save_database" do
34
34
  it "should write the data to disk" do
35
35
  assert @adapter.save_database
36
- assert File.exists? @path
36
+ assert File.exist? @path
37
37
  end
38
38
 
39
39
  it "should raise an AmbryError if it's read-only" do
@@ -62,12 +62,12 @@ describe Ambry::Mapper do
62
62
  end
63
63
 
64
64
  it "should set value#to_hash as value for key" do
65
- value = Person.mapper[:bogus] = Value.new(:a => "b")
65
+ Person.mapper[:bogus] = Value.new(:a => "b")
66
66
  assert_equal "b", Person.mapper[:bogus][:a]
67
67
  end
68
68
 
69
69
  it "should freeze the value" do
70
- value = Person.mapper[:bogus] = Value.new(:a => "b")
70
+ Person.mapper[:bogus] = Value.new(:a => "b")
71
71
  assert Person.mapper[:bogus].frozen?
72
72
  end
73
73
  end
@@ -1,7 +1,6 @@
1
1
  require File.expand_path("../spec_helper", __FILE__)
2
2
 
3
3
  describe Ambry::Model do
4
-
5
4
  before { load_fixtures }
6
5
  after { Ambry.adapters.clear }
7
6
 
@@ -23,8 +22,8 @@ describe Ambry::Model do
23
22
  end
24
23
 
25
24
  it "calls the block after setting sttributes" do
26
- p = Person.new(:name => "foo") {|p| p.name = "bar"}
27
- assert_equal "bar", p.name
25
+ person = Person.new(:name => "foo") {|p| p.name = "bar"}
26
+ assert_equal "bar", person.name
28
27
  end
29
28
 
30
29
  it "can set attributes from a hash" do
@@ -34,14 +33,21 @@ describe Ambry::Model do
34
33
 
35
34
  # This means your custom accessors will be invoked.
36
35
  it "invokes attr writers" do
37
- Person.any_instance.expects(:name=).once
38
- Person.new(:name => "joe")
36
+ class Person
37
+ def name=(val); @name = "doe"; end
38
+ end
39
+ p = Person.new(:name => "joe")
40
+ class Person
41
+ def name=(val); @name = val; end
42
+ end
43
+
44
+ assert_equal "doe", p.name
39
45
  end
40
46
 
41
47
  # Don't loop through params that potentially came from the Internet,
42
48
  # because we need to cast keys to Symbol, and that could leak memory.
43
49
  it "iterates over attribute names, not params" do
44
- Person.attribute_names.expects(:each)
50
+ assert_send([Person.attribute_names, :each])
45
51
  Person.new(:name => "joe")
46
52
  end
47
53
  end
@@ -161,7 +167,7 @@ describe Ambry::Model do
161
167
  describe "#save" do
162
168
  it "passes itself to Mapper#put" do
163
169
  p = Person.new(:name => "hello")
164
- Person.mapper.expects(:put)
170
+ assert_send([Person.mapper, :put, p])
165
171
  p.save
166
172
  end
167
173
  end
@@ -7,7 +7,6 @@ require "bundler/setup"
7
7
  require "ambry"
8
8
  require "ambry/adapters/yaml"
9
9
  require 'minitest/spec'
10
- require "mocha"
11
10
  require "fileutils"
12
11
  require "ffaker"
13
12
 
@@ -39,4 +38,4 @@ def load_fixtures
39
38
  Person.use :main
40
39
  end
41
40
 
42
- MiniTest::Unit.autorun
41
+ MiniTest.autorun
metadata CHANGED
@@ -1,115 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ambry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Norman Clarke
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
11
+ date: 2016-07-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ffaker
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 2.2.2
33
+ version: '5.1'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 2.2.2
46
- - !ruby/object:Gem::Dependency
47
- name: mocha
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
40
+ version: '5.1'
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: activesupport
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ~>
45
+ - - "~>"
68
46
  - !ruby/object:Gem::Version
69
- version: '3.0'
47
+ version: '5.0'
70
48
  type: :development
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
- - - ~>
52
+ - - "~>"
76
53
  - !ruby/object:Gem::Version
77
- version: '3.0'
54
+ version: '5.0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: activemodel
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
- - - ~>
59
+ - - "~>"
84
60
  - !ruby/object:Gem::Version
85
- version: '3.0'
61
+ version: '5.0'
86
62
  type: :development
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
- - - ~>
66
+ - - "~>"
92
67
  - !ruby/object:Gem::Version
93
- version: '3.0'
68
+ version: '5.0'
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: rake
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
- - - ! '>='
73
+ - - ">="
100
74
  - !ruby/object:Gem::Version
101
75
  version: '0'
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
- - - ! '>='
80
+ - - ">="
108
81
  - !ruby/object:Gem::Version
109
82
  version: '0'
110
- description: ! " Ambry is not an ORM, man! It's a database and ORM replacement
111
- for (mostly)\n static models and small datasets. It provides ActiveModel compatibility,
112
- and\n flexible searching and storage.\n"
83
+ description: |2
84
+ Ambry is not an ORM, man! It's a database and ORM replacement for (mostly)
85
+ static models and small datasets. It provides ActiveModel compatibility, and
86
+ flexible searching and storage.
113
87
  email: norman@njclarke.com
114
88
  executables: []
115
89
  extensions: []
@@ -145,33 +119,26 @@ files:
145
119
  - spec/spec_helper.rb
146
120
  homepage: http://github.com/norman/ambry
147
121
  licenses: []
122
+ metadata: {}
148
123
  post_install_message:
149
124
  rdoc_options: []
150
125
  require_paths:
151
126
  - lib
152
127
  required_ruby_version: !ruby/object:Gem::Requirement
153
- none: false
154
128
  requirements:
155
- - - ! '>='
129
+ - - ">="
156
130
  - !ruby/object:Gem::Version
157
131
  version: '0'
158
- segments:
159
- - 0
160
- hash: -2496886611082865367
161
132
  required_rubygems_version: !ruby/object:Gem::Requirement
162
- none: false
163
133
  requirements:
164
- - - ! '>='
134
+ - - ">="
165
135
  - !ruby/object:Gem::Version
166
136
  version: '0'
167
- segments:
168
- - 0
169
- hash: -2496886611082865367
170
137
  requirements: []
171
- rubyforge_project: ! '[none]'
172
- rubygems_version: 1.8.24
138
+ rubyforge_project: "[none]"
139
+ rubygems_version: 2.5.1
173
140
  signing_key:
174
- specification_version: 3
141
+ specification_version: 4
175
142
  summary: An ActiveModel-compatible ORM-like library for storing model instances in
176
143
  an in-memory Hash.
177
144
  test_files: []