cistern 2.7.2 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1078f46c6354a267fc6798e5d9f1b3270cdc548d
4
- data.tar.gz: c82cffe4f6e2d9467cb90e71af6222d01be3d092
3
+ metadata.gz: c46e3adcc00de17de88267eb956010d23a800448
4
+ data.tar.gz: 55b688beea4299e4ff6ce8b2e7a417b57138aeef
5
5
  SHA512:
6
- metadata.gz: b2db4b6003fbacf965896d9e831605bb7cb77bcbb8da51686470450781562560ebbf47a864c92b0a87a52398e6d0126164d93530e6eee6bed71d61d37a40a257
7
- data.tar.gz: ce71093871260a9f4686989e9cdb94f98eb82b65c7f8f8572892e1b82ac7a08ae1997e7b3d906088737df828e526b3344e60fadaff58587b61400c9e8d893fc5
6
+ metadata.gz: cf42fdb4f9909d0e5a388366eec9c12ac3154d8de3d431fd0319e64119d2d437ddf4f72fed4ce0a51c847f598b834ff1a7dbc3e5699018c42e632409e186e424
7
+ data.tar.gz: '0542951ae0e2926ac3454c5140b7e15bc690fa6593b410277da23554f585da872b83006f7dfa9026569a9aa931100eb09759f0d96b74f29e774449542b5c6074'
data/.travis.yml CHANGED
@@ -5,7 +5,10 @@ rvm:
5
5
  bundler_args: "--without development"
6
6
  before_install:
7
7
  - gem install bundler -v "~> 1.10"
8
- script: bundle exec rake --trace
8
+ script:
9
+ - bundle exec rake --trace
10
+ after_script:
11
+ - codeclimate-test-reporter
9
12
  notifications:
10
13
  email: false
11
14
  sudo: false
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at cistern@joshualane.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -14,6 +14,7 @@ group :test do
14
14
  gem "listen", "~> 3.0.5"
15
15
  gem "redis-namespace", "~> 1.4", "< 1.5"
16
16
  gem "codeclimate-test-reporter", require: false
17
+ gem "simplecov", require: false
17
18
  end
18
19
 
19
20
  group :formatters do
data/README.md CHANGED
@@ -205,7 +205,7 @@ Cistern attributes are designed to make your model flexible and developer friend
205
205
  model.merge_attributes("post" => 1)
206
206
  model.post_id #=> 1
207
207
  ```
208
- * `:type` automatically casts the attribute do the specified type.
208
+ * `:type` automatically casts the attribute do the specified type. Supported types: `array`, `boolean`, `date`, `float`, `integer`, `string`, `time`.
209
209
  ```ruby
210
210
  attribute :private_ips, type: :array
211
211
 
@@ -13,7 +13,7 @@ group :test do
13
13
  gem "rspec", "~> 3.3"
14
14
  gem "listen", "~> 3.0.5"
15
15
  gem "redis-namespace", "~> 1.4", "< 1.5"
16
- gem "codeclimate-test-reporter", :require => false
16
+ gem "codeclimate-test-reporter", "< 1.0", :require => false
17
17
  end
18
18
 
19
19
  group :formatters do
