dronestream 0.0.1 → 0.1.0

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
  !binary "U0hBMQ==":
3
- metadata.gz: bd71acfd9ab58149a5546364e53401d713eece4a
4
- data.tar.gz: 08b1c1a0a68db016d8159ba91bf38127a18e43a1
3
+ metadata.gz: 4824289ad21eaf4d72014dcf7da5380489799b74
4
+ data.tar.gz: cb333d62dc6faa30627788cc68fa39ac506c46fc
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 0e75ba1e02d38d38c0a2e04b09b93182886ccab745e8bd399610d3b50e3e4111edab851cbcc550a82b83a2bdaeeb2f378dda132e6c0cf2f321a507fae1f4319c
7
- data.tar.gz: f50632f71a03dcee0f6a9145771e2f8f1628f80bee236fc14d5aae760dad25c5b74806e7ac0ad589785d88523a288fda08572bb40ac8ddb244d88ee8a4ade4b0
6
+ metadata.gz: 7c4d711e3c37fb2d82560397304f50cdd16dd27762594fa6f7c18f9affb76948c01771ea43d80861a48d3ab7015e8461aa6983f984dcaa5e57ae52682a36a4c0
7
+ data.tar.gz: 93c8becadd219c3223775eba9e268599fe61b426d499c922e0dfcb3e7cac1da9c5ac6e0362a38a42b4da2e962ec4ba98a60a3460da5fb984b30a20ee43330cc2
@@ -0,0 +1,9 @@
1
+ ## 0.1.0 (June 2, 2013)
2
+
3
+ * Version bump. Implemented more methods.
4
+
5
+ ## 0.0.1 (June 2, 2013)
6
+
7
+ * Initial release. Support for `#in_country` and `#with_civilian_casualties` methods only.
8
+
9
+
data/Rakefile CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'bundler/gem_tasks'
2
-
3
2
  require 'rake/testtask'
4
- Rake::TestTask.new do |test|
5
- test.test_files = FileList['spec/lib/dronestream/*_spec.rb']
6
- test.verbose = true
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Default: run specs.'
7
+ task :default => :test
8
+
9
+ desc 'Run specs'
10
+ RSpec::Core::RakeTask.new do |test|
11
+ test.pattern = 'spec/lib/dronestream/*_spec.rb'
7
12
  end
@@ -4,8 +4,6 @@ require 'net/http'
4
4
  require 'json'
5
5
  require 'ostruct'
6
6
 
7
- require "httparty"
8
-
9
7
  Dir[File.dirname(__FILE__) + '/dronestream/*.rb'].each do |file|
10
8
  require file
11
9
  end
@@ -3,20 +3,51 @@ module Dronestream
3
3
  include HTTParty
4
4
  base_uri 'http://api.dronestre.am'
5
5
 
6
- def self.response
7
- response = get '/data'
8
- end
6
+ class << self
9
7
 
10
- def self.all
11
- response['strike']
12
- end
8
+ def response
9
+ response = get '/data'
10
+ end
13
11
 
14
- def self.country(country)
15
- self.all.keep_if { |strike| strike['country'] == country }
16
- end
12
+ def all
13
+ response['strike']
14
+ end
15
+
16
+ def in_country(country)
17
+ all.keep_if { |strike| strike['country'] == country }
18
+ end
19
+
20
+ def with_civilian_casualties
21
+ all.keep_if { |strike| strike['civilians'].to_i != 0 }
22
+ end
23
+
24
+ def with_child_casualties
25
+ all.keep_if { |strike| strike['children'].length != 0 }
26
+ end
27
+
28
+ def in_town(town)
29
+ all.keep_if { |strike| strike['town'] == town }
30
+ end
31
+
32
+ def with_injuries
33
+ all.keep_if { |strike| strike['injuries'].length != 0 }
34
+ end
35
+
36
+ def in_location(location)
37
+ all.keep_if { |strike| strike['location'] == location }
38
+ end
39
+
40
+ def with_min_deaths(integer)
41
+ all.keep_if { |strike| strike['deaths_min'].to_i >= integer }
42
+ end
43
+
44
+ def with_max_deaths(integer)
45
+ all.keep_if { |strike| strike['deaths_max'].to_i <= integer }
46
+ end
17
47
 
