wwdc 0.0.2 → 1.0.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: e31a7a4587eb6fd64bbb7b6d6c6c867dafe0cddf
4
- data.tar.gz: 7aab23d89a2a688cfa9f2a1c19cd35764c30b7f2
3
+ metadata.gz: dab8a45020b09a2a93acb97277986b6b75e80d87
4
+ data.tar.gz: e1633fb111cc84e14c951154e9ef26e0aeecbcf6
5
5
  SHA512:
6
- metadata.gz: 0e1070e41b53ffe5c17d66200a1b16722ca48e8c0f80992be72388740a3dcf0ebff6c23794d451331c5cbf5bfc9fb935a00fe93bd02836a5e1aef30d865f70fd
7
- data.tar.gz: f1adf6ec49064e4af6ec0dfdcfe9bc050bbf6598ab44ee20b720e0fb69a01e621607f51e197fc9b956e0dfa7ae69e723aae62ea02f75a1b2270fbe82f89daba8
6
+ metadata.gz: 1877692cd9aa8b4f2896a81806b9e1909c07d72d2d70e697994b0d73068ad546467bbdeddcaaf74dc31799308e8cc908465438f859b90509fd071c9596209fdc
7
+ data.tar.gz: 0460a78b999f50d1780c4fc8e7ef4bb84af8a504997909370da65b419404940e0b4090bda74617319fd083c6aaa73e6bf324c9c52eaa43c2941e7a59466435d2
data/Gemfile.lock CHANGED
@@ -1,19 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wwdc (0.0.2)
5
- commander (~> 4.1.2)
6
- excon (~> 0.25.3)
4
+ wwdc (1.0.0)
5
+ commander (~> 4.1)
6
+ excon (~> 0.25)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- commander (4.1.5)
11
+ commander (4.2.0)
12
12
  highline (~> 1.6.11)
13
- excon (0.25.3)
14
- highline (1.6.19)
15
- rake (0.9.2.2)
16
- rspec (0.6.4)
13
+ diff-lcs (1.2.5)
14
+ excon (0.38.0)
15
+ highline (1.6.21)
16
+ rake (10.3.2)
17
+ rspec (3.0.0)
18
+ rspec-core (~> 3.0.0)
19
+ rspec-expectations (~> 3.0.0)
20
+ rspec-mocks (~> 3.0.0)
21
+ rspec-core (3.0.3)
22
+ rspec-support (~> 3.0.0)
23
+ rspec-expectations (3.0.3)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.0.0)
26
+ rspec-mocks (3.0.3)
27
+ rspec-support (~> 3.0.0)
28
+ rspec-support (3.0.3)
17
29
 
18
30
  PLATFORMS
19
31
  ruby