@@ -7,6 +7,7 @@ module Cistern::Attributes
7
7
  @parsers ||= {
8
8
  array: ->(v, _) { [*v] },
9
9
  boolean: ->(v, _) { TRUTHY.include?(v.to_s.downcase) },
10
+ date: ->(v, _) { v.is_a?(Date) ? v : v && Date.parse(v.to_s) },
10
11
  float: ->(v, _) { v && v.to_f },
11
12
  integer: ->(v, _) { v && v.to_i },
12
13
  string: ->(v, _) { v && v.to_s },
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = '2.7.2'
2
+ VERSION = '2.8.0'
3
3
  end
@@ -157,6 +157,17 @@ describe Cistern::Attributes, 'parsing' do
157
157
  expect(subject.new(attributes: 'x').adam_attributes).to eq('x')
158
158
  end
159
159
 
160
+ it 'should parse date' do
161
+ subject.class_eval do
162
+ attribute :start_date, type: :date
163
+ end
164
+
165
+ date = Date.today
166
+ start_date = subject.new(start_date: date.to_s).start_date
167
+ expect(start_date).to be_a(Date)
168
+ expect(start_date.iso8601).to eq(date.iso8601)
169
+ end
170
+
160
171
  it 'should parse time' do
161
172
  subject.class_eval do
162
173
  attribute :created_at, type: :time
@@ -191,6 +202,16 @@ describe Cistern::Attributes, 'parsing' do
191
202
  expect(subject.new(list: 'item').list).to eq(['item'])
192
203
  end
193
204
 
205
+ it 'should parse an integer' do
206
+ subject.class_eval do
207
+ attribute :int, type: :integer
208
+ end
209
+
210
+ expect(subject.new(int: '42.5').int).to eq(42)
211
+ expect(subject.new(int: '42').int).to eq(42)
212
+ expect(subject.new(int: 42).int).to eq(42)
213
+ end
214
+
194
215
  it 'should parse a float' do
195
216
  subject.class_eval do
196
217
  attribute :floater, type: :float
@@ -44,15 +44,15 @@ describe Cistern::Formatter::AwesomePrint do
44
44
  before { Cistern.formatter = described_class }
45
45
 
46
46
  it 'formats a model' do
47
- expect(
48
- Inspector.new(id: 1, name: 'name').inspect
49
- ).to match(
50
- /(?x-mi:\#<Inspector:0x[0-9a-f]+>\ {\n\ \ \ \ \ \ :id\x1B\[0;37m\ =>\ \x1B\[0m\x1B\[1;34m1\x1B\[0m,\n\ \ \ \ :name\x1B\[0;37m\ =>\ \x1B\[0m\x1B\[0;33m"name"\x1B\[0m\n})/
51
- )
47
+ object = Inspector.new(id: 1, name: 'name')
48
+
49
+ expect(object.inspect).to eq(object.ai)
52
50
  end
53
51
 
54
52
  it 'formats a collection' do
55
- expect(Inspectors.new.all.inspect).to match(/Inspectors\s+{.*}$/m) # close enough
53
+ object = Inspectors.new.all
54
+
55
+ expect(object.inspect).to eq(object.ai)
56
56
  end
57
57
  end
58
58
 
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,15 @@
1
- if ENV['TRAVIS']
2
- require 'codeclimate-test-reporter'
3
- CodeClimate::TestReporter.start
1
+ if ENV.key?('COVERAGE')
2
+ require 'simplecov'
3
+ SimpleCov.start
4
4
  end
5
5
 
6
6
  require File.expand_path('../../lib/cistern', __FILE__)
7
+ Cistern.deprecation_warnings = ENV.key?('DEBUG')
8
+
7
9
  Dir[File.expand_path('../{support,shared,matchers,fixtures}/*.rb', __FILE__)].each { |f| require(f) }
8
10
 
9
11
  Bundler.require(:test)
10
12
 
11
- Cistern.deprecation_warnings = !!ENV['DEBUG']
12
-
13
13
  RSpec.configure do |rspec|
14
14
  if Kernel.respond_to?(:caller_locations)
15
15
  require File.expand_path('../../lib/cistern/coverage', __FILE__)
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.7.2
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2017-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: API client framework extracted from Fog
14
14
  email:
@@ -22,6 +22,7 @@ files:
22
22
  - ".travis.yml"
23
23
  - Appraisals
24
24
  - CHANGELOG.md
25
+ - CODE_OF_CONDUCT.md
25
26
  - Gemfile
26
27
  - Guardfile
27
28
  - LICENSE.txt
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  version: '0'
91
92
  requirements: []
92
93
  rubyforge_project:
93
- rubygems_version: 2.5.1
94
+ rubygems_version: 2.6.11
94
95
  signing_key:
95
96
  specification_version: 4
96
97
  summary: API client framework