bigbertha 0.0.4 → 0.0.5

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTRlMmEwMTA3ZTZlMjgxYTMwNTQyMzNjNmY1NmY2ZmNhYWNhZTQ5NA==
4
+ ZTY1ZmY3ZWVkY2E1NDc3YjI3ZDYyZjAwMWUxOTEwNTg5MmQzMjM1ZQ==
5
5
  data.tar.gz: !binary |-
6
- MWVhMTQ3NWUyZDMzZmFkZDNhMzhkZDRiNWY1MmVmMjIwNzdjYjMzOQ==
6
+ MGJjNWU5ZGUxMDc2MzRkNjE2MjFhYmFiMzkwNDQ5YWZlYzUyODE5ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWRlNjAwMWYxYTM5Nzg5MWM0ZTk5YmJiMzE0MmQ1MDNhN2IxNTI1M2FmNTli
10
- OWUyMmY3ZWIwNjZhMWNjZWQzMTVjZGNlNGE3YWY5NjlhMDJmMmUxZmY2Zjkz
11
- YzliM2Q5NDgzMjViZWY3ZGNlOTQ1NDNjY2Y2OWE4OTQ0YzE0NmY=
9
+ ZTA3YjhiYWZmZWM3MzA1MDQ0YzZjNDkwZTZiODFhOGJiZTYxODUwMDk3NTFi
10
+ NzBlOGQyZjJhNThkMzdhNGMwM2E1ODE0OTI3NjBiMTczOGU1NjU3MjVlMTFj
11
+ ZDE5ZTA5MGE0MTc5NjM4MzFiYjAzYTE2OGQyYzI4YmE2ZTc5ODE=
12
12
  data.tar.gz: !binary |-
