epilicious 0.3.3 → 0.3.4

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: 3dcc4875efef2e7e510646b48699d003e58ac635
4
- data.tar.gz: f0033a03a7d99bb1803b2a34cdcb3c8c6bfc7447
3
+ metadata.gz: 170281222a736d0997d09ba5a446e7164de02de6
4
+ data.tar.gz: 15b6029fd20d48e93f4aac367b3c7cac0ffe182b
5
5
  SHA512:
6
- metadata.gz: dd130556b1a1791ea1c3a3c735e93d5ecaa478192fb089f1623872726bbaf345ab13361d95be89c7de94440cf28d4e85e3f812126d3fe8a615a49220beb3c3c2
7
- data.tar.gz: 8ddb85e92fc9baba81a152b90e61ee0d10049e0f2099c8083b505bc993ef6586d428381e579cbf96eeddba96ad4ce85e2161c03e2950ef306669ae04f0ccc0b3
6
+ metadata.gz: 708d04bfde5cd51e24c66737d7b3803c3aca4008bb21fd188140ce299dee4d14443ff37c295212dd9579ef7fbf943eb8ffab95c5244e65215a4486966713e225
7
+ data.tar.gz: 2efb3f8aa14c7ee8e6448753af7d01e73cfb2753964e4e9b026dd2c1032358d72cd7accbcbddacdfa5a1884bcfc3d9e47bf060447702fd4d7c406978c9efdd12
data/Rakefile CHANGED
@@ -16,3 +16,8 @@ Rake::TestTask.new(:recipe) do |t|
16
16
  t.libs << "test"
17
17
  t.test_files = FileList["test/**/recipe_test.rb"]
18
18
  end
19
+
20
+ Rake::TestTask.new(:utilities) do |t|
21
+ t.libs << "test"
22
+ t.test_files = FileList["test/**/utilities_test.rb"]
23
+ end
@@ -20,9 +20,7 @@ module Epilicious
20
20
  end
21
21
 
22
22
  JSON.parse(recipe_vault).map do |recipe|
23
- recipe.keys.each do |key|
24
- recipe[(key.to_sym rescue key) || key] = recipe.delete(key)
25
- end
23
+ Utilities.symbolize_keys(recipe)
26
24
  Recipe.new(recipe)
27
25
  end
28
26
  end
@@ -45,6 +43,5 @@ module Epilicious
45
43
  def self.uri
46
44
  URI.parse(ENV["REDISCLOUD_URL"])
47
45
  end
48
-
49
46
  end
50
47
  end
@@ -31,11 +31,7 @@ module Epilicious
31
31
  private
32
32
 
33
33
  def fetch_page(url)
34
- if url =~ /http\:\/\/.*\//
35
- Nokogiri::HTML(open(url))
36
- else
37
- Nokogiri::HTML(open(@base_url + url))
38
- end
34
+ Nokogiri::HTML(open(@base_url + url))
39
35
  end
40
36
 
41
37
  def parser
@@ -43,11 +39,3 @@ module Epilicious
43
39
  end
44
40
  end
45
41
  end
46
-
47
-
48
-
49
- class Recipe
50
- def initialize(args)
51
- @name = args[:name]
52
- end
53
- end
@@ -0,0 +1,15 @@
1
+ module Epilicious
2
+ module Utilities
3
+
4
+ def self.symbolize_keys(import_hash)
5
+ import_hash.keys.each do |key|
6
+ import_hash[(key.to_sym rescue key) || key] = import_hash.delete(key)
7
+ end
8
+ import_hash
9
+ end
10
+
11
+ def self.strip_url(url)
12
+ url.gsub!(/http\:\/\/[^\/]+/, "")
13
+ end
14
+ end
15
+ end
@@ -1,2 +1,2 @@
1
1
  module Epilicious
2
- VERSION = "0.3.3" end
2
+ VERSION = "0.3.4" end
data/lib/epilicious.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require "epilicious/version"
2
2
  require "epilicious/fetcher"
3
3
  require "epilicious/cookbook"
4
+ require "epilicious/utilities"
4
5
 
5
6
  module Epilicious
6
7
  def self.recipes(url = recipes_url)
8
+ url = Utilities.strip_url(url)
7
9
  CookBook.recipes(url)
8
10
  end
9
11
 
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'pry'
2
3
 
3
4
  describe Epilicious::CookBook do
4
5
  let(:cookbook) { Epilicious::CookBook }
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ describe Epilicious::Utilities do
4
+ let(:utilities) { Epilicious::Utilities }
5
+
6
+ context ".symbolize_keys" do
7
+ it "should convert string keys into symbols" do
8
+ hash = utilities.symbolize_keys({"one" => nil, "two" => nil})
9
+ hash.keys.must_equal [:one, :two]
10
+ end
11
+ end
12
+
13
+ context ".strip url" do
14
+ it "should return a relative url" do
15
+ input_url = "http://www.epicurious.com/test/"
16
+ output_url = utilities.strip_url(input_url)
17
+ output_url.must_match(/\A\/.+/)
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epilicious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Hein Hoogstad
@@ -140,6 +140,7 @@ files:
140
140
  - lib/epilicious/fetcher.rb
141
141
  - lib/epilicious/parser.rb
142
142
  - lib/epilicious/recipe.rb
143
+ - lib/epilicious/utilities.rb
143
144
  - lib/epilicious/version.rb
144
145
  - test/cookbook_test.rb
145
146
  - test/epilicious_test.rb
@@ -148,6 +149,7 @@ files:
148
149
  - test/parser_test.rb
149
150
  - test/recipe_test.rb
150
151
  - test/test_helper.rb
152
+ - test/utilities_test.rb
151
153
  homepage: ''
152
154
  licenses:
153
155
  - MIT
@@ -180,3 +182,4 @@ test_files:
180
182
  - test/parser_test.rb
181
183
  - test/recipe_test.rb
182
184
  - test/test_helper.rb
185
+ - test/utilities_test.rb