nsrr 0.1.0.rc → 0.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +10 -2
- data/lib/nsrr.rb +7 -0
- data/lib/nsrr/commands/update.rb +37 -0
- data/lib/nsrr/helpers/json_request.rb +16 -9
- data/lib/nsrr/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3acd6f73765b32f956fc2419b3fcf1951c1e825a
|
4
|
+
data.tar.gz: 4cd666686bd47641844247f2ade46c20d2364ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58202e7c2f14914d50cec6873f1d0c253b30cac0ebc9b07076b738cd618add3af022e145905847ae6e9d50729bec306921343b6ed19d783bec6394da1087ac0c
|
7
|
+
data.tar.gz: 0dab0139cdac9fdd2a961ee3122b480dd7f59849666ddd1a7e17446aa276d1933eb3fea822fb320176c159e95c2da485982eff84cf92b96f7f043a228645bd5a
|
data/CHANGELOG.md
CHANGED
@@ -23,5 +23,6 @@
|
|
23
23
|
- Downloads files in selected path folder and all subfolders
|
24
24
|
- 'shallow'
|
25
25
|
- Only downloads files in selected path folder
|
26
|
+
- Added a `nsrr update` command the provides the user with information on how to update the nsrr gem
|
26
27
|
- Added a `nsrr version` command the returns the current version of the nsrr gem
|
27
28
|
- Added testing framework to more easily add new tests for new features
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/nsrr/nsrr-gem.svg?branch=master)](https://travis-ci.org/nsrr/nsrr-gem)
|
4
4
|
[![Dependency Status](https://gemnasium.com/nsrr/nsrr-gem.svg)](https://gemnasium.com/nsrr/nsrr-gem)
|
5
|
-
[![Code Climate](https://codeclimate.com/github/nsrr/nsrr-gem.
|
5
|
+
[![Code Climate](https://codeclimate.com/github/nsrr/nsrr-gem/badges/gpa.svg)](https://codeclimate.com/github/nsrr/nsrr-gem)
|
6
6
|
|
7
7
|
The official ruby gem built to simplify file downloads and dataset integration tasks for the [National Sleep Research Resource](https://sleepdata.org).
|
8
8
|
|
@@ -18,7 +18,7 @@ You must have **Ruby 2.0+ installed** on your system to use the NSRR gem.
|
|
18
18
|
|
19
19
|
Install it yourself as:
|
20
20
|
|
21
|
-
$ gem install nsrr --
|
21
|
+
$ gem install nsrr --no-ri --no-rdoc
|
22
22
|
|
23
23
|
Or add this line to your application's Gemfile:
|
24
24
|
|
@@ -169,6 +169,14 @@ Finished in 2.384734 seconds.
|
|
169
169
|
1 folder created, 0 files downloaded, 0 MiBs downloaded, 2 files skipped, 0 files failed
|
170
170
|
```
|
171
171
|
|
172
|
+
### Update the NSRR gem
|
173
|
+
|
174
|
+
To make sure you're using the latest stable version of the NSRR gem, you can run the following command:
|
175
|
+
|
176
|
+
```
|
177
|
+
nsrr update
|
178
|
+
```
|
179
|
+
|
172
180
|
### Show the version of the NSRR gem
|
173
181
|
|
174
182
|
```
|
data/lib/nsrr.rb
CHANGED
@@ -5,6 +5,7 @@ require "nsrr/version"
|
|
5
5
|
Nsrr::COMMANDS = {
|
6
6
|
'c' => :console,
|
7
7
|
'd' => :download,
|
8
|
+
'u' => :update,
|
8
9
|
'v' => :version
|
9
10
|
}
|
10
11
|
|
@@ -23,6 +24,11 @@ module Nsrr
|
|
23
24
|
Nsrr::Commands::Download.run(argv)
|
24
25
|
end
|
25
26
|
|
27
|
+
def self.update(argv)
|
28
|
+
require 'nsrr/commands/update'
|
29
|
+
Nsrr::Commands::Update.start(argv)
|
30
|
+
end
|
31
|
+
|
26
32
|
def self.help(argv)
|
27
33
|
puts <<-EOT
|
28
34
|
|
@@ -32,6 +38,7 @@ The most common nsrr commands are:
|
|
32
38
|
[c]onsole Load an interactive console to access
|
33
39
|
and download datasets and files
|
34
40
|
[d]ownload Download all or some files in a DATASET
|
41
|
+
[u]pdate Update the nsrr gem
|
35
42
|
[v]ersion Returns the version of nsrr gem
|
36
43
|
|
37
44
|
Commands can be referenced by the first letter:
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
require 'nsrr/helpers/json_request'
|
4
|
+
|
5
|
+
module Nsrr
|
6
|
+
module Commands
|
7
|
+
class Update
|
8
|
+
class << self
|
9
|
+
def start(*args)
|
10
|
+
new(*args).start
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(argv)
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
json = Nsrr::Helpers::JsonRequest.get("https://rubygems.org/api/v1/gems/nsrr.json")
|
19
|
+
|
20
|
+
if json
|
21
|
+
if json['version'] == Nsrr::VERSION::STRING
|
22
|
+
puts "The nsrr gem is " + "up-to-date".colorize(:green) + "!"
|
23
|
+
else
|
24
|
+
puts
|
25
|
+
puts "A newer version (v#{json['version']}) is available! Type the following command to update:"
|
26
|
+
puts
|
27
|
+
puts " gem install nsrr --no-ri --no-rdoc".colorize(:white)
|
28
|
+
puts
|
29
|
+
end
|
30
|
+
else
|
31
|
+
puts "Unable to connect to RubyGems.org. Please try again later."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -14,20 +14,27 @@ module Nsrr
|
|
14
14
|
attr_reader :url
|
15
15
|
|
16
16
|
def initialize(url)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@
|
21
|
-
|
17
|
+
begin
|
18
|
+
@url = URI.parse(url)
|
19
|
+
@http = Net::HTTP.new(@url.host, @url.port)
|
20
|
+
if @url.scheme == 'https'
|
21
|
+
@http.use_ssl = true
|
22
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
23
|
+
end
|
24
|
+
rescue
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
28
|
def get
|
26
|
-
|
27
|
-
|
28
|
-
http.
|
29
|
+
begin
|
30
|
+
req = Net::HTTP::Get.new(@url.path)
|
31
|
+
response = @http.start do |http|
|
32
|
+
http.request(req)
|
33
|
+
end
|
34
|
+
JSON.parse(response.body)
|
35
|
+
rescue
|
36
|
+
nil
|
29
37
|
end
|
30
|
-
JSON.parse(response.body) rescue nil
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
data/lib/nsrr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsrr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/nsrr.rb
|
98
98
|
- lib/nsrr/commands/console.rb
|
99
99
|
- lib/nsrr/commands/download.rb
|
100
|
+
- lib/nsrr/commands/update.rb
|
100
101
|
- lib/nsrr/helpers/constants.rb
|
101
102
|
- lib/nsrr/helpers/download_request.rb
|
102
103
|
- lib/nsrr/helpers/hash_helper.rb
|