13
- MGRhZDVlODM3OTk4YmIwNTM5N2EyOTQ0YmM4ZDc4MmI0YjdlZThlZDM5Y2Jk
14
- MjA1OTM4YzhkNzc3ZjEwMmUxZDFmYTU1ODcwNmIyMTVhZjkxMDg3NzE3NWE5
15
- MjNmYzAwOWU3ZmRmZjRmOWI3NzU1M2U3ZTk5OGVlNDE2ZjdjZmQ=
13
+ NzE0MjY5OWUyMTFlM2JlZmRlMTk5MmZhZDQ4NDY2MzFiNDk4MTI4OWUxOTk3
14
+ MGZmYWUwY2I4YWNmZWQxY2IwMGVkMTFlMjE0OWQ1NTM2MTNkYmM2ODY2ZTBi
15
+ YmU4Yjk3ZDhhMjBmNTQ1YzExYzkxYTA4YzRmMjVlNjQzNjQ0YTY=
data/README.md CHANGED
@@ -350,4 +350,7 @@ Bigbertha is released under the [MIT](http://opensource.org/licenses/MIT) licens
350
350
  + 0.0.4:
351
351
  + Added command line exec bb_auth_token to generate auth tokens
352
352
  + Added splat args to child
353
- + Deprecated Load. Use Ref from now on
353
+ + Deprecated Load. Use Ref from now on
354
+ + 0.0.5
355
+ + Added auth token expiration
356
+ + Added irb console bin
data/Rakefile CHANGED
@@ -17,6 +17,8 @@ desc 'Cleanup build artifacts'
17
17
  task :clean do
18
18
  cov = File.expand_path( File.join( %w(.. coverage) ), __FILE__ )
19
19
  FileUtils.rm_r( cov ) if File.exists?( cov )
20
+ pkg = File.expand_path( File.join( %w(.. pkg) ), __FILE__ )
21
+ FileUtils.rm_r( pkg ) if File.exists?( pkg )
20
22
  end
21
23
 
22
24
  desc 'Run samples'
@@ -7,10 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Bigbertha::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
 
10
- s.authors = [
11
- "Fernand Galiana"
12
- ]
13
-
10
+ s.authors = ["Fernand Galiana"]
14
11
  s.email = ["fernand.galiana@gmail.com"]
15
12
  s.homepage = "http://derailed.github.io/bigbertha"
16
13
  s.summary = %q{Ruby implementation for your Firebase battery}
@@ -7,15 +7,17 @@ Main {
7
7
  description 'Specifies the firebase secret token'
8
8
  cast :string
9
9
  }
10
- option( 'expiry' ) {
11
- description 'Time(int) at which the auth token will be considered invalid'
10
+ option( 'expires' ) {
11
+ description 'Number of days at which the auth token will be considered invalid. Default[30]'
12
12
  cast :integer
13
13
  argument :optional
14
+ defaults 30
14
15
  }
15
16
  option( 'valid_from' ) {
16
- description 'Time(int) before which the auth token will be considered invalid'
17
+ description 'Number of days before which the auth token will be considered invalid. Default[0]'
17
18
  cast :integer
18
19
  argument :optional
20
+ defaults 0
19
21
  }
20
22
  option( 'debug' ) {
21
23
  description 'Turns on debuging mode for security rules'
@@ -54,12 +56,20 @@ Main {
54
56
  puts '='*200
55
57
  end
56
58
 
59
+ def map_key( key )
60
+ keys = { valid_from: 'notBefore' }
61
+ keys[key] || key
62
+ end
63
+
57
64
  def run
58
65
  gen = Firebase::FirebaseTokenGenerator.new( params['secret'].value )
59
66
  opts = {}
60
- %w(admin simulate debug expiry valid_from).each do |key|
61
- opts[key.to_sym] = params[key].value if params[key].value != nil
67
+ %w(admin simulate debug).each do |key|
68
+ opts[map_key( key.to_sym )] = params[key].value unless params[key].value.nil?
62
69
  end
70
+ %w(expires valid_from).each do |key|
71
+ opts[map_key( key.to_sym)] = Time.now.to_i + params[key].value.to_i*24*60*60 unless params[key].value == 0
72
+ end
63
73
  unless params['data'].value.empty?
64
74
  data = JSON.parse( params['data'].value )
65
75
  else
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
3
+ require 'bundler'
4
+ Bundler.require
5
+ require 'bigbertha'
6
+ require 'irb'
7
+
8
+ Main {
9
+ def run
10
+ puts "BigBertha console"
11
+ IRB.start(__FILE__)
12
+ end
13
+ }
@@ -113,8 +113,9 @@ module Bigbertha
113
113
  if resp.response_code == 403
114
114
  raise PermissionDeniedError, "No permission for #{location}"
115
115
  end
116
- unless resp.success?
117
- raise InvalidRequestError, "<#{resp.return_code}> Unable to perform request #{location}"
116
+ unless resp.success?
117
+ error = "-- " + JSON.parse( resp.body )['error'] rescue ""
118
+ raise InvalidRequestError, "<#{resp.return_code}> Unable to perform request #{location} #{error}"
118
119
  end
119
120
  if resp.body.empty? or resp.body == "null"
120
121
  raise NoDataError, "No data found at location #{location}"
@@ -1,3 +1,3 @@
1
1
  module Bigbertha
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,10 +1,10 @@
1
- require 'bigbertha'
2
1
  require 'simplecov'
3
-
4
2
  if ENV['COV']
5
3
  SimpleCov.start do
6
4
  end
7
5
  end
8
6
 
7
+ require 'bigbertha'
8
+
9
9
  RSpec.configure do |config|
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigbertha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-10 00:00:00.000000000 Z
11
+ date: 2013-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  prerelease: false
@@ -86,6 +86,7 @@ email:
86
86
  - fernand.galiana@gmail.com
87
87
  executables:
88
88
  - bb_auth_token
89
+ - bb_console
89
90
  extensions: []
90
91
  extra_rdoc_files: []
91
92
  files:
@@ -95,6 +96,7 @@ files:
95
96
  - Rakefile
96
97
  - bigbertha.gemspec
97
98
  - bin/bb_auth_token
99
+ - bin/bb_console
98
100
  - examples/a.rb
99
101
  - examples/b.rb
100
102
  - examples/c.rb