siringa 0.0.5 → 0.0.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11cf237b2bd1e3a7a176841483c73283b2a8ba1a
4
- data.tar.gz: 1b1d23655815f04acf332a8903e467990547bf8a
3
+ metadata.gz: 56fef5bef124061ab3bac9a1beafbc3828ab62b2
4
+ data.tar.gz: b796d80e4f3d83d0fa78d01e30582ef598589bb9
5
5
  SHA512:
6
- metadata.gz: 33592bd1f814a4b9c165fecb654b6da94cc191631caea3fc1d6c8931745a9158edb4b525f17f14223d5c00eb2c465e7759086dda050df3e854d2115777d25830
7
- data.tar.gz: 2f7134f3caff7c11a8920705ffbf8145c89335d2c8ee59af4c0dd07cb10d9809ea4eaf36bfbc5f399bef9fb0e03795dc431fe61c7e18d03afdd731d9a8cf1df1
6
+ metadata.gz: 1ab9793288d3af7d4fcae48224c7eb406bd7249b9722b1d0914a52597e2b5206707055491e9ccf597c0e0d1c9455f0b04a4d94163073dba3c7b3475ea85cda65
7
+ data.tar.gz: 675a854c035f548366636724203e834ea781e8dfefd5b77789fe27ddef7214e75204c5bffc355573b636169a736bd2fc929f9799dc9031f5b4e175128d817210
@@ -2,7 +2,7 @@ module Siringa
2
2
  class SiringaController < ApplicationController
3
3
 
4
4
  def load
5
- Siringa.load_definition(params['definition'].to_sym)
5
+ Siringa.load_definition(params['definition'].to_sym, options)
6
6
  resp = { :text => "Definition #{params['definition']} loaded.", :status => :created }
7
7
  rescue ArgumentError => exception
8
8
  resp = { :text => exception.to_s, :status => :method_not_allowed }
@@ -45,5 +45,13 @@ module Siringa
45
45
  render resp
46
46
  end
47
47
 
48
+ private
49
+
50
+ # Returns the arguments to be passed to the definition
51
+ #
52
+ # @return [Hash] arguments of the definition
53
+ def options
54
+ params[:siringa_args]
55
+ end
48
56
  end
49
57
  end
@@ -8,9 +8,10 @@ module Siringa
8
8
  # Load a definition and run its code
9
9
  #
10
10
  # @param [Symbol] name of the definition
11
- def self.load_definition(name)
11
+ # @param [Hash] arguments of the definition
12
+ def self.load_definition(name, options)
12
13
  if exists_definition?(name)
13
- @definitions[name].call
14
+ @definitions[name].call(options)
14
15
  else
15
16
  raise ArgumentError, "Definition #{name.to_s} does not exist.", caller
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module Siringa
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -20,4 +20,9 @@ class SiringaControllerTest < ActionController::TestCase
20
20
  assert_response :method_not_allowed
21
21
  end
22
22
 
23
+ test "load action passing arguments" do
24
+ get :load, { definition: "definition_with_arguments", siringa_args: { name: 'Robb Stark' }, use_route: "siringa" }
25
+ assert_response :success
26
+ end
27
+
23
28
  end
@@ -4,3 +4,7 @@ require File.expand_path('../../factories', __FILE__)
4
4
  Siringa.add_definition :initial do
5
5
  FactoryGirl.create :user, name: 'Jesse Pinkman'
6
6
  end
7
+
8
+ Siringa.add_definition :definition_with_arguments do |args|
9
+ FactoryGirl.create :user, name: args[:name]
10
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siringa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrico Stano
8
+ - Pau Pérez
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-12-03 00:00:00.000000000 Z
12
+ date: 2015-03-13 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sqlite3
@@ -28,6 +29,7 @@ description: Remotely populate DB for Rails applications for pure client accepta
28
29
  testing
29
30
  email:
30
31
  - enricostn@gmail.com
32
+ - saulopefa@gmail.com
31
33
  executables: []
32
34
  extensions: []
33
35
  extra_rdoc_files: []