shoppinglist 0.0.5.pre

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58c3d1bb84688ea7a6648235c2c650d719772290
4
+ data.tar.gz: c470f394f5d85a68b59e18999b46018a32096a56
5
+ SHA512:
6
+ metadata.gz: ce1171325216e2129a927fa768c65011922c4b766957221744071573cb38a1fa87f6144d6d544178dabfecfd95ed5b7e084d307bbe758f28a4daf5241dd3a69f
7
+ data.tar.gz: a38b27f60fa9f2b290a8cd391e64c9d14f054325301419a0853c8e76c29073c1f3255cfcb13a3a4114772fc22f8e5f3712f91049c0e2d34af5efee8a9dd0e63e
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ .idea/*
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ -f d
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shoppinglist.gemspec
4
+ #gemspec
5
+
6
+ group :production, :test do
7
+ gem 'bundler'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'guard'
11
+ gem 'guard-rspec'
12
+ gem 'rb-inotify'
13
+
14
+ end
15
+
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { 'spec' }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| %W(spec/routing/#{m[1]}_routing_spec.rb spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb spec/acceptance/#{m[1]}_spec.rb) }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
14
+ watch('config/routes.rb') { 'spec/routing' }
15
+ watch('app/controllers/application_controller.rb') { 'spec/controllers' }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 gekken
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,42 @@
1
+ # ShoppingList
2
+
3
+ This is a simple gem that creates shopping lists with an intentionally simple API.
4
+
5
+ At this time, ShoppingList intentionally uses the standard *nix Dropbox(tm) installation location. ~/Dropbox/
6
+
7
+
8
+ v1 will be a shoes application, with Windows compatibility
9
+ v2 will be built in JRuby for Android use.
10
+ v3 will be a Rails site that integrates the Android app, a desktop client, and the site.
11
+
12
+ ## Requirements
13
+
14
+ working Dropbox installation at ~/Dropbox
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'shoppinglist'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install shoppinglist
29
+
30
+ ## Usage
31
+
32
+ TODO: Write usage instructions here
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
41
+
42
+ [![Code Climate](https://codeclimate.com/github/gekken/shopping_list.png)](https://codeclimate.com/github/gekken/shopping_list)
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ namespace :install do
10
+ directory File.expand_path "~/Dropbox/ShoppingList"
11
+ end
data/bin/shoppinglist ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $: << "../lib"
3
+ require 'shopping_list'
4
+
@@ -0,0 +1,41 @@
1
+ $: << File.dirname(__FILE__)
2
+
3
+
4
+ require 'yaml'
5
+ require 'find'
6
+ require 'shoppinglist/version'
7
+ require 'shoppinglist/list'
8
+ require 'shoppinglist/item'
9
+
10
+
11
+ module ShoppingList
12
+
13
+ $holding_list = []
14
+
15
+
16
+ def self.directory
17
+ File.expand_path("~/Dropbox/ShoppingList")
18
+ end
19
+
20
+ def self.full_path file
21
+ "#{directory}/#{file}"
22
+ end
23
+
24
+ def self.file_list
25
+ files = []
26
+ Find.find(directory) { |f| files << f }; files.shift
27
+ files
28
+ end
29
+
30
+ def self.load! list
31
+ $holding_list = YAML.load_file full_path(list)
32
+ end
33
+
34
+ def self.search item
35
+ this = []
36
+ ShoppingList.file_list.each {|f| YAML.load(File.open(f)).each {|i| this << f if i.name =~ /#{item}/}}
37
+ this
38
+ end
39
+
40
+
41
+ end
@@ -0,0 +1,24 @@
1
+ module ShoppingList
2
+
3
+ class Item
4
+
5
+ attr_accessor :name, :store, :amount, :category
6
+
7
+ def initialize(name, amount=1, category='none', location='none')
8
+ @amount = amount
9
+ @name = name
10
+ @store = location
11
+ @category = category
12
+ end
13
+
14
+ def to_hash
15
+ {name: self.name, amount: self.amount, store: self.store, category: self.category}
16
+ end
17
+
18
+ def add_to_list
19
+ $holding_list << self
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,45 @@
1
+ module ShoppingList
2
+
3
+ class List
4
+
5
+ attr_accessor :items, :name, :location, :directory
6
+
7
+ def initialize name=mylist
8
+ @directory = FileUtils.mkdir_p(ShoppingList.directory).join
9
+ File.new "#{@directory}/#{@name}"
10
+ @name = name
11
+ @location = "#{@directory}/#{@name}"
12
+ @items = $holding_list
13
+
14
+ end
15
+
16
+
17
+ def list_to_hash
18
+ {name: self.name, location: self.location, items: self.items}
19
+ end
20
+
21
+
22
+ def save
23
+ File.open(@location, 'w') do |f|
24
+ f.write YAML.dump(@items)
25
+ end
26
+ end
27
+
28
+ def delete! name, list=@name
29
+ things = YAML.load_file(File.open("#{@directory}/#{list}"))
30
+ things.reject! { |i| i.name == name }
31
+ File.open(File.expand_path("#{@directory}/#{list}"), 'w') do |f|
32
+ f.write YAML.dump(things)
33
+ end
34
+ end
35
+
36
+
37
+ end
38
+ end
39
+
40
+
41
+
42
+
43
+
44
+
45
+
@@ -0,0 +1,3 @@
1
+ module ShoppingList
2
+ VERSION = '0.0.5.pre'
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shoppinglist/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'shoppinglist'
8
+ spec.version = ShoppingList::VERSION
9
+ spec.authors = %w(Peter Bomars)
10
+ spec.email = %w(pbomars@gmail.com)
11
+ spec.description = %q{Simple shopping list gem}
12
+ spec.summary = %q{A simple gem that allows the user to create shopping lists, storing them in ~/Dropbox/ShoppingList by default.}
13
+ spec.homepage = 'https://github.com/gekken/shopping_list'
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 = %w(lib)
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe ShoppingList::Item do
4
+
5
+ subject = ShoppingList::Item.new('notebook, three-ringed', 1, 'work supplies', 'Staples')
6
+ subject2 = ShoppingList::Item.new('pants', 2, 'clothes', nil)
7
+
8
+
9
+ context '#new' do
10
+ it 'has a name' do
11
+ subject.name.should == 'notebook, three-ringed'
12
+ end
13
+
14
+ it 'has a store' do
15
+ subject.store.should == 'Staples'
16
+ end
17
+
18
+ it 'has an amount' do
19
+ subject.amount.should == 1
20
+ end
21
+
22
+ it 'has a category' do
23
+ subject.category.should == 'work supplies'
24
+ end
25
+
26
+ end
27
+
28
+ context '#to_hash' do
29
+
30
+ it 'converts the object to a hash' do
31
+
32
+ expected = {name: 'notebook, three-ringed',
33
+ amount: 1,
34
+ category: 'work supplies',
35
+ store: 'Staples'}
36
+ subject.to_hash.should == expected
37
+ end
38
+
39
+ end
40
+
41
+ context '#add_to_list' do
42
+ it 'saves the item to $holding_list' do
43
+ subject.add_to_list
44
+ subject2.add_to_list
45
+ expected = [{:name => 'notebook, three-ringed', :amount => 1, :store => 'Staples', :category => 'work supplies'},
46
+ {:name => 'pants', :amount => 2, :store => nil, :category => 'clothes'}]
47
+ $holding_list.collect { |i| i.to_hash }.should == expected
48
+
49
+
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe ShoppingList::List do
4
+
5
+ list_subject = ShoppingList::List.new('list')
6
+ list_subject2 = ShoppingList::List.new('test_list')
7
+
8
+ context '#new' do
9
+ it 'has a name' do
10
+ list_subject.name.should == 'list'
11
+ end
12
+
13
+ end
14
+
15
+ context '#list_to_hash' do
16
+ it 'returns a hash of the item' do
17
+ expected = {:items => $holding_list,
18
+ :location => File.expand_path('~/Dropbox/ShoppingList/list'),
19
+ :name => 'list'}
20
+ list_subject.list_to_hash.should == expected
21
+
22
+ end
23
+ end
24
+
25
+ context '#save' do
26
+ it 'adds the items in $holding_list to specified file' do
27
+ list_subject.save
28
+ saved = YAML.load_file(File.open File.expand_path('~/Dropbox/ShoppingList/list'))
29
+ expected = [{:name => 'notebook, three-ringed', :amount => 1, :store => 'Staples', :category => 'work supplies'},
30
+ {:name => 'pants', :amount => 2, :store => nil, :category => 'clothes'}]
31
+ saved.collect { |i| i.to_hash }.should == expected
32
+
33
+ end
34
+ end
35
+
36
+ context '#delete!' do
37
+ it 'removes the specified item (by name) from the specified list' do
38
+ list_subject2.save
39
+ expect(list_subject2.delete!('pants', 'test_list')).to be_true
40
+ end
41
+ end
42
+
43
+
44
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe ShoppingList do
4
+
5
+ list_subject = YAML.load_file (ShoppingList.full_path 'test_list')
6
+ list_subject2 = YAML.load_file (ShoppingList.full_path 'list')
7
+
8
+ it 'has a version' do
9
+ ShoppingList::VERSION.should_not == nil
10
+ end
11
+
12
+ context '#directory' do
13
+ it 'returns the default directory' do
14
+ ShoppingList.directory.should == File.expand_path("~/Dropbox/ShoppingList")
15
+ end
16
+ end
17
+
18
+ context '#full_path' do
19
+ it 'calls #directory and appends the supplied file name' do
20
+ ShoppingList.full_path('list').should == "#{ShoppingList.directory}/list"
21
+ end
22
+ end
23
+
24
+ context '#file_list' do
25
+ it 'returns an array of all the shopping lists in the default directory' do
26
+ ShoppingList.file_list.should == [ShoppingList.full_path('list'),ShoppingList.full_path('test_list')]
27
+ end
28
+ end
29
+
30
+ context '#load!' do
31
+ it 'loads the supplied list, wiping out any buffered additions' do
32
+ $holding_list = list_subject2
33
+
34
+ ShoppingList.load!('test_list')
35
+
36
+ expected = $holding_list.collect { |i| i.to_hash }
37
+ tested = list_subject.collect { |i| i.to_hash }
38
+ tested.should == expected
39
+ end
40
+ end
41
+
42
+ context '#search' do
43
+ it 'returns an array of the file name(s) that has/have the specified item' do
44
+ ShoppingList.search('pants').should == [ShoppingList.full_path('list')]
45
+ #puts ShoppingList.search('notebook')
46
+ end
47
+ end
48
+
49
+
50
+ end
@@ -0,0 +1,25 @@
1
+ require 'shopping_list'
2
+ require 'rspec'
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # Require this file using `require "spec_helper"` to ensure that it is only
7
+ # loaded once.
8
+ #
9
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
+
11
+ $: << File.dirname(__FILE__)
12
+
13
+ #RSpec.configure do |config|
14
+ # config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ # config.run_all_when_everything_filtered = true
16
+ # config.filter_run :focus
17
+
18
+ # Run specs in random order to surface order dependencies. If you find an
19
+ # order dependency and want to debug it, you can fix the order by providing
20
+ # the seed, which is printed after each run.
21
+ # --seed 1234
22
+ #config.order = 'random'
23
+ #end
24
+
25
+
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shoppinglist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5.pre
5
+ platform: ruby
6
+ authors:
7
+ - Peter
8
+ - Bomars
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Simple shopping list gem
43
+ email:
44
+ - pbomars@gmail.com
45
+ executables:
46
+ - shoppinglist
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - .gitignore
51
+ - .rspec
52
+ - Gemfile
53
+ - Guardfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/shoppinglist
58
+ - lib/shopping_list.rb
59
+ - lib/shoppinglist/item.rb
60
+ - lib/shoppinglist/list.rb
61
+ - lib/shoppinglist/version.rb
62
+ - shoppinglist.gemspec
63
+ - spec/shoppinglist/item_spec.rb
64
+ - spec/shoppinglist/list_spec.rb
65
+ - spec/shoppinglist_spec.rb
66
+ - spec/spec_helper.rb
67
+ homepage: https://github.com/gekken/shopping_list
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>'
83
+ - !ruby/object:Gem::Version
84
+ version: 1.3.1
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.0.2
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A simple gem that allows the user to create shopping lists, storing them
91
+ in ~/Dropbox/ShoppingList by default.
92
+ test_files:
93
+ - spec/shoppinglist/item_spec.rb
94
+ - spec/shoppinglist/list_spec.rb
95
+ - spec/shoppinglist_spec.rb
96
+ - spec/spec_helper.rb