ngphoto 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/ngphoto +9 -0
  3. data/lib/ngphoto.rb +27 -0
  4. metadata +116 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e52ba7cf4f51a8f72bb63c10796c629d738980fe
4
+ data.tar.gz: b7237183060037c5368e3d6cbb3721924441e0df
5
+ SHA512:
6
+ metadata.gz: 20c80d8d28b7916614a7cdefecce9e616e7715934a3db46e1b74e485c8b06b60b84d238237430f0e3d2ea634c92a59bf51d8cd9b55313ebb986520a7284df57a
7
+ data.tar.gz: c54ad66d97cb13c58d73b53ea3669c3addb8604a9f31dcbe2dd8d9c58da57423183cb7cd49957d4dc53149d8d3d1c7fc9c8e4d333c0ae048abde900fc4908bf2
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+ require "ngphoto"
4
+ require 'fileutils'
5
+
6
+ # make sure that the directory exists
7
+ FileUtils::mkdir_p "#{ENV['HOME']}/Pictures/ngphoto"
8
+
9
+ Ngphoto.fetch.save
@@ -0,0 +1,27 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+
5
+ class Ngphoto
6
+ NG_PHOTO_OF_THE_DAY_URL = "http://photography.nationalgeographic.com/photography/photo-of-the-day/"
7
+
8
+ attr_reader :title, :url
9
+
10
+ def initialize(title, url)
11
+ @title = Time.now.strftime('%Y-%m-%d-') + title.split('--')[0].strip.gsub(' ', '-').downcase
12
+ @url = url
13
+ end
14
+
15
+ def save
16
+ system "curl -o ~/Pictures/ngphoto/#{title}.jpg #{url}"
17
+ end
18
+
19
+ def self.fetch
20
+ doc = Nokogiri::HTML(open(NG_PHOTO_OF_THE_DAY_URL))
21
+
22
+ title = doc.css('title').first.text
23
+ url = doc.css('.download_link a').first[:href]
24
+
25
+ Ngphoto.new title, url
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ngphoto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ali Ismayilov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.15.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.15.0
83
+ description: Utility to download Photo of the Day from National Geographic
84
+ email: ali@ismailov.info
85
+ executables:
86
+ - ngphoto
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/ngphoto.rb
91
+ - bin/ngphoto
92
+ homepage: https://github.com/aliismayilov/ngphoto
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.1.11
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: National Geographic Photo of the Day downloader
116
+ test_files: []