zazzle_rails 0.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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zazzle_rails.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'nokogiri'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nephtali Rodriguez
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # ZazzleRails
2
+
3
+ A gem geared towards parsing the Zazzle RSS feeds for a given store.
4
+
5
+ Ideally this will use their api instead of their RSS when they enable that kind of functionality.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'zazzle_rails'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install zazzle_rails
20
+
21
+ ## Usage
22
+
23
+ To use it, simply install and then you can get back your list of products using
24
+
25
+ ZazzleRails.get_products("YOUR STORE HERE")
26
+
27
+ This will return a hash of products from that store in the format of:
28
+
29
+ {:items=>
30
+ {:item_0=>
31
+ {:guid=>"256512229341746841",
32
+ :pubDate=>"Wed, 30 Jan 2013 06:10:16 GMT",
33
+ :title=>"justNeph Messenger Bag",
34
+ :link=>
35
+ "http://www.zazzle.com/justneph_messenger_bag_computer_bag-256512229341746841",
36
+ :author=>"justNeph",
37
+ :description=>
38
+ "Got stuff to carry. Got drugs to move. Got a copy of 50 Shades you're embarassed to carry. Get the justNeph Messenger Bag! It's comfortable, spacious and lets people kn
39
+ :price=>"$169.95",
40
+ :thumbnail=>
41
+ "http://rlv.zcache.com/justneph_messenger_bag_computer_bag-r53e6c2d36ac64d40aa15b71a7175d704_vxzzv_8byvr_152.jpg",
42
+ :content=>
43
+ "http://rlv.zcache.com/justneph_messenger_bag_computer_bag-r53e6c2d36ac64d40aa15b71a7175d704_vxzzv_8byvr_500.jpg",
44
+ :keywords=>"justneph, bag, messenger-bag, youtube",
45
+ :rating=>"g"}
46
+ }
47
+ }
48
+
49
+ With the attributes for each product being
50
+
51
+ - GUID
52
+ - Published Date
53
+ - Title
54
+ - Link
55
+ - Author
56
+ - Description
57
+ - Price
58
+ - Thumbnail (product image)
59
+ - Content (Full size product image)
60
+ - Keywords
61
+ - Rating
62
+
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new('spec')
@@ -0,0 +1,3 @@
1
+ module ZazzleRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ require "zazzle_rails/version"
2
+ require 'feedzirra'
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require "cgi"
6
+ module ZazzleRails
7
+ def self.get_products(store_name)
8
+ products = {:items => {}}
9
+ zazzle_feed = Nokogiri::XML(open("http://feed.zazzle.com/#{store_name}/feed")) do |config|
10
+ config.noblanks
11
+ end
12
+ zazzle_feed.xpath("//channel").xpath("//item").each_with_index do |item, index|
13
+ item_attributes = {}
14
+ item.children.each do |item_attr|
15
+ attr_to_add = ""
16
+ case item_attr.name
17
+ when "content", "thumbnail"
18
+ attr_to_add = item_attr.attributes["url"].text
19
+ when "guid"
20
+ attr_to_add = item_attr.text.match(/http:\/\/www.zazzle.com\/\D+-(\d+)/).captures.first
21
+ else
22
+ attr_to_add = CGI.unescape_html(item_attr.text)
23
+ end
24
+ item_attributes.merge!({"#{item_attr.name}".to_sym => attr_to_add})
25
+ end
26
+ products[:items].merge!({"item_#{index}".to_sym => item_attributes})
27
+ end
28
+ products
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require "pry"
8
+ require File.expand_path('../../lib/zazzle_rails.rb', __FILE__)
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ describe ZazzleRails do
3
+ describe "When hitting the zazzle rss" do
4
+ context "#get_products" do
5
+ it "gets back a parsed hash of products" do
6
+ ZazzleRails.get_products("justNeph").should be_present
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zazzle_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "zazzle_rails"
8
+ spec.version = ZazzleRails::VERSION
9
+ spec.authors = ["Nephtali Rodriguez"]
10
+ spec.email = ["nukz45@gmail.com"]
11
+ spec.description = %q{A way to retrieve products from a Zazzle store.}
12
+ spec.summary = %q{A gem to connect to retrieve a list of products from Zazzle Marketplace}
13
+ spec.homepage = "https://github.com/nrodriguez/zazzle_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_dependency "nokogiri"
25
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zazzle_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nephtali Rodriguez
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: nokogiri
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: A way to retrieve products from a Zazzle store.
79
+ email:
80
+ - nukz45@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - lib/zazzle_rails.rb
92
+ - lib/zazzle_rails/version.rb
93
+ - spec/spec_helper.rb
94
+ - spec/zazzle_rails_spec.rb
95
+ - zazzle_rails.gemspec
96
+ homepage: https://github.com/nrodriguez/zazzle_rails
97
+ licenses:
98
+ - MIT
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.24
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: A gem to connect to retrieve a list of products from Zazzle Marketplace
121
+ test_files:
122
+ - spec/spec_helper.rb
123
+ - spec/zazzle_rails_spec.rb
124
+ has_rdoc: