get_freaky 0.1.0.pre → 0.1.1

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: be38981662bd8198eaea529990115e8370733bd9
4
- data.tar.gz: 7149fb396aec270113fc5c13ea986b0ebc12ea30
3
+ metadata.gz: ecfc45150450c0d94ccc4ab5e154391ebf9cdda1
4
+ data.tar.gz: f2fd1f56b2d802af89fca2745b454522d8736981
5
5
  SHA512:
6
- metadata.gz: 3401aeee50e55e5127324557e16a235c2d2789081cb13c93b786490aea394b759500e3369327b808fa62a676a9d891be15f6ba6a5c2049e550ef3edfebc02bce
7
- data.tar.gz: a2932d7b495bb400d8d0eee68e17cee8be1206d6497edc041eaa52e3ff77aad189a213fec0464d6b6f49ecab7fbf59c8dd6152ded81b36e3758855c4105279ce
6
+ metadata.gz: 3afc2af41df350c379053261eac5b1aa85c5f917352c02417be9be8f672bd67000aa1a366db74e8199dd5424d891c82ee4bbd56b15af31bf49c8b46bd1f12b5d
7
+ data.tar.gz: c8f424ecdfcab80d6ffa670e2edd4d27de922bfa2a35533617a94a58e655c937fe24d98b1d30a5df15e4a9fa5f50d86fe9eca8e670083e66e6ea3318fb910ca9
data/bin/get_freaky ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #require 'rubygems' # I read somewhere that I shouldn't need this--I'll leave it commented for now just in case
4
+ require 'commander/import'
5
+ #require 'get_freaky'
6
+ require_relative '../lib/get_freaky'
7
+
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
+ program :version, GetFreaky::VERSION
11
+ program :description, Info::DESCRIPTION
12
+ program :help, 'Author', 'Stephen Mariano Cabrera <smcabrera.github.io>'
13
+ program :help, 'Version', "#{GetFreaky::VERSION} #{GetFreaky::DATE}"
14
+
15
+ command :conf do |c|
16
+ c.syntax = 'get_freaky conf NAME [options]'
17
+ c.summary = 'Displays information about a conference'
18
+ c.description = c.summary # Because we're lazy
19
+ c.example 'List information about the GORUCO conference', 'get_freaky conf GORUCO'
20
+ c.action do |args, options|
21
+ conf = Conference.find(args[0])
22
+ puts conf.event_list
23
+ end
24
+ end
25
+
26
+ command :event do |c|
27
+ c.syntax = 'get_freaky event NAME [options]'
28
+ #c.summary = 'Displays information about an event (an instance of a conference in a particular year)'
29
+ c.summary = 'Shows the videos available from confreaks for an event (an instance of a conference in a particular year)'
30
+ c.description = c.summary
31
+ c.example 'Display information about the railsberry2013', 'get_freaky event railsberry2013'
32
+ c.action do |args, options|
33
+ event = Event.find(args[0])
34
+ puts event.video_list
35
+ end
36
+ end
37
+
38
+ command :download do |c|
39
+ c.syntax = 'get_freaky download VIDEO_NAME EVENT_NAME [options]'
40
+ #c.summary = 'Displays information about an event (an instance of a conference in a particular year)'
41
+ 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'
42
+ c.description = c.summary
43
+ c.example 'Download "The Future of Online Learning" from Railsberry 2013', 'get_freaky download "The Future of Online Learning" railsberry2013'
44
+ c.example 'Download "Sleep!" from Railsberry 2013', 'get_freaky download Sleep! railsberry2013'
45
+ c.action do |args, options|
46
+ video_title = args[0]
47
+ event = Event.find(args[1])
48
+ event_short_code = event.short_code
49
+ video = Video.find(event_short_code, video_title)
50
+ puts video.download
51
+ end
52
+ end
53
+
54
+ default_command :help
@@ -0,0 +1,29 @@
1
+ class Conference
2
+ include HTTParty
3
+ base_uri "http://confreaks.tv/api/v1"
4
+ attr_accessor :name, :event_count, :events
5
+
6
+ def initialize(name, event_count, events)
7
+ self.name = name
8
+ self.event_count = event_count
9
+ self.events = events
10
+ end
11
+
12
+ def self.find(name)
13
+ response = get("/conferences/#{name}.json")
14
+ if response.success?
15
+ self.new(
16
+ response["name"],
17
+ response["event_count"],
18
+ response["events"]
19
+ )
20
+ else
21
+ # this just raises the net/http response that was raised
22
+ raise response.response
23
+ end
24
+ end
25
+
26
+ def event_list
27
+ events.map { |event| event["short_code"] }
28
+ end
29
+ end
@@ -0,0 +1,59 @@
1
+ class Event
2
+ include HTTParty
3
+ BASE_URI = "http://confreaks.tv/api/v1"
4
+ base_uri "http://confreaks.tv/api/v1"
5
+ attr_accessor :short_code, :conference_name, :conference_id, :video_count, :video_list
6
+
7
+ def initialize(short_code, conference_name, conference_id, video_count)
8
+ self.short_code = short_code
9
+ self.conference_name = conference_name
10
+ self.conference_id = conference_id
11
+ self.video_count = video_count
12
+ end
13
+
14
+ # Alias short_code as name; "short_code" is consistent with the api, but "name" is easier to remember
15
+ def name
16
+ short_code
17
+ end
18
+
19
+ def self.find(short_code)
20
+ response = get("/events/#{short_code}.json")
21
+ if response.success?
22
+ self.new(
23
+ response["short_code"],
24
+ response["conference"]["name"],
25
+ response["conference"]["id"],
26
+ response["video_count"]
27
+ )
28
+ else
29
+ # This raises the net/http response that was raised
30
+ raise response.response
31
+ end
32
+ end
33
+
34
+ def find_conference
35
+ Conference.find(self.conference_name)
36
+ end
37
+
38
+ def videos
39
+ response = HTTParty.get("#{BASE_URI}/events/#{short_code}/videos.json")
40
+ if response.success?
41
+ return response
42
+ else
43
+ # This raises the net/http response that was raised
44
+ raise response.response
45
+ end
46
+ end
47
+
48
+ # TODO: This implementation isn't really ideal. By calling the videos method you're hitting the api again.
49
+ # Ideally you want to just hit the api once and store that information away since you know that hitting the API takes more resources (and time frankly) then just storing the names in memory which is all you really care about until you need to actually get the information for that particular video
50
+ #
51
+ # 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
+ # This seems slightly better but I'm still not sure it's ideal
53
+ def video_list
54
+ self.video_list = videos.map { |video| video["title"] }
55
+ end
56
+
57
+ def find_video
58
+ end
59
+ end
@@ -0,0 +1,4 @@
1
+ module Info
2
+ DATE = %q{2015-5-7}
3
+ DESCRIPTION = %q{Wrapper for the confreaks API. Browse and download convention videos from the command line.}
4
+ end
@@ -1,3 +1,4 @@
1
1
  module GetFreaky
