get_freaky 0.1.2.pre → 0.2.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: b6338916db36a7680f7feff7d3aa07cd38518b59
4
- data.tar.gz: e3489dac1296caf08995d929eaa7eb118c622522
3
+ metadata.gz: 47c57b669caf236bdfc64a796c895331b9629fb9
4
+ data.tar.gz: f65a8e1c888d6f59f4ca31d7c889f8ff412bda21
5
5
  SHA512:
6
- metadata.gz: 01e26f4c372b41713b28eb890f66b720cb13aac8ec5ed83d628c95036d5fcd91918ddc454ab4c47c377b7e16c3732ea3cac67a822780df612196ffbb6532b0ae
7
- data.tar.gz: 0209cba65873ddda0855e0efd5709a4461d546d8c1872960444a507a8345c646840f5de3e57852eb6224ee42e3c3be1c51c7279939fc542ff1d275001d83592d
6
+ metadata.gz: ade9ef4ab79dc358e3ca4780357cf569a1c68a98eef6f27a66797e3aabda3af0445a95a285f77adbb38f8b1c2b4ac791245c19000107463a6200d891484788b2
7
+ data.tar.gz: e7a9480ae2e64f88b452a20188c2499dd5e22739ffa55e3eeaccd45dc751dae14cfa61259e03494f04e694436dd10c57986202c6d76babad5df20a93dcaaf6b7
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # GetFreaky
2
+
3
+ All around the world there are great conferences on software, programming languages, web development and more. But conferences are expensive! [Confreaks](confreaks.tv) is a website that posts videos from over two hundred conferences. ```get_freaky``` is a ruby gem that aims to provide a simple command-line interface to the confreaks api to make it easier to browse videos from confreaks.tv and download them for offline viewing.
4
+
5
+ ## Installation
6
+
7
+ Just install locally with rubygems:
8
+
9
+ $ gem install get_freaky
10
+
11
+ ## For the Impatient
12
+
13
+ Just run
14
+
15
+ $ get_freaky featured
16
+
17
+ You'll get the title and a short description of the current *featured video* and if you'd like, you can download it automatically. Not an interesting subject to you? Run the command again--the featured video changes each time. (I'm actually not sure how featured is chosen but just anecdotally they seem to be popular videos from more well-known speakers) so you can run the command again to get a look at a different video.
18
+
19
+ And if you already know a video you want, you can start downloading a video right away:
20
+
21
+ $ get_freaky download "The Future of Online Learning" railsberry2013
22
+
23
+ passing in the name of the video and the event its from.
24
+
25
+ ## Usage
26
+
27
+ The command for the executable is the same as the name of the gem: ```get_freaky```. You can get going right out of the box by running the command in your terminal where you'll be shown the current help information. Check out the commands by running them with the --help flag to see examples.
28
+
29
+ $ get_freaky
30
+
31
+ By itself shows you all the currently available commands and is generally more up to date than this readme.
32
+
33
+ $ get_freaky conf CONF_NAME
34
+
35
+ $ get_freaky event EVENT_NAME
36
+
37
+ $ get_freaky download EVENT_NAME TALK_TITLE
38
+
39
+ For any of these commands the ```--help``` flag will give you more usage details.
40
+
41
+ Adding the ```--download``` option will download the video automatically without prompting. This can be nice for scripting purposes, if you want to create a cron job to automatically download a conference video every week for example.
42
+
43
+ $ get_freaky featured --download
44
+
45
+ ## Development
46
+
47
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+
51
+ ## Contributing
52
+ This is my first gem so any suggestions, tips, pull request, etc. are greatly appreciated!
53
+
54
+ 0. Check out the [code of conduct](https://github.com/smcabrera/get_freaky/blob/master/CODE_OF_CONDUCT.md) for contributors (TL;DR [be excellent to each other](http://giphy.com/gifs/POekkUcKs16gg/html5))
55
+ 1. [Fork it](https://github.com/smcabrera/get_freaky/fork)
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create a new Pull Request
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "get_freaky"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/get_freaky CHANGED
@@ -6,7 +6,6 @@ require 'commander/import'
6
6
  require_relative '../lib/get_freaky'
7
7
 
8
8
  program :name, "get_freaky"
9
- #program :version, GetFreaky::Version # I should be able to call this dynamically the same way my gemspec does
10
9
  program :version, GetFreaky::VERSION
11
10
  program :description, Info::DESCRIPTION
12
11
  program :help, 'Author', 'Stephen Mariano Cabrera <smcabrera.github.io>'
@@ -25,7 +24,10 @@ command :conf do |c|
25
24
  if conf.name == "Not Found"
26
25
  puts "Sorry, there was no conference found by that name."
27
26
  else
28
- puts conf.event_list
27
+ events = conf.event_list
28
+ event_title = choose("Choose an event you'd like to see more information about it:\n\n", *events)
29
+ event = Event.find(event_title)
30
+ puts event
29
31
  end
30
32
  end
31
33
  end
@@ -38,21 +40,30 @@ command :event do |c|
38
40
  c.description = c.summary
39
41
  c.example 'Display information about the railsberry2013', 'get_freaky event railsberry2013'
40
42
  c.action do |args, options|
41
- event = Event.find(args[0])
42
- puts event.video_list
43
+ unless args[0]
44
+ puts `get_freaky conf --help`
45
+ else
46
+ event = Event.find(args[0])
47
+ videos = event.video_list
48
+ video_title = choose("Choose a talk to see more information about it:\n\n", *videos)
49
+ video = Video.find(event.name, video_title)
50
+ puts video
51
+ ask_to_download(video)
52
+ end
43
53
  end
44
54
  end
45
55
 
46
56
  command :download do |c|
47
57
  c.syntax = 'get_freaky download VIDEO_NAME EVENT_NAME [options]'
48
- #c.summary = 'Displays information about an event (an instance of a conference in a particular year)'
49
58
  c.summary = 'Downloads a confreaks video locally using the viddl-rb library. Note that the "event name" given needs to be formatted in the same way as the listing show by the "event" command. Be sure to put quotes around video titles of multiple words and escape special exclamation points'
50
59
  c.description = c.summary
51
60
  c.example 'Download "The Future of Online Learning" from Railsberry 2013', 'get_freaky download "The Future of Online Learning" railsberry2013'
52
61
  c.example 'Download "Sleep!" from Railsberry 2013', 'get_freaky download Sleep! railsberry2013'
53
62
  c.action do |args, options|
54
63
  if args[0] == "featured"
55
- Video.find_featured
64
+ video = Video.find_featured
65
+ puts video
66
+ ask_to_download(video, options.download)
56
67
  else
57
68
  video_title = args[0]
58
69
  event = Event.find(args[1])
@@ -69,12 +80,21 @@ command :featured do |c|
69
80
  c.summary = 'Shows information on the "featured video" on confreaks.tv'
70
81
  c.description = c.summary
71
82
  c.example 'Show the current featured video on confreaks.tv', 'get_freaky featured'
83
+ c.option '--download', 'Automatically download the video without being prompted'
72
84
  c.action do |args, options|
73
85
  video = Video.find_featured
74
86
  puts video
75
- puts agree("Would you like to download this video?") ? video.download : %Q(Okay. Here's the link if you change your mind #{video.url})
87
+ ask_to_download(video, options.download)
76
88
  end
77
89
  end
78
90
 
91
+ def ask_to_download(video, download_option = false)
92
+ unless download_option
93
+ puts agree(Paint["\nWould you like to download this video? (y/n)", :blue]) ? video.download : %Q(Okay. Here's the link if you change your mind \n#{video.url})
94
+ else
95
+ puts "\nDownloading automatically with viddl-rb...\n"
96
+ video.download
97
+ end
98
+ end
79
99
 
80
100
  default_command :help
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -2,13 +2,15 @@ class Event
2
2
  include HTTParty
3
3
  BASE_URI = "http://confreaks.tv/api/v1"
4
4
  base_uri "http://confreaks.tv/api/v1"
5
- attr_accessor :short_code, :conference_name, :conference_id, :video_count, :video_list
5
+ attr_accessor :short_code, :conference_name, :conference_id, :video_count, :date
6
6
 
7
- def initialize(short_code, conference_name, conference_id, video_count)
7
+ # TODO: I'm pretty sure that at this number of arguments it should just take a hash
8
+ def initialize(short_code, conference_name, conference_id, video_count, date)
8
9
  self.short_code = short_code
9
10
  self.conference_name = conference_name
10
11
  self.conference_id = conference_id
11
12
  self.video_count = video_count
13
+ self.date = date
12
14
  end
13
15
 
14
16
  # Alias short_code as name; "short_code" is consistent with the api, but "name" is easier to remember
@@ -16,14 +18,30 @@ class Event
16
18
  short_code
17
19
  end
18
20
 
21
+ def to_s
22
+ %Q{\nConference: #{conference_name}\nNumber of Videos: #{video_count}}
23
+ end
24
+
19
25
  def self.find(short_code)
20
26
  response = get("/events/#{short_code}.json")
21
- if response.success?
27
+ if response["status"] == 404
28
+ # TODO: The below is totally embarrassing...need to figure out a better way to handle this (though it's still better than nil)
29
+ # Look into using NULL Objects?
30
+ # Better exceptions?
31
+ self.new(
32
+ "Not Found",
33
+ "Not Found",
34
+ "Not Found",
35
+ "Not Found",
36
+ "Not Found"
37
+ )
38
+ elsif response.success?
22
39
  self.new(
23
40
  response["short_code"],
24
41
  response["conference"]["name"],
25
42
  response["conference"]["id"],
26
- response["video_count"]
43
+ response["video_count"],
44
+ fix_date(response["start_at"])
27
45
  )
28
46
  else
29
47
  # This raises the net/http response that was raised
@@ -51,9 +69,18 @@ class Event
51
69
  # Probably should do something like store the list of video names as strings as soon as you create the object and then keep that array for future use
52
70
  # This seems slightly better but I'm still not sure it's ideal
53
71
  def video_list
54
- self.video_list = videos.map { |video| video["title"] }
72
+ if self.videos == "Not Found"
73
+ "There was no conference found by that name."
74
+ else
75
+ videos.map { |video| video["title"] }
76
+ end
55
77
  end
56
78
 
57
- def find_video
79
+ def self.fix_date(date)
80
+ year, month, day = date[0..3].to_i, date[5..6].to_i, date[8..9].to_i
81
+ Date.new(year, month, day)
58
82
  end
83
+
84
+ private
85
+
59
86
  end
@@ -1,4 +1,3 @@
1
1
  module Info
2
- DATE = %q{2015-5-7}
3
2
  DESCRIPTION = %q{Wrapper for the confreaks API. Browse and download convention videos from the command line.}
4
3
  end
@@ -1,4 +1,4 @@
1
1
  module GetFreaky
2
- VERSION = "0.1.2.pre"
3
- DATE = %q{2015-05-08}
2
+ VERSION = "0.2.0"
3
+ DATE = %q{2015-05-14}
4
4
  end
@@ -1,3 +1,5 @@
1
+ require 'paint'
2
+
1
3
  class Video
2
4
  include HTTParty
3
5
  BASE_URI = "http://confreaks.tv/api/v1"
@@ -42,11 +44,7 @@ class Video
42
44
  end
43
45
 
44
46
  def to_s
45
- info = %Q{
46
- Title: #{title}
47
- Description: #{abstract}
48
- Link: #{url}
49
- }
47
+ %Q{\n#{Paint['Title:', :green]} #{title}\n#{Paint["Description:", :green]} #{abstract}\n}
50
48
  end
51
49
 
52
50
  def url
data/lib/get_freaky.rb CHANGED
@@ -2,9 +2,9 @@ require 'httparty'
2
2
  require 'slugify'
3
3
  require 'viddl-rb'
4
4
 
5
- require 'get_freaky/conference'
6
- require 'get_freaky/event'
7
- require 'get_freaky/video'
8
- require "get_freaky/version"
9
- require "get_freaky/info"
5
+ require_relative 'get_freaky/conference'
6
+ require_relative 'get_freaky/event'
7
+ require_relative 'get_freaky/video'
8
+ require_relative "get_freaky/version"
9
+ require_relative "get_freaky/info"
10
10
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_freaky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.pre
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Mariano Cabrera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: table_print
14
+ name: commander
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.3
19
+ version: 4.3.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.5.3
26
+ version: 4.3.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: paint
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: fabricas
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -144,7 +158,10 @@ executables:
144
158
  extensions: []
145
159
  extra_rdoc_files: []
146
160
  files:
161
+ - README.md
162
+ - bin/console
147
163
  - bin/get_freaky
164
+ - bin/setup
148
165
  - lib/get_freaky.rb
149
166
  - lib/get_freaky/conference.rb
150
167
  - lib/get_freaky/event.rb
@@ -167,9 +184,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
184
  version: '0'
168
185
  required_rubygems_version: !ruby/object:Gem::Requirement
169
186
  requirements:
170
- - - ">"
187
+ - - ">="
171
188
  - !ruby/object:Gem::Version
172
- version: 1.3.1
189
+ version: '0'
173
190
  requirements: []
174
191
  rubyforge_project:
175
192
  rubygems_version: 2.2.2