Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added install generator #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in spire.gemspec
gemspec

# lower rails version
gem "rails", "~> 4.0.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caseyli I went lower with rails 4 but can put this to whatever we want

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@7chris71000 so I like this functionality, but at the same time I don't want to restrict non-rails programs from using this gem. Would you mind researching how to make this optional? "Like if Rails is installed, run the generator. If Rails isn't installed, don't run it." I think that would be the best option.

135 changes: 92 additions & 43 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,76 +1,124 @@
PATH
remote: .
specs:
spire (2.3.0)
spire (3.3.0)
activemodel (>= 3.2.0)
json
rest-client (>= 1.8.0)

GEM
remote: https://rubygems.org/
specs:
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activesupport (5.2.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
coderay (1.1.2)
concurrent-ruby (1.1.6)
diff-lcs (1.3)
docile (1.3.0)
actionmailer (4.0.13)
actionpack (= 4.0.13)
mail (~> 2.5, >= 2.5.4)
actionpack (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
activerecord (4.0.13)
activemodel (= 4.0.13)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.13)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.4)
activesupport (4.0.13)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.2)
builder (3.1.4)
coderay (1.1.3)
concurrent-ruby (1.1.9)
diff-lcs (1.4.4)
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
factory_bot (4.8.2)
erubis (2.7.0)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
faker (1.8.7)
i18n (>= 0.7)
faker (2.2.1)
i18n (>= 0.8)
http-accept (1.7.0)
http-cookie (1.0.3)
http-cookie (1.0.4)
domain_name (~> 0.5)
i18n (1.5.1)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.3.1)
method_source (0.9.0)
json (2.5.1)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
minitest (5.14.1)
mime-types-data (3.2021.0225)
mini_mime (1.1.0)
minitest (4.7.5)
multi_json (1.15.0)
netrc (0.11.0)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rake (13.0.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (1.5.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.0.13)
actionmailer (= 4.0.13)
actionpack (= 4.0.13)
activerecord (= 4.0.13)
activesupport (= 4.0.13)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.13)
sprockets-rails (~> 2.0)
railties (4.0.13)
actionpack (= 4.0.13)
activesupport (= 4.0.13)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (13.0.3)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
simplecov (0.16.1)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
simplecov (0.21.2)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
thor (1.1.0)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
tzinfo (0.3.60)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unf_ext (0.0.7.7)

PLATFORMS
ruby
Expand All @@ -80,6 +128,7 @@ DEPENDENCIES
factory_bot (~> 4.8)
faker
pry
rails (~> 4.0.0)
rake (~> 13.0)
rspec (~> 3.2)
simplecov
Expand Down
60 changes: 50 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Spire

Spire is a Ruby wrapper around the [Spire Systems API](http://www.spiresystems.com/).

This gem was inspired by [ruby-trello](https://github.com/jeremytregunna/ruby-trello).
Expand All @@ -22,13 +23,29 @@ gem 'spire', git: "https://github.com/bitesite/spire-ruby", tag: "v2.5.0"

And then execute:

$ bundle
```shell
$ bundle
```

## Usage

First you will need to configure spire. This is a global configuration. Thus it will be applied anywhere you use spire within
your application.

### Rails

There are 2 options to configure your rails project to use this gem.

**Automated Rails Generator**

Run the following command in your projects root folder.

```shell
$ rails generate spire:install
```

**Manual**

If you are using spire within a Rails application, you could put the following config in an initializer.

```ruby
Expand All @@ -41,97 +58,117 @@ end
```

### Items

Below are a few usage examples. For other uses, please refer to `lib/item.rb`.

Will retrieve one item from Spire

```ruby
Spire::Item.find(itemId)
```

Will search Spire for an item that matches the given query

```ruby
Spire::Item.search('GF-1234')
```

Will retrieve many Items based on a filter from Spire

```ruby
Spire::Item.filter('{"partNo":"ABCD-0001", "whse":"00"}')
```

Will create a new item on Spire

```ruby
Spire::Item.create(options)
```

Will delete an item from Spire

```ruby
Spire::Item.find(itemId).delete
```

Updates item description on Spire

```ruby
item = Spire::Item.find(71)
item.description = 'This is a new description'
item.save
```

### UPCs

Below are a few usage examples. For other uses, please refer to `lib/upc.rb`.

Will retrieve many UPCs based on a filter from Spire

```ruby
Spire::Upc.filter('{"partNo":"ABCD-0001", "whse":"00"}')
```

Will retrieve one UPC from Spire

```ruby
Spire::Upc.find(upcId)
```

Will create a new UPC on Spire

```ruby
Spire::Upc.create(upc: "12345678901", uomCode: "EA", inventory: {id: 1})
```

Will delete a UPC from Spire

```ruby
Spire::Upc.find(upcId).delete
```

Updates a UPC on Spire

```ruby
upc = Spire::Upc.find(1)
upc.upc = '12345678902'
upc.save
```

### Customers

Below are a few usage examples. For other uses, please refer to `lib/customer.rb`.

Will retrieve one customer from Spire

```ruby
Spire::Customer.find(customerId)
```

Will search Spire for a customer that matches the given query

```ruby
Spire::Customer.search('[email protected]')
```

### Orders

The syntax for orders is very similar to items. For additional information please refer to `lib/order.rb`.

Will retrieve one order from Spire

```ruby
Spire::Order.find(orderId)
```

Will search Spire for any order that match the given query

```ruby
Spire::Order.search('[email protected]')
```

Will create order in Spire

```ruby
Spire::Order.create({
'customer' => {'id': 'customer id'},
Expand Down Expand Up @@ -167,12 +204,15 @@ Spire::Order.create({
'freight': '14'
})
```
*Above is the minimum param to create an order in Spire*

_Above is the minimum param to create an order in Spire_

### Vendors

The syntax for vendors is very similar to items. For additional information please refer to `lib/vendor.rb`.

Will retrieve one vendor from Spire

```ruby
Spire::Vendor.find(vendorId)
```
Expand All @@ -193,23 +233,23 @@ To install this gem onto your local machine, run `bundle exec rake install`.
4. ~~Build the gem `gem build spire.gemspec`~~
5. ~~Publish to BiteSite's RubyGems account `gem push spire-2.4.1.gem`~~

After trying to publish to rubygems.org, we realized we had a name conflict. If we changed the name of the gem,
After trying to publish to rubygems.org, we realized we had a name conflict. If we changed the name of the gem,
that would also affect the code that requires the top-level package. Until we're willing to release a Major version
upgrade with breaking changes, we'll just have to publish via GitHub.
upgrade with breaking changes, we'll just have to publish via GitHub.

Until then, when we're ready to release a new version:

1. On master, `git checkout master`
2. Make sure you have the latest changes `git pull`
2. Update `spire/version.rb` with a new version number following Semantic Versioning Rules.
3. Commit the change `git add .` and `git commit -m "Updated version number for release."`
4. Push changes `git push origin master`
5. Tag the commit `git tag 'vX.X.X'`
6. Push tags `git push origin --tags`
3. Update `spire/version.rb` with a new version number following Semantic Versioning Rules.
4. Commit the change `git add .` and `git commit -m "Updated version number for release."`
5. Push changes `git push origin master`
6. Tag the commit `git tag 'vX.X.X'`
7. Push tags `git push origin --tags`

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bitesite/spire.
Bug reports and pull requests are welcome on GitHub at https://github.com/bitesite/spire-ruby.

We do not currently support the entire [Spire](http://www.spiresystems.com/) api.
Any pull requests adding CRUD resources to this gem are appreciated.
Expand Down
Loading