poro_plus 1.0.0
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/.console_history +100 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +12 -0
- data/lib/poro_plus.rb +28 -0
- data/lib/poro_plus/version.rb +3 -0
- data/poro_plus.gemspec +25 -0
- data/spec/lib/poro_plus/poro_plus_spec.rb +33 -0
- data/spec/spec_helper.rb +3 -0
- metadata +114 -0
data/.console_history
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
a.data.map{|d| d.to_tsv}
|
2
|
+
a.data(Date.today - 1.week, Date.today).map{|d| d.to_tsv}
|
3
|
+
a.data(Date.today - 1.week, Date.today).map{|d| d.to_tsv} * "\r"
|
4
|
+
pp
|
5
|
+
pp a.data(Date.today - 1.week, Date.today).map{|d| d.to_tsv} * "\r"
|
6
|
+
a.title
|
7
|
+
pp a.data(Date.today - 1.week, Date.today).map{|d| d.to_tsv}
|
8
|
+
pp a.fetch_data(Date.today - 1.week, Date.today)
|
9
|
+
a.data_points.last
|
10
|
+
a.data_points
|
11
|
+
p = Sources::GoogleAnalytics::Profile.new(email: 'coreybantik@gmail.com', password: '$amura!23')
|
12
|
+
a = p.accounts.last
|
13
|
+
p = Sources::GoogleAnalytics::Report.new(email: 'coreybantik@gmail.com', password: '$amura!23')
|
14
|
+
p.report
|
15
|
+
a = Sources::GoogleAnalytics::Account.new(email: 'coreybantik@gmail.com', password: '$amura!23')
|
16
|
+
a = Sources::GoogleAnalytics::Account.find(email: 'coreybantik@gmail.com', password: '$amura!23', '1')
|
17
|
+
a = Sources::GoogleAnalytics::Account.find('coreybantik@gmail.com','$amura!23123123', '1')
|
18
|
+
a = Sources::GoogleAnalytics::Account.find('coreybantik@gmail.com','$amura!23', '1')
|
19
|
+
a = Sources::GoogleAnalytics::Account.all('coreybantik@gmail.com','$amura!23')
|
20
|
+
a.profiles
|
21
|
+
a.email
|
22
|
+
a.profile
|
23
|
+
a = Sources::GoogleAnalytics::Account.find('coreybantik@gmail.com','$amura!23', 676985)
|
24
|
+
a = Sources::GoogleAnalytics::Account.all
|
25
|
+
a = Sources::GoogleAnalytics::Account.all('coreybantik@gmail.com', '$amura!23')
|
26
|
+
aa = _
|
27
|
+
a = aa.first
|
28
|
+
puts "FOO" unless bar = nil
|
29
|
+
puts "FOO" unless (bar = nil)
|
30
|
+
c = Sources::GoogleAnalytics::Connector.new
|
31
|
+
c = Sources::GoogleAnalytics::Connector.new(:email => 'coreybantik@gmail.com')
|
32
|
+
c = Sources::GoogleAnalytics::Connector.new(:email => 'coreybantik@gmail.com', :password => '$amura!23'))
|
33
|
+
c = Object.new
|
34
|
+
c.inspect
|
35
|
+
c.to_s
|
36
|
+
c.accounts
|
37
|
+
a = _.first
|
38
|
+
a = c.accounts.first
|
39
|
+
c.accounts.where(:profile_id => 45149121)
|
40
|
+
c.accounts.where(:profile_id => 45149121).first
|
41
|
+
a = _
|
42
|
+
r.account
|
43
|
+
c.pasword
|
44
|
+
c.password
|
45
|
+
a.repoert
|
46
|
+
a.report
|
47
|
+
a.report.data
|
48
|
+
a.password
|
49
|
+
a = c.accounts.where(:profile_id => 45149121).first; return nil
|
50
|
+
r.profile_id
|
51
|
+
r.fetch_data
|
52
|
+
c = Sources::GoogleAnalytics::Connector.new(:email => 'coreybantik@gmail.com', :password => '$amura!23'); nil
|
53
|
+
a = c.accounts.where(:profile_id => 45149121).first; nil
|
54
|
+
relaod!
|
55
|
+
SearchQuery::Property.new
|
56
|
+
q = _
|
57
|
+
exot
|
58
|
+
q = SearchQuery::Property.new
|
59
|
+
q = SearchQuery::Property.new; q.foo
|
60
|
+
q = SearchQuery::Property.new; q.page
|
61
|
+
q = SearchQuery::Property.new(:page = 1)
|
62
|
+
q.page
|
63
|
+
q.execute!
|
64
|
+
q.instance_variables
|
65
|
+
q = SearchQuery::Property.new(:page => 1)
|
66
|
+
q.to_attributes
|
67
|
+
include Searchable
|
68
|
+
reload!
|
69
|
+
searches 'SearchResult::Detail'
|
70
|
+
Foo.searches
|
71
|
+
c = Sources::GoogleAnalytics::Connector.new(:email => 'coreybantik@gmail.com', :password => '$amura!23')
|
72
|
+
c
|
73
|
+
a = c.accounts.where(:profile_id => 45149121).first
|
74
|
+
r = a.report
|
75
|
+
r.data
|
76
|
+
r.to_tsv
|
77
|
+
require 'json'
|
78
|
+
{:foo => 'bar'}.to_json
|
79
|
+
f.public_send(:bar => 1)
|
80
|
+
class Foo
|
81
|
+
def bar
|
82
|
+
puts "OL"
|
83
|
+
f = Foo.new
|
84
|
+
f.public_send(:foo)
|
85
|
+
f.public_send(:bar)
|
86
|
+
require 'version'
|
87
|
+
require 'poro_plus/version'
|
88
|
+
require 'poro_plus'
|
89
|
+
PoroPlus
|
90
|
+
include PoroPlus
|
91
|
+
attr_accessor :foo, :bar
|
92
|
+
end
|
93
|
+
thing_one = MyThing.new(:foo => 'Raven', :bar => 'Writing Desk')
|
94
|
+
thing_one.to_hash
|
95
|
+
class MyThing
|
96
|
+
attr_accessor :foo, :bar, :tres
|
97
|
+
end
|
98
|
+
thing_one = MyThing.new(:foo => 'Raven', :bar => 'Writing Desk', :tres => nil)
|
99
|
+
thing_one.to_json(:skip_nils => true)
|
100
|
+
exit
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
poro_plus (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.4)
|
10
|
+
rake (10.1.0)
|
11
|
+
rspec (2.13.0)
|
12
|
+
rspec-core (~> 2.13.0)
|
13
|
+
rspec-expectations (~> 2.13.0)
|
14
|
+
rspec-mocks (~> 2.13.0)
|
15
|
+
rspec-core (2.13.1)
|
16
|
+
rspec-expectations (2.13.0)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.13.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bundler (~> 1.3)
|
25
|
+
poro_plus!
|
26
|
+
rake
|
27
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Bantik
|
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,44 @@
|
|
1
|
+
# PoroPlus
|
2
|
+
Friendly methods intended to make POROs more useful.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'poro_plus'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install poro_plus
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Simply include PoroPlus into your Ruby class:
|
21
|
+
|
22
|
+
class MyThing
|
23
|
+
include PoroPlus
|
24
|
+
attr_accessor :foo, :bar, :tres
|
25
|
+
end
|
26
|
+
|
27
|
+
Then you can:
|
28
|
+
|
29
|
+
> thing_1 = MyThing.new(:foo => 'Raven', :bar => 'Writing Desk', :tres => nil)
|
30
|
+
=> #<MyThing:0x007ff4866ea398 @foo="Raven", @bar="Writing Desk", @tres=nil>
|
31
|
+
|
32
|
+
> thing_1.to_hash
|
33
|
+
=> {:foo=>"Raven", :bar=>"Writing Desk", :tres=>nil}
|
34
|
+
|
35
|
+
> thing_one.to_json(:skip_nils => true)
|
36
|
+
=> "{\"foo\":\"Raven\",\"bar\":\"Writing Desk\"}"
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/poro_plus.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module PoroPlus
|
4
|
+
|
5
|
+
def initialize(args={})
|
6
|
+
args.each{|k,v| self.public_send("#{k}=", v) if self.respond_to?("#{k}=")}
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_hash(args={})
|
10
|
+
instance_variables.inject({}) do |h, iv|
|
11
|
+
value = instance_variable_get(iv)
|
12
|
+
return h if value.nil? && args[:skip_nils]
|
13
|
+
h[sanitized_key(iv)] = value
|
14
|
+
h
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_json(args={})
|
19
|
+
to_hash(args).to_json
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def sanitized_key(instance_variable_name)
|
25
|
+
instance_variable_name.to_s.gsub('@','').to_sym
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/poro_plus.gemspec
ADDED
@@ -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
|
+
|
5
|
+
require 'poro_plus/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "poro_plus"
|
9
|
+
spec.version = PoroPlus::VERSION
|
10
|
+
spec.authors = ["Bantik"]
|
11
|
+
spec.email = ["corey@idolhands.com"]
|
12
|
+
spec.description = %q{Simple methods to make POROs more fun.}
|
13
|
+
spec.summary = %q{Simple methods to make Plain Old Ruby Objects (POROs) more fun.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PoroPlus do
|
4
|
+
|
5
|
+
class Thing
|
6
|
+
include PoroPlus
|
7
|
+
attr_accessor :foo
|
8
|
+
attr_accessor :bar
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#sanitized_key' do
|
12
|
+
it 'converts a @foo-style instance variable to a symbol' do
|
13
|
+
thing = Thing.new
|
14
|
+
thing.send(:sanitized_key, "@foo_bar").should == :foo_bar
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#to_hash' do
|
19
|
+
|
20
|
+
it 'serializes its instance variables' do
|
21
|
+
thing = Thing.new(:foo => 1, :bar => 2)
|
22
|
+
thing.to_hash[:foo].should == 1
|
23
|
+
thing.to_hash[:bar].should == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'skips nil-value instance variables if so configured' do
|
27
|
+
thing = Thing.new(:foo => 1, :bar => nil)
|
28
|
+
thing.to_hash(:skip_nils => true).keys.include?(:bar).should be_false
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: poro_plus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bantik
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-03 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
|
+
description: Simple methods to make POROs more fun.
|
63
|
+
email:
|
64
|
+
- corey@idolhands.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .console_history
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- Gemfile.lock
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- lib/poro_plus.rb
|
77
|
+
- lib/poro_plus/version.rb
|
78
|
+
- poro_plus.gemspec
|
79
|
+
- spec/lib/poro_plus/poro_plus_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
homepage: ''
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
hash: 2906580714184035242
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: 2906580714184035242
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 1.8.24
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: Simple methods to make Plain Old Ruby Objects (POROs) more fun.
|
112
|
+
test_files:
|
113
|
+
- spec/lib/poro_plus/poro_plus_spec.rb
|
114
|
+
- spec/spec_helper.rb
|