cistern 2.8.0 → 2.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c46e3adcc00de17de88267eb956010d23a800448
4
- data.tar.gz: 55b688beea4299e4ff6ce8b2e7a417b57138aeef
2
+ SHA256:
3
+ metadata.gz: 6949d6bf767316892c02a7ae3ae1f14afc2cff8331b4fc0a72bf93295e126e7a
4
+ data.tar.gz: d2a27bae1d717ec47ed4f6135cc7fa4e635423a1f81e7facd2b616cf33eed3ef
5
5
  SHA512:
6
- metadata.gz: cf42fdb4f9909d0e5a388366eec9c12ac3154d8de3d431fd0319e64119d2d437ddf4f72fed4ce0a51c847f598b834ff1a7dbc3e5699018c42e632409e186e424
7
- data.tar.gz: '0542951ae0e2926ac3454c5140b7e15bc690fa6593b410277da23554f585da872b83006f7dfa9026569a9aa931100eb09759f0d96b74f29e774449542b5c6074'
6
+ metadata.gz: '02565729c04cff5108f5b3b7547e635b3c3a56dd239d00bb3108b8106a05ad7a50d79b03992dddea1a136bf66552d97a3c140d282a1218c73c5b0e4df1116b2a'
7
+ data.tar.gz: aa96a0b7dd8ad8e985e4ee8c9f1d22f8c8ca673b9ef9346d7771a4b853440791a7acef4a9f95fb6cb2c86b69f0d969bc8c8cc8f62f9a92c793798781601631cc
data/.travis.yml CHANGED
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
4
  - 2.2
5
+ - 2.4.1
5
6
  bundler_args: "--without development"
6
7
  before_install:
7
8
  - gem install bundler -v "~> 1.10"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## [Unreleased](https://github.com/lanej/cistern/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/lanej/cistern/compare/v2.7.2...HEAD)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - fix codeclimate reporting [\#80](https://github.com/lanej/cistern/pull/80) ([lanej](https://github.com/lanej))