data/README.md CHANGED
@@ -16,12 +16,21 @@ $ gem install wwdc
16
16
  ```bash
17
17
  $ wwdc info 228
18
18
 
19
+ 228: "A Look Inside Presentation Controllers"
20
+ iOS 8 brings you powerful new means of presenting content within your apps. Hear how presentation controllers were leveraged by UIKit to give you fine grain control using new alert and searching APIs. Dive deep into how presentation controllers work and how you can use them to present content within your app in exciting new ways.
21
+
22
+ $ wwdc info 228 2013
23
+
19
24
  228: "Hidden Gems in Cocoa and Cocoa Touch"
20
25
  Learn from the experts about the Cocoa and Cocoa Touch classes you may not even know exist, as well as some very obscure but extremely valuable classes that are favorites of the presenters.
21
26
 
22
27
  $ wwdc open 228
23
28
 
24
- # Opens browser to Apple Developer page with links to slides and video
29
+ # Opens browser to Apple Developer page with links to slides and video for this year
30
+
31
+ $ wwdc open 228 2013
32
+
33
+ # Opens browser to Apple Developer page with links to slides and video for 2013
25
34
 
26
35
  $ wwdc search UIView
27
36
 
@@ -1,14 +1,15 @@
1
1
  command :info do |c|
2
- c.syntax = 'wwdc info [SESSION]'
3
- c.summary = 'Get information about a session by its number'
4
- c.description = ''
2
+ c.syntax = 'wwdc info SESSION'
3
+ c.summary = 'Get information about a session by its number and year'
4
+ c.option '-y', '--year YEAR', 'WWDC Year'
5
5
 
6
6
  c.action do |args, options|
7
- say_error "Missing session number" and abort unless @number = (Integer(args.first) rescue nil)
7
+ determine_session!(args, options)
8
+ determine_year!(args, options)
8
9
 
9
- session = get(path: "/2013/sessions/#{@number}")
10
+ @session = get(path: "/#{@year}/sessions/#{@number}")
10
11
 
11
- describe session
12
+ describe @session
12
13
  end
13
14
  end
14
15
 
@@ -1,12 +1,13 @@
1
1
  command :open do |c|
2
2
  c.syntax = 'wwdc open [SESSION]'
3
3
  c.summary = 'Open your browser to the Apple Developer Center to view session slides and video'
4
- c.description = ''
4
+ c.option '-y', '--year YEAR', 'WWDC Year'
5
5
 
6
6
  c.action do |args, options|
7
- say_error "Missing session number" and abort unless @number = (Integer(args.first) rescue nil)
7
+ determine_session!(args, options)
8
+ determine_year!(args, options)
8
9
 
9
- session = get(path: "/2013/sessions/#{@number}") do |response|
10
+ @session = get(path: "/#{@year}/sessions/#{@number}") do |response|
10
11
  url = response.headers['Link'].scan(/\<(.+)\>/).flatten.first
11
12
  `open "#{url}"`
12
13
  end
@@ -1,17 +1,17 @@
1
1
  command :search do |c|
2
2
  c.syntax = 'wwdc search [QUERY]'
3
3
  c.summary = 'Find sessions containing the specified search terms'
4
- c.description = ''
4
+ c.option '-y', '--year YEAR', 'WWDC Year'
5
5
 
6
6
  c.action do |args, options|
7
- @query = args.join(" ")
8
- say_error "Missing session number" and abort if @query.empty?
7
+ determine_query!(args, options)
8
+ determine_year!(args, options) if options.year
9
9
 
10
- json = get(path: "search", query: {q: @query})
10
+ @results = get(path: "search", query: {q: @query, year: @year})['results']
11
11
 
12
- json['results'].each do |result|
13
- describe result
14
- end
12
+ say_warning "No results" and abort if @results.empty?
13
+
14
+ describe *@results
15
15
  end
16
16
  end
17
17
 
data/lib/wwdc/helpers.rb CHANGED
@@ -1,8 +1,13 @@
1
1
  require 'excon'
2
2
  require 'json'
3
+ require 'rubygems/text'
3
4
 
4
5
  module WWDC
6
+ YEARS = (2010..2014)
7
+
5
8
  module Helpers
9
+ include Gem::Text
10
+
6
11
  def get(options = {}, &block)
7
12
  response = client.get(options)
8
13
  say_error "Error #{response.status}" and abort unless response.status == 200
@@ -12,14 +17,35 @@ module WWDC
12
17
  JSON.parse(response.body)
13
18
  end
14
19
 
15
- def describe(session)
16
- puts %{\033[1m#{session['number']}: "#{session['title']}"\033[0m}
17
- puts session['description']
18
- puts
20
+ def describe(*sessions)
21
+ enable_paging if sessions.length > 5
22
+
23
+ sessions.each do |session|
24
+ puts %{\033[1mWWDC #{session['year']}\033[0m}
25
+ puts %{\033[1mSession #{session['number']}: "#{session['title']}"\033[0m}
26
+ puts
27
+ puts format_text(session['description'], 80)
28
+ puts
29
+ end
19
30
  end
20
31
 
21
32
  private
22
33
 
34
+ def determine_session!(args = [], options = {})
35
+ @number = (Integer(args.first).nonzero? rescue nil)
36
+ say_error "Missing session number" and abort unless @number
37
+ end
38
+
39
+ def determine_year!(args = [], options = {})
40
+ @year = (Integer(options.year).nonzero? rescue nil) || YEARS.last
41
+ say_error "Invalid year: #{@year}" and abort unless YEARS.include?(@year)
42
+ end
43
+
44
+ def determine_query!(args = [], options = {})
45
+ @query = args.join(" ")
46
+ say_error "Missing query" and abort if @query.empty?
47
+ end
48
+
23
49
  def client
24
50
  @client ||= Excon.new('http://asciiwwdc.com', headers: {'Accept' => "application/json"})
25
51
  end
data/lib/wwdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WWDC
2
- VERSION = '0.0.2'
2
+ VERSION = '1.0.0'
3
3
  end
data/wwdc.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
  s.summary = "WWDC"
15
15
  s.description = "A command-line interface for accessing WWDC session content"
16
16
 
17
- s.add_dependency "commander", "~> 4.1.2"
18
- s.add_dependency "excon", "~> 0.25.3"
17
+ s.add_dependency "commander", "~> 4.1"
18
+ s.add_dependency "excon", "~> 0.25"
19
19
 
20
20
  s.add_development_dependency "rspec"
21
21
  s.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wwdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattt Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.2
19
+ version: '4.1'
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: 4.1.2
26
+ version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: excon
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.25.3
33
+ version: '0.25'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.25.3
40
+ version: '0.25'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.0.3
111
+ rubygems_version: 2.1.11
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: WWDC