18
- def self.with_civilian_casualties
19
- self.all.reject { |strike| strike['civilians'].to_i == 0 }
48
+ def with_intended_target
49
+ all.keep_if { |strike| strike['target'].length != 0 }
50
+ end
20
51
  end
21
52
 
22
53
  end
@@ -1,3 +1,3 @@
1
1
  module Dronestream
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -18,6 +18,15 @@ describe Dronestream::Strike do
18
18
  expect(Dronestream::Strike.base_uri).to eq(uri)
19
19
  end
20
20
 
21
+ describe '#response' do
22
+ context 'no error' do
23
+ pending 'no error'
24
+ end
25
+ context 'error' do
26
+ pending 'error'
27
+ end
28
+ end
29
+
21
30
  describe '#all' do
22
31
  it 'parses the api response from json to array' do
23
32
  expect(strike.all).to be_instance_of Array
@@ -25,8 +34,9 @@ describe Dronestream::Strike do
25
34
  end
26
35
 
27
36
  describe '#country' do
37
+ let(:country_name) { 'Yemen' }
28
38
  it 'takes a country and returns strikes from that country' do
29
- expect(strike.country('Yemen').first['country']).to eq('Yemen')
39
+ expect(strike.in_country(country_name).first['country']).to eq(country_name)
30
40
  end
31
41
  end
32
42
 
@@ -35,5 +45,52 @@ describe Dronestream::Strike do
35
45
  expect(strike.with_civilian_casualties.first['civilians']).not_to eq('0')
36
46
  end
37
47
  end
48
+
49
+ describe '#with_child_casualties' do
50
+ it 'returns an array of strikes with child casualties' do
51
+ expect(strike.with_child_casualties.first['children']).not_to eq('')
52
+ end
53
+ end
54
+
55
+ describe '#in_town' do
56
+ let(:town_name) { 'Wadi Abida' }
57
+ it 'returns an array of strikes for a given town' do
58
+ expect(strike.in_town(town_name).first['town']).to eq(town_name)
59
+ end
60
+ end
61
+
62
+ describe '#in_location' do
63
+ let(:location_name) { 'North Waziristan' }
64
+ it 'returns an array of strikes for a given location' do
65
+ expect(strike.in_location(location_name).first['location']).to eq(location_name)
66
+ end
67
+ end
68
+
69
+ describe '#with_injuries' do
70
+ it 'returns an array of strikes with injuries' do
71
+ expect(strike.with_injuries.first['injuries']).not_to be_empty
72
+ end
73
+ end
74
+
75
+ describe '#with_min_deaths' do
76
+ let(:integer) { 4 }
77
+ it 'returns an array of strikes with a minimum given number of deaths' do
78
+ expect(strike.with_min_deaths(integer).first['deaths_min'].to_i).to be >= integer
79
+ end
80
+ end
81
+
82
+ describe '#with_max_deaths' do
83
+ let(:integer) { 4 }
84
+ it 'returns an array of strikes with a minimum given number of deaths' do
85
+ expect(strike.with_max_deaths(integer).first['deaths_max'].to_i).to be <= integer
86
+ end
87
+ end
88
+
89
+ describe '#with_intended_target' do
90
+ it 'returns an array of strikes that actually have an intended target' do
91
+ expect(strike.with_intended_target.first['target'].length).not_to be_zero
92
+ end
93
+ end
94
+
38
95
  end
39
96
 
@@ -1,6 +1,7 @@
1
1
  require 'dronestream'
2
2
  require 'rspec'
3
3
  require 'vcr'
4
+ require 'webmock/rspec'
4
5
 
5
6
 
6
7
  #VCR config
@@ -9,7 +10,7 @@ VCR.configure do |c|
9
10
  c.hook_into :webmock
10
11
  end
11
12
 
12
- Rspec.configure do |config|
13
+ RSpec.configure do |config|
13
14
  # Use color in STDOUT
14
15
  config.color_enabled = true
15
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dronestream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thenickcox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-02 00:00:00.000000000 Z
11
+ date: 2013-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - .gitignore
105
+ - CHANGELOG.md
105
106
  - Gemfile
106
107
  - LICENSE.txt
107
108
  - README.md