10
+ - Add support for a Date type. [\#78](https://github.com/lanej/cistern/pull/78) ([leklund](https://github.com/leklund))
11
+ - fix 0.12 branch for ruby 2.4 [\#77](https://github.com/lanej/cistern/pull/77) ([ehowe](https://github.com/ehowe))
12
+
13
+ ## [v2.7.2](https://github.com/lanej/cistern/tree/v2.7.2) (2016-10-21)
14
+ [Full Changelog](https://github.com/lanej/cistern/compare/v2.7.1...v2.7.2)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - feature: add \#clone\_attributes [\#75](https://github.com/lanej/cistern/pull/75) ([lanej](https://github.com/lanej))
19
+ - fix: alias attributes= to merge\_attributes [\#74](https://github.com/lanej/cistern/pull/74) ([lanej](https://github.com/lanej))
20
+
3
21
  ## [v2.7.1](https://github.com/lanej/cistern/tree/v2.7.1) (2016-08-26)
4
22
  [Full Changelog](https://github.com/lanej/cistern/compare/v2.7.0...v2.7.1)
5
23
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cistern::Associations
3
4
 
4
5
  def self.extended(klass)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Attributes
2
4
  PROTECTED_METHODS = [:cistern, :service, :identity, :collection].freeze
3
5
  TRUTHY = ['true', '1'].freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Client
2
4
  module Collections
3
5
  def collections
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Collection
2
4
  include Cistern::HashSupport
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Coverage
2
4
  unless Kernel.respond_to? :caller_locations
3
5
  abort <<-ABORT
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Cistern::Data::Hash
2
4
  Cistern::Data.backends[:hash] = self
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Cistern::Data::Redis
2
4
  Cistern::Data.backends[:redis] = self
3
5
 
data/lib/cistern/data.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Data
2
4
  def self.extended(klass)
3
5
  klass.send(:extend, ClassMethods)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'awesome_print'
2
4
 
3
5
  module Cistern::Formatter::AwesomePrint
@@ -27,14 +29,16 @@ module AwesomePrint::Cistern
27
29
  # Format Cistern::Model
28
30
  #------------------------------------------------------------------------------
29
31
  def awesome_cistern_model(object)
30
- data = object.attributes.keys.sort.each_with_object({}) { |e, a| a[e] = object.public_send(e) }
31
- "#{object} " << awesome_hash(data)
32
+ data = object.attributes.keys.sort.each_with_object({}) do |e, a|
33
+ a[e] = object.read_attribute(e)
34
+ end
35
+ "#{object} #{awesome_hash(data)}"
32
36
  end
33
37
 
34
38
  # Format Cistern::Model
35
39
  #------------------------------------------------------------------------------
36
40
  def awesome_cistern_collection(object)
37
- "#{object.class.name} " << awesome_hash(attributes: object.attributes, records: object.to_a)
41
+ "#{object.class.name} #{awesome_hash(attributes: object.attributes, records: object.to_a)}"
38
42
  end
39
43
  end
40
44
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Formatter::Default
2
4
  class << self
3
5
  def call(object)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'formatador'
2
4
 
3
5
  module Cistern::Formatter::Formatador
@@ -12,24 +14,24 @@ module Cistern::Formatter::Formatador
12
14
 
13
15
  def self.model_inspect(model)
14
16
  Thread.current[:formatador] ||= Formatador.new
15
- data = "#{Thread.current[:formatador].indentation}<#{model.class.name}"
17
+ data = ["#{Thread.current[:formatador].indentation}<#{model.class.name}"]
16
18
  Thread.current[:formatador].indent do
17
19
  unless model.class.attributes.empty?
18
20
  data << "\n#{Thread.current[:formatador].indentation}"
19
- data << model.class.attributes.map { |attribute, _| "#{attribute}=#{model.send(attribute).inspect}" }.join(",\n#{Thread.current[:formatador].indentation}")
21
+ data << model.class.attributes.map { |attribute, _| "#{attribute}=#{model.read_attribute(attribute).inspect}" }.join(",\n#{Thread.current[:formatador].indentation}")
20
22
  end
21
23
  end
22
24
  data << "\n#{Thread.current[:formatador].indentation}>"
23
- data
25
+ data.join
24
26
  end
25
27
 
26
28
  def self.collection_inspect(collection)
27
29
  Thread.current[:formatador] ||= Formatador.new
28
- data = "#{Thread.current[:formatador].indentation}<#{collection.class.name}\n"
30
+ data = ["#{Thread.current[:formatador].indentation}<#{collection.class.name}\n"]
29
31
  Thread.current[:formatador].indent do
30
32
  unless collection.class.attributes.empty?
31
33
  data << "#{Thread.current[:formatador].indentation}"
32
- data << collection.class.attributes.map { |attribute| "#{attribute}=#{send(attribute).inspect}" }.join(",\n#{Thread.current[:formatador].indentation}")
34
+ data << collection.class.attributes.map { |attribute, _| "#{attribute}=#{collection.read_attribute(attribute).inspect}" }.join(",\n#{Thread.current[:formatador].indentation}")
33
35
  data << "\n"
34
36
  end
35
37
  data << "#{Thread.current[:formatador].indentation}["
@@ -44,7 +46,7 @@ module Cistern::Formatter::Formatador
44
46
  data << "]\n"
45
47
  end
46
48
  data << "#{Thread.current[:formatador].indentation}>"
47
- data
49
+ data.join
48
50
  end
49
51
 
50
52
  def table(attributes = nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Formatter
2
4
  autoload :AwesomePrint, 'cistern/formatter/awesome_print'
3
5
  autoload :Formatador, 'cistern/formatter/formatador'
data/lib/cistern/hash.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Cistern::Hash
2
4
  # @example
3
5
  # Cistern::Hash.slice({ :a => 1, :b => 2 }, :a) #=> { :a => 1 }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::HashSupport
2
4
  def hash_slice(*args); Cistern::Hash.slice(*args); end
3
5
  def hash_except(*args); Cistern::Hash.except(*args); end
data/lib/cistern/mock.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern
2
4
  class Mock
3
5
  def self.not_implemented(method = '')
data/lib/cistern/model.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Model
2
4
  include Cistern::Attributes::InstanceMethods
3
5
  include Cistern::HashSupport
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Request
2
4
  include Cistern::HashSupport
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Cistern::Service
2
4
  def self.inherited(klass)
3
5
  Cistern.deprecation(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern::Singular
2
4
  include Cistern::Model
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Cistern::String
2
4
  def self.camelize(string)
3
5
  string.gsub(/[A-Z]+/) { |w| "_#{w.downcase}" }.gsub(/^_/, '')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern
2
4
  module WaitFor
3
5
  def self.wait_for(timeout = Cistern.timeout, interval = Cistern.poll_interval, &_block)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cistern
2
- VERSION = '2.8.0'
4
+ VERSION = '2.8.1'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'timeout'
2
4
 
3
5
  module Cistern
data/lib/cistern.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cistern/version'
2
4
 
3
5
  # stdlib
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Cistern::Associations do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Cistern::Attributes, '#clone_attributes' do
data/spec/client_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe 'client' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::Collection' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'coverage', :coverage do
data/spec/dirty_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::Model#dirty' do
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class Inspector < Sample::Model
4
6
  identity :id
5
7
  attribute :name
8
+
9
+ has_many :employees, -> { Inspectors.new(associate_id: id).all }
10
+ has_many :managers, -> { Inspectors.new(associate_id: nil).all }
6
11
  end
7
12
 
8
13
  class Anon < Sample::Model
@@ -10,11 +15,13 @@ class Anon < Sample::Model
10
15
  end
11
16
 
12
17
  class Inspectors < Sample::Collection
18
+ attribute :associate_id
19
+
13
20
  model Inspector
14
21
 
15
22
  def all(options = {})
16
23
  merge_attributes(options)
17
- load([{ id: 1, name: '2' }, { id: 3, name: '4' }])
24
+ load([{ id: 1, name: '2', managers: [{ id: 5, name: '5'}]}, { id: 3, name: '4' }, employees: [{ id: 9, name: '8'}]])
18
25
  end
19
26
  end
20
27
 
@@ -64,20 +71,33 @@ describe Cistern::Formatter::Formatador do
64
71
 
65
72
  expect(Inspector.new(id: 1, name: 'name').inspect).to eq(' <Inspector
66
73
  id=1,
67
- name="name"
74
+ name="name",
75
+ employees=nil,
76
+ managers=nil
68
77
  >')
69
78
  end
70
79
 
71
80
  it 'formats a collection' do
72
81
  expect(Inspectors.new.all.inspect).to eq(' <Inspectors
82
+ associate_id=nil
73
83
  [
74
84
  <Inspector
75
85
  id=1,
76
- name="2"
86
+ name="2",
87
+ employees=nil,
88
+ managers=[{"id"=>5, "name"=>"5"}]
77
89
  >,
78
90
  <Inspector
79
91
  id=3,
80
- name="4"
92
+ name="4",
93
+ employees=nil,
94
+ managers=nil
95
+ >,
96
+ <Inspector
97
+ id=nil,
98
+ name=nil,
99
+ employees=[{"id"=>9, "name"=>"8"}],
100
+ managers=nil
81
101
  >
82
102
  ]
83
103
  >')
data/spec/hash_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::Hash' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'mock data' do
data/spec/model_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::Model' do
data/spec/request_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::Request' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::Singular' do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if ENV.key?('COVERAGE')
2
4
  require 'simplecov'
3
5
  SimpleCov.start
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.before(:each) {
3
5
  Object.send(:remove_const, :Sample) if Object.constants.include?(:Sample)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Cistern::WaitFor' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cistern
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: API client framework extracted from Fog
14
14
  email:
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.6.11
94
+ rubygems_version: 2.7.6
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: API client framework