dolly 3.1.3 → 3.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc95f5c129eb675fa694d16b7f1eefaacd9d8c52dbadf38b0f039a02d4f547a8
4
- data.tar.gz: 5a55b4eb560aee3ffe45796eed3834833a80ef2da2d8cae115db9c4561debb3d
3
+ metadata.gz: c05943aabfd347226c64d622f7e2f872ad8f1f78e52e1229697a3a60364a5e53
4
+ data.tar.gz: 7a64b93ef1232cec80ca842f9d4e4ebb5dd1e260b967549d8b6ec0d12b0e929d
5
5
  SHA512:
6
- metadata.gz: 036f683c88a6a7c5b27852e3c9d874e182b2de313ead437e843d5b25c795e4ad68cea854c21856560c386df07f3c6d2d82ce837b58f7c0095dedd1f4c3701ea9
7
- data.tar.gz: 78275f902a858c32e23f9964726fdd0048b3e9b114e67bd9ad58224ba32711ef32155fc3ec90bc8ad3ec5cac6b2b25781d54cc423268120ac74be7aaa7f7f82a
6
+ metadata.gz: a50e0365e3dabf0620e6f0c2d13d57f029709616d02733758f2bb1317ef0d4906c4ec999dfef81f5dc95f94d94997dba36004ed1f3a7bf4f0be59f51895fe578
7
+ data.tar.gz: ff4faa8af117ef82db9c428387a0d31d24dd1d59f3e831d41fe4399ef03faf5ea710ac732bc39108a710191645fefdd31a5284a7448803de5dd1786893b704c0
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Dolly3
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dolly3`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ The thing you move your couch with...
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ![example workflow](https://github.com/amco/dolly/actions/workflows/ruby.yml/badge.svg)
6
6
 
7
7
  ## Installation
8
8
 
@@ -33,7 +33,7 @@ module Dolly
33
33
  def configuration
34
34
  @config_data ||= File.read(config_file)
35
35
  raise Dolly::InvalidConfigFileError if @config_data&.empty?
36
- YAML::load(ERB.new(@config_data).result)[app_env.to_s]
36
+ YAML::safe_load(ERB.new(@config_data).result, aliases: true)[app_env.to_s]
37
37
  end
38
38
 
39
39
  def config_file
@@ -27,13 +27,19 @@ module Dolly
27
27
  @app_env = defined?(Rails) ? Rails.env : app_env
28
28
  end
29
29
 
30
+ def skip_migrations?
31
+ env['skip_migrations']
32
+ end
33
+
30
34
  def get(resource, data = {})
31
35
  query = { query: values_to_json(data) } if data
32
36
  request :get, resource, query
33
37
  end
34
38
 
35
39
  def post resource, data
36
- request :post, resource.cgi_escape, data
40
+ query_str = to_query(data.delete(:query)) if data[:query]
41
+ query = "?#{query_str}" if query_str
42
+ request :post, "#{resource.cgi_escape}#{query}", data
37
43
  end
38
44
 
39
45
  def put resource, data
@@ -23,7 +23,10 @@ module Dolly
23
23
  end
24
24
 
25
25
  def create_in_database(database, name, fields, type = 'json')
26
- connection_for_database(database).post(DESIGN, build_index_structure(name, fields, type))
26
+ db_conn = connection_for_database(database)
27
+ return "Migrations for #{database} skiped." if db_conn.skip_migrations?
28
+
29
+ db_conn.post(DESIGN, build_index_structure(name, fields, type))
27
30
  end
28
31
 
29
32
  def find_by_fields(fields)
@@ -46,7 +49,8 @@ module Dolly
46
49
  private
47
50
 
48
51
  def connection_for_database(database)
49
- Dolly::Connection.new(database.to_sym, Rails.env || :development)
52
+ rails_env = defined?(Rails) ? Rails.env : :development
53
+ Dolly::Connection.new(database.to_sym, rails_env)
50
54
  end
51
55
 
52
56
  def connection
@@ -33,7 +33,7 @@ module Dolly
33
33
  end
34
34
 
35
35
  def update_doc(key, _value = nil)
36
- doc.regular_writer(key.to_s, instance_variable_get(:"@#{key}"))
36
+ doc[key.to_s] = instance_variable_get(:"@#{key}")
37
37
  end
38
38
 
39
39
  def properties
data/lib/dolly/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dolly
2
- VERSION = "3.1.3"
2
+ VERSION = "3.1.5"
3
3
  end
@@ -463,7 +463,7 @@ class DocumentTest < Test::Unit::TestCase
463
463
  test_foo = FooBar.new
464
464
  test_foo.foo = 'test_value'
465
465
  assert_equal 'test_value', test_foo.foo
466
- assert_equal 'test_value', test_foo.send(:doc)[:foo]
466
+ assert_equal 'test_value', test_foo.send(:doc)['foo']
467
467
  assert_equal 'test_value', test_foo.instance_variable_get(:@foo)
468
468
  end
469
469
 
@@ -21,7 +21,7 @@ class MangoIndexTest < Test::Unit::TestCase
21
21
  ddoc: nil,
22
22
  name:"_all_docs",
23
23
  type:"special",
24
- def:{ fields:[{ _id:"asc" }] }
24
+ def:{ fields:[{ _id: "asc" }] }
25
25
  },
26
26
  {
27
27
  ddoc: "_design/1",
@@ -32,6 +32,25 @@ class MangoIndexTest < Test::Unit::TestCase
32
32
  ]}.to_json)
33
33
  end
34
34
 
35
+ test '#create_in_database' do
36
+ assert_equal "Migrations for design_skipped skiped.", Dolly::MangoIndex.create_in_database(
37
+ :design_skipped,
38
+ "demo",
39
+ [:_id]
40
+ )
41
+ end
42
+
43
+ test '#create_in_database' do
44
+ stub_request(:post, "http://localhost:5984/test/_index").
45
+ to_return(status: 200, body: "Design doc run", headers: {})
46
+
47
+ assert_equal "Design doc run", Dolly::MangoIndex.create_in_database(
48
+ :default,
49
+ "demo",
50
+ [:_id]
51
+ )
52
+ end
53
+
35
54
  test '#delete_all' do
36
55
  previous_indexes = Dolly::MangoIndex.all
37
56
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolly
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - javierg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -178,7 +178,7 @@ files:
178
178
  homepage: https://www.amco.me
179
179
  licenses: []
180
180
  metadata: {}
181
- post_install_message:
181
+ post_install_message:
182
182
  rdoc_options: []
183
183
  require_paths:
184
184
  - lib
@@ -193,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  requirements: []
196
- rubygems_version: 3.0.3
197
- signing_key:
196
+ rubygems_version: 3.1.6
197
+ signing_key:
198
198
  specification_version: 4
199
199
  summary: will write something
200
200
  test_files: