get_happy 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f70c53798f7c41f99d0566fe0290e8a02a7d20f8
4
- data.tar.gz: 2282f78b01a237555507c1374a13513227044940
3
+ metadata.gz: 4a4ed4a095297fa3a804cd60290f40202e23269f
4
+ data.tar.gz: 3980843e5bba07926cb8b4b9327a0bd9020e8699
5
5
  SHA512:
6
- metadata.gz: 695fdb1ff5f852f0828c2ac6919b10d50a4266001630760090b95d1c048f5114431f630f9ad79f2b143cc273466b9a6ed9600eab80648b27cff65f891a3d6520
7
- data.tar.gz: 97a02dd86e53a8715489ab5e8ce0a26b001e1bb9047cd4b2ea7bf8cf3b6b8867cf8761236ae80986a2343ce3a5ea95493fb48fe222eab19c2a7e305debcc9299
6
+ metadata.gz: 7950d344b795ae98a3658b9275d8e3d7f9a9f0212587de75dcb76c404c31070e4b5f46ec80c01e031ec877b7389400bd68c71c32030c3916fcd42d04024b8c9b
7
+ data.tar.gz: a51754ca4139f7a369212e9e0fb2756f0f2a15ef2bbaa2712ff252ad3feb2b528e86c14b11c59e68049830258f8852c3818152f0f300495318d9912a573caab7
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.3
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ [![Gem Version](https://badge.fury.io/rb/get_happy.png)](http://badge.fury.io/rb/get_happy)
2
+ [![Build Status](https://travis-ci.org/msroot/get_happy.svg?branch=master)](https://travis-ci.org/msroot/get_happy)
3
+ [![Code Climate](https://codeclimate.com/github/msroot/get_happy/badges/gpa.svg)](https://codeclimate.com/github/msroot/get_happy)
4
+ [![Inline docs](http://inch-ci.org/github/msroot/get_happy.svg?branch=master)](http://inch-ci.org/github/msroot/get_happy)
5
+ [![Coverage Status](https://coveralls.io/repos/msroot/get_happy/badge.svg?branch=master)](https://coveralls.io/r/msroot/get_happy?branch=master)
6
+
1
7
  # GetHappy
2
8
 
3
9
  A Gem to make you happy!
@@ -25,13 +31,14 @@ Or install it yourself as:
25
31
 
26
32
  $ get_happy help
27
33
  Commands:
28
- get_happy add [LINKS] # add a link to collection
29
- get_happy clean # clean collection
30
- get_happy delete # delete a url
31
- get_happy help [COMMAND] # Describe available commands or one specific command
32
- get_happy list # list collection
33
- get_happy play # play a random song
34
- get_happy seed # seed with some sample urls
34
+ get_happy add [LINKS] # add a link to collection
35
+ get_happy clean # clean collection
36
+ get_happy delete # delete a url
37
+ get_happy help [COMMAND] # Describe available commands or one specific command
38
+ get_happy import_playlist [ID] # import a youtube playlist
39
+ get_happy list # list collection
40
+ get_happy play # play a random song
41
+ get_happy seed # seed with some sample urls
35
42
 
36
43
  Play a random song
37
44
 
@@ -41,10 +48,12 @@ List collection
41
48
 
42
49
  $ get_happy list
43
50
  Ioannis Total 4
44
- 🚀 https://www.youtube.com/watch?v=s3Q80mk7bxE
45
- 🚀 https://www.youtube.com/watch?v=LxDhlzJR4XQ
46
- 🚀 https://www.youtube.com/watch?v=HqYnevHibaI
47
- 🚀 https://www.youtube.com/watch?v=8kMZcA5oEAA
51
+ 🚀 https://www.youtube.com/watch?v=oijgjddWhjI
52
+ 🚀 https://www.youtube.com/watch?v=YESZ1S1zLWg
53
+ 🚀 https://www.youtube.com/watch?v=vyGv-dV_bV8
54
+ 🚀 https://www.youtube.com/watch?v=yBP_Re9r9MI
55
+ 🚀 https://www.youtube.com/watch?v=N43cdFeSNnQ
56
+ 🚀 https://www.youtube.com/watch?v=jXjdyfkL5Ko
48
57
 
49
58
  Seed with some sample urls
50
59
 
@@ -70,6 +79,12 @@ Delete a url
70
79
 
71
80
  $ get_happy delete https://www.youtube.com/watch?v=s3Q80mk7bxE
72
81
 
82
+ Import Youtube Playlist
83
+
84
+ $ get_happy import_playlist B2A4E1367126848D
85
+ => Found 25 items
86
+ => Import playlist?
87
+
73
88
 
74
89
  ## Contributing
75
90
 
@@ -78,3 +93,31 @@ Delete a url
78
93
  3. Commit your changes (`git commit -am 'Add some feature'`)
79
94
  4. Push to the branch (`git push origin my-new-feature`)
80
95
  5. Create a new Pull Request
96
+
97
+
98
+
99
+
100
+ ## License
101
+
102
+ Copyright (c) 2015 Ioannis Kolovos
103
+
104
+ MIT License
105
+
106
+ Permission is hereby granted, free of charge, to any person obtaining
107
+ a copy of this software and associated documentation files (the
108
+ "Software"), to deal in the Software without restriction, including
109
+ without limitation the rights to use, copy, modify, merge, publish,
110
+ distribute, sublicense, and/or sell copies of the Software, and to
111
+ permit persons to whom the Software is furnished to do so, subject to
112
+ the following conditions:
113
+
114
+ The above copyright notice and this permission notice shall be
115
+ included in all copies or substantial portions of the Software.
116
+
117
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
118
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
119
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
120
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
121
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
122
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
123
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -6,5 +6,9 @@ task :build_local do
6
6
  system "rake build && rake install"
7
7
  end
8
8
 
9
- task :default => :spec
10
9
 
10
+ task :default do
11
+ system "bundle exec rspec"
12
+ end
13
+
14
+ task :default => :spec
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["yannis.kolovos@gmail.com"]
11
11
  spec.summary = "A Gem to make you happy!"
12
12
  spec.description = "Creates a collection with your music favorite links and opens a random one"
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/msroot/get_happy"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "coveralls", "~> 0.7.11"
24
- spec.add_development_dependency "minitest", "~> 5.5.1"
25
- spec.add_development_dependency "rspec", "~> 3.2.0"
26
- spec.add_development_dependency "guard", "~> 2.12.5"
27
- spec.add_development_dependency "guard-rspec", "~> 4.5.0"
24
+ spec.add_development_dependency "minitest", '~> 5.5', '>= 5.5.1'
25
+ spec.add_development_dependency "rspec", '~> 3.2', '>= 3.2.0'
26
+ spec.add_development_dependency "guard", '~> 2.12', '>= 2.12.5'
27
+ spec.add_development_dependency "guard-rspec", '~> 4.5', '>= 4.5.0'
28
28
  spec.add_runtime_dependency "thor", "~> 0.19.1"
29
29
  end
@@ -1,13 +1,12 @@
1
1
  require "get_happy/version"
2
2
  require "thor"
3
3
  require 'yaml'
4
+ require 'json'
4
5
  require "get_happy/cli"
5
6
  require "get_happy/engine"
6
7
 
7
-
8
-
9
8
  module GetHappy
10
9
  class CLI
11
10
  default_task :play
12
11
  end
13
- end
12
+ end
@@ -22,7 +22,7 @@ module GetHappy
22
22
 
23
23
  desc "list", "list collection"
24
24
  def list
25
- @collection ||= GetHappy.get_collection
25
+ @collection = GetHappy.get_collection
26
26
  user = `echo $USER`.gsub("\n", "")
27
27
 
28
28
  say " \n"
@@ -37,26 +37,39 @@ module GetHappy
37
37
  def clean
38
38
  @collection = []
39
39
  GetHappy.write_collection([])
40
- say "Collection is empty"
40
+ say "Collection is empty", :green
41
41
  end
42
42
 
43
43
  desc "seed", "seed with some sample urls"
44
44
  def seed
45
45
  GetHappy.seed
46
- @collection = GetHappy.get_collection
47
46
  list
48
47
  end
49
48
 
50
49
  desc "delete", "delete a url"
51
50
  def delete(url)
52
- @collection ||= GetHappy.get_collection
53
- @collection.delete(url.to_s)
51
+ @collection = GetHappy.get_collection
52
+ deleted = !!@collection.delete(url.to_s)
54
53
  GetHappy.write_collection(@collection)
55
- list
54
+ say deleted, deleted ? :green : :red
55
+ end
56
+
57
+
58
+ desc "import_playlist [ID]", "import a youtube playlist"
59
+ def import_playlist(id)
60
+ GetHappy.ensure_user_data!
61
+
62
+ playlist = GetHappy.get_playlist(id)
63
+ say "Found #{playlist.size} items"
64
+
65
+ unless playlist.empty?
66
+ if yes?("Import playlist?", :green)
67
+ GetHappy.write_collection(playlist)
68
+ list
69
+ end
70
+ end
71
+
56
72
  end
57
73
 
58
74
  end
59
75
  end
60
-
61
-
62
-
@@ -2,10 +2,12 @@ module GetHappy
2
2
  extend self
3
3
 
4
4
  @urls = %w(
5
- https://www.youtube.com/watch?v=s3Q80mk7bxE
6
- https://www.youtube.com/watch?v=LxDhlzJR4XQ
7
- https://www.youtube.com/watch?v=HqYnevHibaI
8
- https://www.youtube.com/watch?v=8kMZcA5oEAA
5
+ https://www.youtube.com/watch?v=oijgjddWhjI
6
+ https://www.youtube.com/watch?v=YESZ1S1zLWg
7
+ https://www.youtube.com/watch?v=vyGv-dV_bV8
8
+ https://www.youtube.com/watch?v=yBP_Re9r9MI
9
+ https://www.youtube.com/watch?v=N43cdFeSNnQ
10
+ https://www.youtube.com/watch?v=jXjdyfkL5Ko
9
11
  )
10
12
 
11
13
  COLLECTION_DIR = Dir.home + '/.get_happy'
@@ -23,6 +25,19 @@ module GetHappy
23
25
  end
24
26
 
25
27
  def get_collection
28
+ ensure_user_data!
29
+ YAML::load_file(COLLECTION)
30
+ end
31
+
32
+ def get_playlist(id)
33
+ url = "http://gdata.youtube.com/feeds/api/playlists/#{id}?v=2&alt=json"
34
+ request = Net::HTTP.get_response(URI.parse(url))
35
+ success = request.is_a? Net::HTTPSuccess
36
+ data = JSON.parse(request.body, :symbolize_names => true) if success
37
+ success ? data[:feed][:entry].map {|e| e[:link].first[:href]} : []
38
+ end
39
+
40
+ def ensure_user_data!
26
41
  unless File.directory?(COLLECTION_DIR)
27
42
  FileUtils.mkdir_p(COLLECTION_DIR)
28
43
  end
@@ -30,9 +45,7 @@ module GetHappy
30
45
  File.open(COLLECTION, "w") do |file|
31
46
  file.write [].to_yaml
32
47
  end unless File.file?(COLLECTION)
33
-
34
- YAML::load_file(COLLECTION)
35
- end
36
-
48
+ end
49
+
37
50
  end
38
51
 
@@ -1,3 +1,3 @@
1
1
  module GetHappy
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,5 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
+
4
+
5
+
3
6
  describe GetHappy do
4
7
  before(:each) do
5
8
  FileUtils.rm_rf(GetHappy::COLLECTION_DIR)
@@ -12,79 +15,87 @@ describe GetHappy do
12
15
  expect(File.directory?(GetHappy::COLLECTION_DIR)).to be true
13
16
  expect(File.file?(GetHappy::COLLECTION)).to be true
14
17
  end
15
-
16
-
18
+
19
+
17
20
  it "methods" do
18
21
  script = GetHappy::CLI.new
19
22
  script.respond_to? :add
20
23
  %i(add clean delete list play seed).each do |method|
21
- expect(script.methods).to include method
22
- expect(script).to respond_to method
23
- end
24
+ expect(script.methods).to include method
25
+ expect(script).to respond_to method
26
+ end
24
27
  end
25
-
28
+
26
29
  it "should list" do
27
30
  out = capture_io{ GetHappy::CLI.start %w{ list} }.join ''
28
- expect(out).to match /Ioannis Total./
31
+ whoami = `whoami`.gsub("\n", "")
32
+ expect(out).to match "#{whoami} Total."
29
33
  end
30
-
31
-
34
+
35
+
32
36
  it "should delete" do
33
- GetHappy::CLI.start %w{ }
37
+ GetHappy::CLI.start %w{ }
34
38
  expect(YAML::load_file(GetHappy::COLLECTION)).to be_empty
35
- GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
39
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
36
40
  expect(YAML::load_file(GetHappy::COLLECTION)).to include("https://www.youtube.com/watch?v=u9h7Teiyvc8")
37
-
38
- GetHappy::CLI.start %w{ delete https://www.youtube.com/watch?v=u9h7Teiyvc8}
41
+
42
+ GetHappy::CLI.start %w{ delete https://www.youtube.com/watch?v=u9h7Teiyvc8}
39
43
  expect(YAML::load_file(GetHappy::COLLECTION)).not_to include("https://www.youtube.com/watch?v=u9h7Teiyvc8")
40
44
  end
41
-
45
+
42
46
  it "should clean" do
43
- GetHappy::CLI.start %w{ seed}
47
+ GetHappy::CLI.start %w{ seed}
44
48
  expect(YAML::load_file(GetHappy::COLLECTION)).not_to be_empty
45
- GetHappy::CLI.start %w{ clean}
49
+ GetHappy::CLI.start %w{ clean}
46
50
  expect(YAML::load_file(GetHappy::COLLECTION)).to be_empty
47
51
  end
48
-
52
+
49
53
  it "should play" do
50
54
  GetHappy::CLI.start %w{ seed}
51
55
 
52
56
  out, err = capture_io do
53
57
  GetHappy::CLI.start %w{ play}
54
58
  end
55
-
59
+
56
60
  expect(out.strip).to include "run open https://www.youtube.com/watch?v="
57
61
  expect(err).to be_empty
58
62
  end
59
-
60
-
63
+
64
+
61
65
  it "should seed" do
62
- GetHappy::CLI.start %w{}
66
+ GetHappy::CLI.start %w{}
63
67
  expect(YAML::load_file(GetHappy::COLLECTION)).to be_empty
64
- GetHappy::CLI.start %w{ seed}
68
+ GetHappy::CLI.start %w{ seed}
65
69
  expect(YAML::load_file(GetHappy::COLLECTION)).not_to be_empty
66
70
  end
67
-
71
+
68
72
  it "should add" do
69
73
  GetHappy::CLI.start %w{}
70
74
  before = YAML::load_file(GetHappy::COLLECTION)
71
- GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
75
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
72
76
  after = YAML::load_file(GetHappy::COLLECTION)
73
-
77
+
74
78
  expect(before).to_not be after
75
79
  expect(after.first).to match /u9h7Teiyvc8/
76
80
  end
77
-
78
-
79
-
81
+
82
+
83
+
80
84
  it "should not add duplicates" do
81
- GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
85
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
82
86
  expect(YAML::load_file(GetHappy::COLLECTION).size).to eq 1
83
- GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
87
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
84
88
  expect(YAML::load_file(GetHappy::COLLECTION).size).to eq 1
85
89
  end
86
-
87
-
90
+
91
+ it "should import list" do
92
+ allow_any_instance_of(Thor::Actions).to receive(:yes?).and_return(true)
93
+
94
+ id = "B2A4E1367126848D"
95
+ playlist = GetHappy.get_playlist(id)
96
+ GetHappy::CLI.start %w{ import_playlist B2A4E1367126848D}
97
+
98
+ expect(YAML::load_file(GetHappy::COLLECTION).size).to eq playlist.size
99
+ end
88
100
 
89
101
  end
90
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_happy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ioannis Kolovos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-29 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,9 @@ dependencies:
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.5'
62
+ - - ">="
60
63
  - !ruby/object:Gem::Version
61
64
  version: 5.5.1
62
65
  type: :development
@@ -64,6 +67,9 @@ dependencies:
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '5.5'
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: 5.5.1
69
75
  - !ruby/object:Gem::Dependency
@@ -71,6 +77,9 @@ dependencies:
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.2'
82
+ - - ">="
74
83
  - !ruby/object:Gem::Version
75
84
  version: 3.2.0
76
85
  type: :development
@@ -78,6 +87,9 @@ dependencies:
78
87
  version_requirements: !ruby/object:Gem::Requirement
79
88
  requirements:
80
89
  - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '3.2'
92
+ - - ">="
81
93
  - !ruby/object:Gem::Version
82
94
  version: 3.2.0
83
95
  - !ruby/object:Gem::Dependency
@@ -85,6 +97,9 @@ dependencies:
85
97
  requirement: !ruby/object:Gem::Requirement
86
98
  requirements:
87
99
  - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '2.12'
102
+ - - ">="
88
103
  - !ruby/object:Gem::Version
89
104
  version: 2.12.5
90
105
  type: :development
@@ -92,6 +107,9 @@ dependencies:
92
107
  version_requirements: !ruby/object:Gem::Requirement
93
108
  requirements:
94
109
  - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '2.12'
112
+ - - ">="
95
113
  - !ruby/object:Gem::Version
96
114
  version: 2.12.5
97
115
  - !ruby/object:Gem::Dependency
@@ -99,6 +117,9 @@ dependencies:
99
117
  requirement: !ruby/object:Gem::Requirement
100
118
  requirements:
101
119
  - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '4.5'
122
+ - - ">="
102
123
  - !ruby/object:Gem::Version
103
124
  version: 4.5.0
104
125
  type: :development
@@ -106,6 +127,9 @@ dependencies:
106
127
  version_requirements: !ruby/object:Gem::Requirement
107
128
  requirements:
108
129
  - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '4.5'
132
+ - - ">="
109
133
  - !ruby/object:Gem::Version
110
134
  version: 4.5.0
111
135
  - !ruby/object:Gem::Dependency
@@ -132,6 +156,7 @@ extensions: []
132
156
  extra_rdoc_files: []
133
157
  files:
134
158
  - ".gitignore"
159
+ - ".travis.yml"
135
160
  - Gemfile
136
161
  - Guardfile
137
162
  - LICENSE.txt
@@ -146,7 +171,7 @@ files:
146
171
  - spec/get_happpy_spec.rb
147
172
  - spec/screen_shot.png
148
173
  - spec/spec_helper.rb
149
- homepage: ''
174
+ homepage: https://github.com/msroot/get_happy
150
175
  licenses:
151
176
  - MIT
152
177
  metadata: {}
@@ -166,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
191
  version: '0'
167
192
  requirements: []
168
193
  rubyforge_project:
169
- rubygems_version: 2.2.2
194
+ rubygems_version: 2.4.5.1
170
195
  signing_key:
171
196
  specification_version: 4
172
197
  summary: A Gem to make you happy!