Skip to content

Commit

Permalink
Move from Spree to Refinery
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez committed May 12, 2016
1 parent 1d7b8a1 commit 700a99c
Show file tree
Hide file tree
Showing 70 changed files with 203 additions and 200 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ build/

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
.gems
.rbenv-*
.ruby-version
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in spree-api.gemspec
# Specify your gem's dependencies in refinery-api.gemspec
gemspec
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
spree-api (0.1.0)
refinery-api (0.1.0)
faraday

GEM
Expand Down Expand Up @@ -51,7 +51,7 @@ DEPENDENCIES
pry
rake (~> 10.0)
rspec (~> 3.0)
spree-api!
refinery-api!
vcr
webmock

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[ ![Codeship Status for rocketsofawesome/spree-api](https://codeship.com/projects/49f0af80-c09a-0133-681a-7ec3d9f82d5d/status?branch=master)](https://codeship.com/projects/137289)
[ ![Codeship Status for rocketsofawesome/refinery-api](https://codeship.com/projects/49f0af80-c09a-0133-681a-7ec3d9f82d5d/status?branch=master)](https://codeship.com/projects/137289)

# Spree::Api
# Refinery::Api

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/spree/api`. To experiment with that code, run `bin/console` for an interactive prompt.
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/refinery/api`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

Expand All @@ -11,7 +11,7 @@ TODO: Delete this and the text above, and describe your gem
Add this line to your application's Gemfile:

```ruby
gem 'spree-api'
gem 'refinery-api'
```

And then execute:
Expand All @@ -20,7 +20,7 @@ And then execute:

Or install it yourself as:

$ gem install spree-api
$ gem install refinery-api

## Usage

Expand All @@ -34,7 +34,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/spree-api.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/refinery-api.


## License
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "spree/api"
require "refinery/api"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
23 changes: 23 additions & 0 deletions lib/refinery/api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "refinery/api/version"
require "refinery/api/configuration"
require "refinery/api/products"
require "refinery/api/variants"
require "refinery/api/taxonomies"
require "refinery/api/taxons"
require "refinery/api/option_types"
require "refinery/api/option_values"

require "faraday"

module Refinery
module API
class << self
attr_accessor :configuration
end

def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "faraday"

module Spree
module Refinery
module API
class Configuration
attr_accessor :api_token, :api_url, :api_path
Expand All @@ -13,7 +13,7 @@ def initialize

def connection
@_connection ||= ::Faraday.new(url: api_url,
headers: { "X-Spree-Token" => api_token,
headers: { "X-Refinery-Token" => api_token,
"Content-Type" => "application/json" }) do |faraday|
faraday.request :url_encoded
faraday.adapter Faraday.default_adapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Spree
module Refinery
module API
module Helpers
module ClientHelper
def config
@_config ||= Spree::API.configuration
@_config ||= Refinery::API.configuration
end

def api_path
Spree::API.configuration.api_path
Refinery::API.configuration.api_path
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Spree
module Refinery
module API
class OptionTypes
include Spree::API::Helpers::ClientHelper
include Refinery::API::Helpers::ClientHelper

def index
config.connection.get(option_types_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Spree
module Refinery
module API
class OptionValues
include Spree::API::Helpers::ClientHelper
include Refinery::API::Helpers::ClientHelper

def create(option_type_id:, option_value:)
config.connection.post(
Expand Down
6 changes: 3 additions & 3 deletions lib/spree/api/products.rb → lib/refinery/api/products.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "spree/api/helpers/client_helper"
require "refinery/api/helpers/client_helper"

module Spree
module Refinery
module API
class Products
include Spree::API::Helpers::ClientHelper
include Refinery::API::Helpers::ClientHelper

def index
config.connection.get(products_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "spree/api/helpers/client_helper"
require "refinery/api/helpers/client_helper"

module Spree
module Refinery
module API
class Taxonomies
include Spree::API::Helpers::ClientHelper
include Refinery::API::Helpers::ClientHelper

def index
config.connection.get(taxonomies_path)
Expand Down
6 changes: 3 additions & 3 deletions lib/spree/api/taxons.rb → lib/refinery/api/taxons.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "spree/api/helpers/client_helper"
require "refinery/api/helpers/client_helper"

module Spree
module Refinery
module API
class Taxons
include Spree::API::Helpers::ClientHelper
include Refinery::API::Helpers::ClientHelper

def index(taxonomy_id:)
config.connection.get(taxons_path(taxonomy_id))
Expand Down
6 changes: 3 additions & 3 deletions lib/spree/api/variants.rb → lib/refinery/api/variants.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "spree/api/helpers/client_helper"
require "refinery/api/helpers/client_helper"

module Spree
module Refinery
module API
class Variants
include Spree::API::Helpers::ClientHelper
include Refinery::API::Helpers::ClientHelper

def index(product_id: nil)
if product_id
Expand Down
2 changes: 1 addition & 1 deletion lib/spree/api/version.rb → lib/refinery/api/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Spree
module Refinery
module API
VERSION = "0.1.0"
end
Expand Down
23 changes: 0 additions & 23 deletions lib/spree/api.rb

This file was deleted.

10 changes: 5 additions & 5 deletions spree-api.gemspec → refinerycms-api-wrapper.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'spree/api/version'
require 'refinery/api/version'

Gem::Specification.new do |spec|
spec.name = "spree-api"
spec.version = Spree::API::VERSION
spec.name = "refinerycms-api-wrapper"
spec.version = Refinery::API::VERSION
spec.authors = ["Ian Rodriguez"]
spec.email = ["[email protected]"]

spec.summary = %q{This wraps the Spree commerce API in a simple yet flexible way.}
spec.description = %q{Interact with Spree commerce API using this awesome gem.}
spec.summary = %q{This wraps the Refinery commerce API in a simple yet flexible way.}
spec.description = %q{Interact with Refinery commerce API using this awesome gem.}
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.license = "MIT"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe Configuration do
let(:config) { described_class.new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe OptionTypes do
let(:client) { OptionTypes.new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe OptionValues do
let(:client) { OptionValues.new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe Products do
let(:client) { Products.new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe Taxonomies do
let(:client) { Taxonomies.new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe Taxons do
let(:client) { Taxons.new }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

module Spree
module Refinery
module API
RSpec.describe Variants do
let(:client) { Variants.new }
Expand Down
8 changes: 4 additions & 4 deletions spec/spree/api_spec.rb → spec/refinery/api_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

module Spree
module Refinery
RSpec.describe API do
it 'has a version number' do
expect(API::VERSION).not_to be nil
Expand All @@ -11,13 +11,13 @@ module Spree
end

it "sets configuration options through the block" do
Spree::API.configure do |config|
Refinery::API.configure do |config|
config.api_token = "1234"
config.api_url = "api.test.com"
end

expect(Spree::API.configuration.api_token).to eq("1234")
expect(Spree::API.configuration.api_url).to eq("api.test.com")
expect(Refinery::API.configuration.api_token).to eq("1234")
expect(Refinery::API.configuration.api_url).to eq("api.test.com")
end
end
end
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'spree/api'
require 'refinery/api'
require 'vcr'
require 'pry'

Expand All @@ -14,7 +14,7 @@
config.include Requests::JsonHelper

config.before(:each) do
Spree::API.configure do |conf|
Refinery::API.configure do |conf|
conf.api_token = "d3d1038e9338436c2db1e9ca597ef31b430e937aef90fba6"
conf.api_url = "http://localhost:3000"
conf.api_path = "/shop/api"
Expand Down
4 changes: 2 additions & 2 deletions spec/support/vcr_cassettes/option_values/create.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions spec/support/vcr_cassettes/option_values/destroy.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 700a99c

Please sign in to comment.