dronestream 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Rakefile +9 -4
- data/lib/dronestream.rb +0 -2
- data/lib/dronestream/strike.rb +42 -11
- data/lib/dronestream/version.rb +1 -1
- data/spec/lib/dronestream/strike_spec.rb +58 -1
- data/spec/test_helper.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4824289ad21eaf4d72014dcf7da5380489799b74
|
4
|
+
data.tar.gz: cb333d62dc6faa30627788cc68fa39ac506c46fc
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c4d711e3c37fb2d82560397304f50cdd16dd27762594fa6f7c18f9affb76948c01771ea43d80861a48d3ab7015e8461aa6983f984dcaa5e57ae52682a36a4c0
|
7
|
+
data.tar.gz: 93c8becadd219c3223775eba9e268599fe61b426d499c922e0dfcb3e7cac1da9c5ac6e0362a38a42b4da2e962ec4ba98a60a3460da5fb984b30a20ee43330cc2
|
data/CHANGELOG.md
ADDED
data/Rakefile
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
|
3
2
|
require 'rake/testtask'
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
data/lib/dronestream.rb
CHANGED
data/lib/dronestream/strike.rb
CHANGED
@@ -3,20 +3,51 @@ module Dronestream
|
|
3
3
|
include HTTParty
|
4
4
|
base_uri 'http://api.dronestre.am'
|
5
5
|
|
6
|
-
|
7
|
-
response = get '/data'
|
8
|
-
end
|
6
|
+
class << self
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def response
|
9
|
+
response = get '/data'
|
10
|
+
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
48
|
+
def with_intended_target
|
49
|
+
all.keep_if { |strike| strike['target'].length != 0 }
|
50
|
+
end
|
20
51
|
end
|
21
52
|
|
22
53
|
end
|
data/lib/dronestream/version.rb
CHANGED
@@ -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.
|
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
|
|
data/spec/test_helper.rb
CHANGED
@@ -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
|
-
|
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
|
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-
|
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
|