2
- VERSION = "0.1.0.pre"
2
+ VERSION = "0.1.1"
3
+ DATE = %q{2015-05-07}
3
4
  end
@@ -0,0 +1,57 @@
1
+ class Video
2
+ include HTTParty
3
+ BASE_URI = "http://confreaks.tv/api/v1"
4
+ base_uri "http://confreaks.tv/api/v1"
5
+ attr_accessor :title, :abstract, :embed_code
6
+
7
+ def initialize(title, abstract, embed_code)
8
+ self.title = title
9
+ self.abstract = abstract
10
+ self.embed_code = embed_code
11
+ end
12
+
13
+ def self.find(event_short_code, title)
14
+ slug = self.create_slug(event_short_code, title)
15
+ response = get("/videos/#{slug}.json")
16
+ if response.success?
17
+ Video.new(
18
+ response["title"],
19
+ response["abstract"],
20
+ response["embed_code"]
21
+ )
22
+ else
23
+ raise response.response
24
+ end
25
+ end
26
+
27
+ # TODO: That's WAY too many lines of code to do something relatively simple.
28
+ # I'm sure I can do better with some time spent cooking up a regular expression
29
+ # Also I may come up against more situations in which slugify isn't consistent
30
+ # with the way ConFreaks creates slugs--perhaps look into what gem they-re using!
31
+ # For now though...it works!
32
+ def self.create_slug(event_short_code, title)
33
+ _i = "#{event_short_code} #{title}"
34
+ _i = _i.gsub('/', '-').gsub("'", '-')
35
+ _i = _i.slugify
36
+ _i = _i.gsub('---', '-').gsub('--', '-')
37
+ _i = _i.chomp('-').chomp(',')
38
+ end
39
+
40
+ def download
41
+ cmd = %x[ viddl-rb #{youtube_url} ]
42
+ end
43
+
44
+ #private
45
+
46
+ def youtube_url
47
+ "https://www.youtube.com/watch?v=#{embed_code}"
48
+ end
49
+ end
50
+
51
+ def find(event_short_code, title)
52
+ slug = self.create_slug(event_short_code, title)
53
+ response = HTTParty.get("http://confreaks.tv/api/v1/videos/#{slug}.json")
54
+ end
55
+
56
+
57
+
data/lib/get_freaky.rb CHANGED
@@ -1,12 +1,10 @@
1
1
  require 'httparty'
2
2
  require 'slugify'
3
3
  require 'viddl-rb'
4
- require "get_freaky/version"
4
+
5
5
  require 'get_freaky/conference'
6
6
  require 'get_freaky/event'
7
7
  require 'get_freaky/video'
8
-
9
- module GetFreaky
10
- # Your code goes here...
11
- end
8
+ require "get_freaky/version"
9
+ require "get_freaky/info"
12
10
 
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_freaky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Mariano Cabrera
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: slugify
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: httparty
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,33 +25,33 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0.13'
41
27
  - !ruby/object:Gem::Dependency
42
- name: viddl-rb
28
+ name: slugify
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '1.1'
33
+ version: '1.0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '1.1'
40
+ version: '1.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: commander
42
+ name: viddl-rb
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '4.3'
47
+ version: '1.1'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '4.3'
54
+ version: '1.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: bundler
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,27 +80,22 @@ dependencies:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: '10.0'
97
- description: Wrapper for the confreaks API. Makes it easier to browse and download
98
- videos from software engineering conventions posted to confreaks.tv.
99
- email:
100
- - stephen.m.cabrera@gmail.com
101
- executables: []
83
+ description: Wrapper for the confreaks API. Browse and download convention videos
84
+ from the command line.
85
+ email: stephen.m.cabrera@gmail.com
86
+ executables:
87
+ - get_freaky
102
88
  extensions: []
103
89
  extra_rdoc_files: []
104
90
  files:
105
- - ".gitignore"
106
- - ".travis.yml"
107
- - CODE_OF_CONDUCT.md
108
- - Gemfile
109
- - LICENSE.txt
110
- - README.md
111
- - Rakefile
112
- - bin/console
113
- - bin/setup
114
- - get_freaky.gemspec
91
+ - bin/get_freaky
115
92
  - lib/get_freaky.rb
93
+ - lib/get_freaky/conference.rb
94
+ - lib/get_freaky/event.rb
95
+ - lib/get_freaky/info.rb
116
96
  - lib/get_freaky/version.rb
117
- homepage: https://www.github.com/smcabrera/get_freaky
97
+ - lib/get_freaky/video.rb
98
+ homepage: https://github.com/smcabrera/get_freaky
118
99
  licenses:
119
100
  - MIT
120
101
  metadata:
@@ -130,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
111
  version: '0'
131
112
  required_rubygems_version: !ruby/object:Gem::Requirement
132
113
  requirements:
133
- - - ">"
114
+ - - ">="
134
115
  - !ruby/object:Gem::Version
135
- version: 1.3.1
116
+ version: '0'
136
117
  requirements: []
137
118
  rubyforge_project:
138
119
  rubygems_version: 2.2.2
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.2
data/CODE_OF_CONDUCT.md DELETED
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in get_freaky.gemspec
4
- gemspec
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Stephen Mariano Cabrera
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,39 +0,0 @@
1
- # GetFreaky
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/get_freaky`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'get_freaky'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install get_freaky
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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.
30
-
31
- 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).
32
-
33
- ## Contributing
34
-
35
- 1. Fork it ( https://github.com/[my-github-username]/get_freaky/fork )
36
- 2. Create your feature branch (`git checkout -b my-new-feature`)
37
- 3. Commit your changes (`git commit -am 'Add some feature'`)
38
- 4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create a new Pull Request
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
-
4
- require 'rake/testtask'
5
-
6
- Rake::TestTask.new do |t|
7
- t.libs << 'lib/get_freaky'
8
- t.test_files = FileList['test/lib/get_freaky/*_test.rb']
9
- t.verbose = true
10
- end
11
-
12
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
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
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
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
data/get_freaky.gemspec DELETED
@@ -1,33 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'get_freaky/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "get_freaky"
8
- spec.version = GetFreaky::VERSION
9
- spec.authors = ["Stephen Mariano Cabrera"]
10
- spec.email = ["stephen.m.cabrera@gmail.com"]
11
-
12
- spec.summary = %q{Get Freaky!}
13
- spec.description = %q{Wrapper for the confreaks API. Makes it easier to browse and download videos from software engineering conventions posted to confreaks.tv.}
14
- spec.homepage = "https://www.github.com/smcabrera/get_freaky"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
-
22
- if spec.respond_to?(:metadata)
23
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
24
- end
25
-
26
- spec.add_runtime_dependency "slugify", "~> 1.0"
27
- spec.add_runtime_dependency "httparty", "~> 0.13"
28
- spec.add_runtime_dependency "viddl-rb", "~> 1.1"
29
- spec.add_runtime_dependency 'commander', "~> 4.3"
30
-
31
- spec.add_development_dependency "bundler", "~> 1.9"
32
- spec.add_development_dependency "rake", "~> 10.0"
33
- end